예제 #1
0
def install():
    dhnio.Dprint(4, 'transport_q2q.install')
       
    def done(x, resultDefer): 
        dhnio.Dprint(4, 'transport_q2q.install.done')
        settings.setQ2Quserathost(str(dhnvertex.getFrom()))
        resultDefer.callback(x)
        return x
        
    def failed(x, resultDefer):
        dhnio.Dprint(4, 'transport_q2q.install.failed: ' + x.getErrorMessage())
        resultDefer.errback(x)
        return x

    result = Deferred()
    username = misc.getIDName() + time.strftime('%Y%m%d%H%M%S') + '@' + settings.DefaultQ2QServer()
    password = settings.getQ2Qpassword()
    if password.strip() == '':
        password = misc.rndstr(NEW_USER_PASSWORD_LENGTH)
        settings.setQ2Qpassword(password)

    d = dhnvertex.register(username, password)
    d.addCallback(done, result)
    d.addErrback(failed, result)

    return result
예제 #2
0
def register(user, password):
    return dhnvertex.register(user, password)