You are not logged in.

#1 2011-07-01 01:48:46

colbert
Member
Registered: 2007-12-16
Posts: 809

Need help with python script for Deluge

I am using Deluge 1.3.2 with web server, and all works fine, I use this script in the Deluge settings to execute upon torrent completion:

#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3
torrenttimedelta=`/usr/bin/python2 /home/bobby/scripts/deluge/torrentTimeDelta.py $1`

subject="Started download new torrent!"
message="$torrentname to $torrentpath"

echo -e `date`"::Finished downloading torrent:$2 in: $3" with id:$torrentid >> ~/logs/scripts.log
echo -e `sendEmail -t my@email.com -f my@email.com -u "deluge server notification: torrent $torrentname is complete!" -m "$torrentname has completed downloading at: $torrentpath and took $torrenttimedelta to complete :)" -xu my@email.com -xp password -v -o tls=yes -s email.com` >> ~/logs/scripts.log
echo ---------------------------------------- >> ~/logs/scripts.log

This is to email me when a torrent is done and works. What I wanted to add to this email was the time taken to complete the torrent. I have gotten help from Deluge forum in this thread: http://forum.deluge-torrent.org/viewtop … =9&t=36989  However I think it's something with Python within Arch that is the obstacle, and so that helpful person can't do much more IMO. The python script I'm using is:

#!/usr/bin/python2

from deluge.ui.client import client
from twisted.internet import reactor

d = client.connect()

def on_connect_success(result):
    print "Connection was successful!"
    def on_get_torrent_value(value):

        for torrent in value:
                print "%s: %s" % (torrent, value[torrent]["name"])
        
        client.disconnect()
        reactor.stop()
        
    client.core.get_torrents_status({}, ["name"]).addCallback(on_get_torrent_value)

d.addCallback(on_connect_success)

def on_connect_fail(result):
    print "Connection failed!"
    print "result:", result

d.addErrback(on_connect_fail)

reactor.run()

Now if I call this from shell directly, it works. However, including it with my email script at the top, Deluge itself freezes and no email is sent. I run ps aux | grep deluge and I can see that the script has run, but apparently died and all is just hanging. I kill the script process and Deluge resumes just fine, the email is sent. Kinda confused how to remedy this, appreciate any help smile Thanks

P.S. When I get the email, the part that says ""$torrentname has completed downloading at: $torrentpath and took $torrenttimedelta to complete smile"" shows nothing where $torrenttimedelta should be, it just says "and took to complete"

Offline

#2 2011-07-05 19:10:22

rickeyski
Member
Registered: 2011-01-27
Posts: 25

Re: Need help with python script for Deluge

[edit]  Sorry, I don't use deluge and I messed up my test script. If the script is executable try `/home/bobby/scripts/deluge/torrentTimeDelta.py $1`
Are there any other errors? or try running bash with debug output to see if it will tell you something else


The problem you are having is bash doesn't recognize variables inside the tick marks.


Hope that helps

Last edited by rickeyski (2011-07-05 19:27:36)

Offline

Board footer

Powered by FluxBB