mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-18 08:08:46 +00:00
Fix console daemon connect
This commit is contained in:
parent
c2c93f00de
commit
7171df62eb
1 changed files with 21 additions and 1 deletions
|
@ -90,11 +90,31 @@ def load_commands(command_dir, exclude=[]):
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def get_localhost_auth_uri(uri):
|
||||||
|
"""
|
||||||
|
Grabs the localclient auth line from the 'auth' file and creates a localhost uri
|
||||||
|
|
||||||
|
:param uri: the uri to add the authentication info to
|
||||||
|
:returns: a localhost uri containing authentication information or None if the information is not available
|
||||||
|
"""
|
||||||
|
import deluge.configmanager
|
||||||
|
auth_file = deluge.configmanager.get_config_dir("auth")
|
||||||
|
if os.path.exists(auth_file):
|
||||||
|
import urlparse
|
||||||
|
u = urlparse.urlsplit(uri)
|
||||||
|
for line in open(auth_file):
|
||||||
|
username, password = line.split(":")
|
||||||
|
if username == "localclient":
|
||||||
|
# We use '127.0.0.1' in place of 'localhost' just incase this isn't defined properly
|
||||||
|
hostname = u.hostname.replace("localhost", "127.0.0.1")
|
||||||
|
return u.scheme + "://" + username + ":" + password + "@" + hostname + ":" + str(u.port)
|
||||||
|
return None
|
||||||
|
|
||||||
class ConsoleUI(object):
|
class ConsoleUI(object):
|
||||||
prompt = '>>> '
|
prompt = '>>> '
|
||||||
|
|
||||||
def __init__(self, args=None):
|
def __init__(self, args=None):
|
||||||
client.set_core_uri("http://localhost:58846")
|
client.set_core_uri(get_localhost_auth_uri("http://localhost:58846"))
|
||||||
self._commands = load_commands(os.path.join(UI_PATH, 'commands'))
|
self._commands = load_commands(os.path.join(UI_PATH, 'commands'))
|
||||||
if args:
|
if args:
|
||||||
self.precmd()
|
self.precmd()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue