Deluge.ui.client not importing in python

General support for problems installing or using Deluge
Post Reply
Divc09
New User
New User
Posts: 4
Joined: Wed Oct 26, 2016 2:06 pm

Deluge.ui.client not importing in python

Post 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.
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge.ui.client not importing in python

Post 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
Divc09
New User
New User
Posts: 4
Joined: Wed Oct 26, 2016 2:06 pm

Re: Deluge.ui.client not importing in python

Post 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.
Cas
Top Bloke
Top Bloke
Posts: 3681
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Deluge.ui.client not importing in python

Post 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...
Divc09
New User
New User
Posts: 4
Joined: Wed Oct 26, 2016 2:06 pm

Re: Deluge.ui.client not importing in python

Post 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.
Post Reply