Ticket #653: auth.diff

File auth.diff, 2.5 KB (added by dasnyderx@yahoo.com, 16 years ago)

Diff to the UI common and GTK UI connectionmanager files

  • deluge/ui/common.py

     
    2929
    3030from deluge import bencode
    3131from deluge.log import LOG as log
     32from deluge.core.authmanager import AuthManager
    3233import deluge.configmanager
    3334
    3435class TorrentInfo(object):
     
    128129    :returns: a localhost uri containing authentication information or None if the information is not available
    129130    """
    130131    auth_file = deluge.configmanager.get_config_dir("auth")
    131     if os.path.exists(auth_file):
    132         u = urlparse.urlsplit(uri)
    133         for line in open(auth_file):
    134             try:
    135                 username, password = line.strip().split(":")
    136             except ValueError:
    137                 continue
     132    if not os.path.exists(auth_file):
     133        AuthManager().start()
     134        auth_file = deluge.configmanager.get_config_dir("auth")
    138135
    139             if username == "localclient":
    140                 # We use '127.0.0.1' in place of 'localhost' just incase this isn't defined properly
    141                 hostname = u.hostname.replace("localhost", "127.0.0.1")
    142                 return u.scheme + "://" + username + ":" + password + "@" + hostname + ":" + str(u.port)
    143     return None
     136    u = urlparse.urlsplit(uri)
     137    rtn_uri = None
     138    for line in open(auth_file):
     139        try:
     140            username, password = line.strip().split(":")
     141        except ValueError:
     142            continue
     143
     144        # We use '127.0.0.1' in place of 'localhost'
     145        # just incase this isn't defined properly
     146        hostname = u.hostname.replace("localhost", "127.0.0.1")
     147
     148        if username == "localclient" and hostname == "127.0.0.1":
     149            rtn_uri = u.scheme + "://" + username + ":" + password + "@" + hostname + ":" + str(u.port)
     150
     151    return rtn_uri
  • deluge/ui/gtkui/connectionmanager.py

     
    157157                # We need to keep trying because the daemon may not have been started yet
    158158                # and the 'auth' file may not have been created
    159159                uri = get_localhost_auth_uri(DEFAULT_URI)
     160                if uri == None:
     161                    raise Exception('Could not locate localclient authorization')
    160162                time.sleep(0.01)
    161163
    162164            while not self.test_online_status(uri):