예제 #1
0
def main():
    global cfg

    log = Logger('manager')
    log.info("Starting DarkCloud Manager")

    cfg = Config('manager')
    if not cfg.is_loaded():
        sys.exit(1)

    client = ConnectionSocketClient(cfg['hub'].host(), cfg['hub'].port())
    request = Request()

    if client == False:
        sys.exit(1)

    signals.connect('connection:connected', on_connect)
    signals.connect('connection:data_received', request.parse)

    client.connect()

    try:
        while True:
            client.pool()
    except KeyboardInterrupt:
        sys.stdout.write('\r')
        log.info('Exiting on user request (Ctrl+C)')
        pass

    client.disconnect()

    del client
예제 #2
0
def main():
    global cfg

    cfg = Config('client')

    if not cfg.is_loaded():
        sys.exit(1)

    client = ConnectionSocketClient(cfg['hub'].host(),
                                    cfg['hub'].port())
    if client == False:
        sys.exit(1)

    signals.connect('connection:connected', on_connect)
    signals.connect('connection:data_received', on_recv)

    client.connect()

    x = client.remote_addr().split(':')
    remote = '%s:%s' % (gethostbyaddr(x[0])[0], x[1])

    global last_cmd

    try:
        cmd = ''
        while True:
            cmd = raw_input("%s " % (cfg['prompt'].ansi() % remote))
            if cmd == 'quit':
                raise EOFError
            if not cmd:
                continue
            last_cmd = cmd

            client.sendjson({
                'action': cmd
            })
            client.pool()

    except KeyboardInterrupt:
        print("quit")
        pass
    except EOFError:
        pass

    print("Quitting...")

    client.disconnect()

    del client
예제 #3
0
def main():
    global cfg

    cfg = Config('client')

    if not cfg.is_loaded():
        sys.exit(1)

    client = ConnectionSocketClient(cfg['hub'].host(), cfg['hub'].port())
    if client == False:
        sys.exit(1)

    signals.connect('connection:connected', on_connect)
    signals.connect('connection:data_received', on_recv)

    client.connect()

    x = client.remote_addr().split(':')
    remote = '%s:%s' % (gethostbyaddr(x[0])[0], x[1])

    global last_cmd

    try:
        cmd = ''
        while True:
            cmd = raw_input("%s " % (cfg['prompt'].ansi() % remote))
            if cmd == 'quit':
                raise EOFError
            if not cmd:
                continue
            last_cmd = cmd

            client.sendjson({'action': cmd})
            client.pool()

    except KeyboardInterrupt:
        print("quit")
        pass
    except EOFError:
        pass

    print("Quitting...")

    client.disconnect()

    del client