Page 1 of 1

Deluge.ui.client not importing in python

Posted: Wed Oct 26, 2016 2:19 pm
by Divc09
Ok so this forum is my last hope. I have been trying to get this to script to work for days at this point. The OS is windows 7 btw.

Code: Select all

#!/usr/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()
The line with the error is "from deluge.ui.client import client"
I have wasted hours on it and i still get the same error no matter what I do which is

Code: Select all

Traceback (most recent call last):
  File "C:\Scripts\getLabel.py", line 5, in <module>
    from deluge.ui.client import client
ImportError: No module named 'deluge'

This is with python. Does anyone have the slightest clue about what to do to get this working. If someone knows how to fix this please reply or even if you could just provide additional info. I really need this. Thanks a million to anyone who helps. I just want to import the client and I have restarted deluge multiple times with both classic mode enabled and disabled to no avail. Please help if someone knows how to as multiple people are using this script. Thanks again. Hoping that it works this time.

Re: Deluge.ui.client not importing in python

Posted: Wed Oct 26, 2016 5:58 pm
by Cas
Deluge application is standalone (i.e. has it's own python) so the only way to run the script is to either install Deluge from source in your Python or place the script in the Deluge app folder and run it from there

Re: Deluge.ui.client not importing in python

Posted: Thu Oct 27, 2016 9:59 am
by Divc09
Thank you so much for responding. I don't know how to install deluge from source or what that means. I placed the script in the deluge folder and the error disappeared except another error was returned -
Traceback (most recent call last):
File "C:\Program Files\Deluge\deluge-1.3.11-py2.6.egg\getLabel.py", line 5, in <module>
from deluge.ui.client import client
ImportError: bad magic number in 'deluge.ui.client': b'\xd1\xf2\r\n'
Any way to fix this or could you tell me how to install deluge from source?
Again thanks a lot for responding. This is the first time I've been able to make this script work a little bit.

Re: Deluge.ui.client not importing in python

Posted: Thu Oct 27, 2016 1:17 pm
by Cas
ImportError: bad magic number
This means mismatching Python versions between Deluge Python and your OS Python installed version, most likely Py2.7? If so install the Deluge that contains py2.7 and it should work..
could you tell me how to install deluge from source?
Read the docs...

Re: Deluge.ui.client not importing in python

Posted: Thu Oct 27, 2016 1:33 pm
by Divc09
Alright so I installed a bunch of things and made everything go past the first two lines but now i get this error
Traceback (most recent call last):
File "C:\Program Files\Deluge\deluge-1.3.13-py2.7.egg\getLabel.py", line 13, in <module>
torrent_id = sys.argv[1]
IndexError: list index out of range
>>>
I'm not sure what this means. It's definitely something with deluge though.
Edit- When I change the 1 to a 0 it gives me this
[Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionRefusedError'>: Connection was refused by other side: 10061: No connection could be made because the target machine actively refused it..
]
Does this mean it's working with 0 or something? Could not have gotten this far without you so thanks.