Ejemplo n.º 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
Ejemplo n.º 2
0
def main():
    log = Logger('hub')

    log.info('Starting %s %s' % (full_name, version))

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

    server = ConnectionSocketServer(cfg['listen'].host(), cfg['listen'].port())
    request = Request()

    signals.connect('connection:connected', client.add)
    signals.connect('connection:disconnected', client.remove)
    signals.connect('connection:data_received', request.parse)

    signals.connect('data:on_info', client.on_info)

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

    del server
Ejemplo n.º 3
0
def main():
    log = Logger('hub')

    log.info('Starting %s %s' % (full_name, version))

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

    server = ConnectionSocketServer(cfg['listen'].host(),
                                    cfg['listen'].port())
    request = Request()

    signals.connect('connection:connected', client.add)
    signals.connect('connection:disconnected', client.remove)
    signals.connect('connection:data_received', request.parse)

    signals.connect('data:on_info', client.on_info)

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

    del server
Ejemplo n.º 4
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
Ejemplo n.º 5
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