Connecting to deluged via Python

General support for problems installing or using Deluge
scolby33
New User
New User
Posts: 5
Joined: Tue Sep 10, 2013 2:46 pm
OS or Distro: Ubuntu 13.04

Connecting to deluged via Python

Postby scolby33 » Tue Sep 10, 2013 3:01 pm

Hello. I am setting up a home server using a combination of flexget, deluged, and filebot. The first two-thirds of this works beautifully; flexget successfully connects to deluge and passes the torrent/magnet information. In deluge, I am using the Execute plugin to run the script from here [http://forum.deluge-torrent.org/viewtopic.php?f=9&p=172841] upon torrent completion. This script consistently fails, with the following error message:

Code: Select all

2013-09-09 22:09:03,051 Download complete: {torrent id}
2013-09-09 22:09:03,051 Connecting to deluge
2013-09-09 22:09:03,055 Connecting to daemon at 127.0.0.1:58846..
2013-09-09 22:09:03,058 Connected to daemon at 127.0.0.1:58846..
2013-09-09 22:09:03,067 RPCError Message Received!
--------------------------------------------------------------------------------
RPCRequest: daemon.login(, )
--------------------------------------------------------------------------------
  File "/usr/lib/python2.7/dist-packages/deluge/core/rpcserver.py", line 259, in dispatch
    ret = component.get("AuthManager").authorize(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/deluge/core/authmanager.py", line 87, in authorize
    raise BadLoginError("Username does not exist")

BadLoginError: Username does not exist
--------------------------------------------------------------------------------
2013-09-09 22:09:03,068 Connection failed: [Failure instance: Traceback (failure with no frames): <class 'deluge.ui.client.DelugeRPCError'>: <deluge.ui.client.DelugeRPCError object at 0x7f9796e85bd0>
]
2013-09-09 22:09:03,068 Connection lost to daemon at 127.0.0.1:58846 reason: Connection was closed cleanly.

Clearly, the script is unable to authenticate with the daemon. These are the contents of my deluge auth file:

Code: Select all

localclient:{bunch of random characters}:10
flexget:{flexgetpass}:10


As a side note, any connection using deluge-console fails with "reason: Username does not exist".

My question is this: in flexget, I am required to pass a username and password for authentication to deluge. In the script I am using, it just uses the client.connect() method with no obvious facility to pass authentication details. Is there something wrong with my localclient configuration in the auth file? Or is there a method to connect to deluge in python that passes a username and password?

Thank you in advance for your help!

scolby33
New User
New User
Posts: 5
Joined: Tue Sep 10, 2013 2:46 pm
OS or Distro: Ubuntu 13.04

Re: Connecting to deluged via Python

Postby scolby33 » Fri Sep 13, 2013 2:47 am

I have a quick update that solved my problem, although not in the best possible way. I have appended the following line to my auth file:

Code: Select all

::10

Now, both the script and deluge-console connect to deluged with no problems. I am not happy with the need to leave a blank username with a blank password lying around, but it seems to be the only option if no one can come up with a way to reasonable authentication using the python API.

Cas
Top Bloke
Top Bloke
Posts: 3473
Joined: Mon Dec 07, 2009 6:04 am
OS or Distro: Ubuntu 16.04
Location: Scotland

Re: Connecting to deluged via Python

Postby Cas » Fri Sep 13, 2013 11:05 am

client.connect() can take user/pass details: http://deluge-torrent.org/docs/master/m ... lient.html

The problem is due to default config location based on the running user so another way to solve it by copying your auth file (or just the localclient line) from the service user's config to the user's config that is running the script which will also enable deluge-console to work.

scolby33
New User
New User
Posts: 5
Joined: Tue Sep 10, 2013 2:46 pm
OS or Distro: Ubuntu 13.04

Re: Connecting to deluged via Python

Postby scolby33 » Fri Sep 13, 2013 6:27 pm

Adding the user/pass details to client.connect() worked! Thank you for pointing me to this documentation; I am surprised I didn't come across it in my google searches.

Your answer leads to an interesting question, however. The script is executed by deluge's "Execute" plugin. I would have assumed that the script would be running as the same user as deluged is...the localclient connection does work since the command:

Code: Select all

sudo -H -u debian-deluged deluge-console

allows the console to connect automatically. I will have the script log its uid/gid to see what is going on here.

Edit: after poking around and trying a few things, it seems that the problem arises because I am using the non-standard configuration directory ~/config instead of ~/.config/deluge/. The deluge-console command, at least, looks for the .config directory and, upon not finding it, creates an empty directory that contains no auth file at all.

sgtwtf
New User
New User
Posts: 4
Joined: Fri Sep 20, 2013 5:17 am
OS or Distro: weezy

Re: Connecting to deluged via Python

Postby sgtwtf » Fri Sep 20, 2013 6:07 am

any followup on this? im doing the exact same thing, having the same issue and that command string worked for me but how can we parlay this into something that is a fix? i copied the auth file to everyplace it could look for it . im running weezy btw

now the console give me an error about password does not match but it does i even reset it to make sure....i hatethis auth file...

scolby33
New User
New User
Posts: 5
Joined: Tue Sep 10, 2013 2:46 pm
OS or Distro: Ubuntu 13.04

Re: Connecting to deluged via Python

Postby scolby33 » Fri Sep 20, 2013 2:06 pm

I have not been able to make any use of the deluge-console command work without running it as the debian-deluged user. I changed my config directory to be /var/lib/debian-deluged/.config/deluge. The home directory for the debian-deluged user is set as /var/lib/debian-deluged. As for running it as my normal login user, I have not tried copying the auth file around, as I am not usually going to need deluge-console from the console.

sgtwtf
New User
New User
Posts: 4
Joined: Fri Sep 20, 2013 5:17 am
OS or Distro: weezy

Re: Connecting to deluged via Python

Postby sgtwtf » Fri Sep 20, 2013 3:52 pm

ok so after playing around with soooooo may google searches i tried something. i think the init script is missing something. i ran

Code: Select all

# deluged
and now everything works... just working on how to make that run on boot. try that and see if it works for your issues.
Last edited by sgtwtf on Fri Sep 20, 2013 7:35 pm, edited 2 times in total.

scolby33
New User
New User
Posts: 5
Joined: Tue Sep 10, 2013 2:46 pm
OS or Distro: Ubuntu 13.04

Re: Connecting to deluged via Python

Postby scolby33 » Fri Sep 20, 2013 7:29 pm

Oh, sorry. I thought you were asking about the second part. To configure flexget to work with deluge, just include something like this in your preset or what have you in the config file:

Code: Select all

    deluge:
      path: {your path}
      user: flexget
      pass: {your password}
      label: flexget


And your auth file should look like:

Code: Select all

flexget:{your password}:10


Check out the documentation here: http://flexget.com/wiki/Plugins/deluge

sgtwtf
New User
New User
Posts: 4
Joined: Fri Sep 20, 2013 5:17 am
OS or Distro: weezy

Re: Connecting to deluged via Python

Postby sgtwtf » Fri Sep 20, 2013 7:31 pm

scolby33 wrote:Oh, sorry. I thought you were asking about the second part. To configure flexget to work with deluge, just include something like this in your preset or what have you in the config file:

Code: Select all

    deluge:
      path: {your path}
      user: flexget
      pass: {your password}
      label: flexget


And your auth file should look like:

Code: Select all

flexget:{your password}:10


Check out the documentation here: http://flexget.com/wiki/Plugins/deluge


I had all that and it caused issues. after i ran deluged everything works and i took out everything below "path" from my flexget config.yml

Skyway
New User
New User
Posts: 3
Joined: Tue Jun 07, 2016 7:41 am
OS or Distro: Debian

Re: Connecting to deluged via Python

Postby Skyway » Sat Feb 10, 2018 12:30 pm

same issue here. Can't get flexget to connect to deluge. It seems it needs deluge installed with pip.
but can't do that!?

Code: Select all

Could not find a version that satisfies the requirement deluge (from versions: )
No matching distribution found for deluge

How did u solved this?


Return to “Support”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests