Deluge script using wrong XDG_CONFIG_HOME
Posted: Tue Aug 12, 2014 12:33 am
I'm working on a new headless Deluge 1.3.6 setup with FreeBSD 10 as the base. Everything is working just fine, but when a torrent finishes downloading, I'd like to copy it to the completed directory, rather than move it. To do this, I'm using the 'Execute' and 'Label' plugins, and copying to the destination based on the label. The problem is that the python script, when executed via the plugin, tries to read /root/.config/deluge rather than ~/.config/deluge.
The python script in question is the same one floating around the forums:
And I'm running it via the following shell script:
The output from ~/bin/get_label.py ${TORRENT_ID} when I run it manually as the appropriate user is exactly what it should be ("tv", "movie", "distro", etc.). But when it runs via the plugin, it just comes back with
I've even tried an "export XDG_CONFIG_HOME="${HOME}/.config" at the top of the shell script, but that doesn't help any. What's going on? Why is xdg reporting back with the wrong XDG_CONFIG_HOME, even when I try to force it? Or is there a better way to copy rather than move a file when finished downloading?
The python script in question is the same one floating around the forums:
Code: Select all
#!/usr/local/bin/python
import sys
from deluge.ui.client import client
from twisted.internet import reactor
# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()
d = client.connect()
torrent_id = sys.argv[1]
def on_connect_success(result):
def on_get_torrent_status(torrent):
print torrent["label"]
client.disconnect()
reactor.stop()
client.core.get_torrent_status(torrent_id, ["label"]).addCallback(on_get_torrent_status)
d.addCallback(on_connect_success)
def on_connect_fail(result):
print result
reactor.stop()
d.addErrback(on_connect_fail)
reactor.run()
Code: Select all
$ cat copy_torrent.sh
#!/bin/sh
# export XDG_CONFIG_HOME="${HOME}/.config"
TORRENT_ID="${1}"
TORRENT_NAME="${2}"
TORRENT_PATH="${3}"
NEW_BASE="/media/New"
test -z "${TORRENT_ID}" && exit 255
test -z "${TORRENT_NAME}" && exit 254
test -z "${TORRENT_PATH}" && exit 253
TORRENT_LABEL="$(~/bin/get_label.py ${TORRENT_ID})"
case "${TORRENT_LABEL}" in
tv | television ) RELDEST="TV" ;;
movie | movies ) RELDEST="Movies" ;;
music ) RELDEST="Music" ;;
esac
DESTINATION="${NEW_BASE}/${RELDEST}"
rsync -HrltpDq "${TORRENT_PATH}"/"${TORRENT_NAME}" "${DESTINATION}"
Code: Select all
[ERROR ] 00:16:38 common:167 Unable to use default config directory, exiting... ([Errno 13] Permission denied: '/root/.config/deluge')