'Connects to the deluge daemon and runs on_connect_success'

def connect(self, task, config):

    if ((config[u'host'] in [u'localhost', u'127.0.0.1']) and (not config.get(u'username'))):
        auth = get_localhost_auth()
        if auth[0]:
            (config[u'username'], config[u'password']) = auth
        else:
            raise plugin.PluginError(u'Unable    to    get    local    authentication    info    for    Deluge.    You    may    need    to    specify    an    username    and    password    from    your    Deluge    auth    file.')
    client.set_disconnect_callback(self.on_disconnect)
    d = client.connect(host=config[u'host'], port=config[u'port'], username=config[u'username'], password=config[u'password'])
    d.addCallback(self.on_connect_success, task, config).addErrback(self.on_connect_fail)
    result = reactor.run()
    if isinstance(result, Exception):
        raise result
    return result
