Exemple #1
0
 def callback(args):
     user, e = args
     if e is None:
         count[0] -= 1
         print "Connected with {}! ({} left)".format(user, count[0])
         if not count[0]:
             semaphore.release()
     else:
         not_connected.append(e.client)
         print "{}: {}".format(user, e)
         if e.code == 101 or e.code == 603:
             common.remove_penguin(cpps, user, penguins)
         semaphore.release()
Exemple #2
0
def login():
    remember = common.get_remember()
    argc = len(sys.argv)
    cpps = sys.argv[1] if argc > 1 else None
    server = sys.argv[2] if argc > 2 else None
    user = sys.argv[3] if argc > 3 else None
    cpps, server, user, password, encrypted, client = common.get_penguin(
        cpps, server, user, remember)
    try:
        client.connect(user, password, encrypted)
    except ClientError as e:
        if e.code == 101 or e.code == 603:
            common.remove_penguin(cpps, user)
        raise common.LoginError("Failed to connect")
    print "Connected!"
    return client
Exemple #3
0
def manual_login(cpps, server, shape, connected, not_connected, remember):
    pool = ThreadPool()
    for i, client in enumerate(not_connected):
        while not client.connected:
            cpps, server, user, password, encrypted, client = common.get_penguin(
                cpps, server, remember=remember, client=client)
            if any(client.name.lower() == user for client in connected):
                print "Already logged in"
                continue
            print "Connecting..."
            try:
                client.connect(user, password)
            except ClientError as e:
                print e
                if e.code == 101 or e.code == 603:
                    common.remove_penguin(cpps, user)
                continue
            equip(client, shape, pool)
            print "Connected! ({} left)".format(len(not_connected) - i - 1)
    pool.close()
    pool.join()