コード例 #1
0
def Pyom():
    sys.path.append(os.getcwd())
    logger.boot('Logging system initialized.')
    server = TelnetServer(port=PORT)
    server.on_connect = init_descriptor
    server.on_disconnect = close_socket

    init_monitoring()
    logger.boot('Entering Game Loop')
    game_loop(server)
    logger.critical('System halted.')
コード例 #2
0
ファイル: pyom.py プロジェクト: carriercomm/PyRom
def Pyom():
    sys.path.append(os.getcwd())
    logger.boot('Logging system initialized.')
    server = TelnetServer(port=PORT)
    server.on_connect = init_descriptor
    server.on_disconnect = close_socket

    init_monitoring()
    logger.boot('Entering Game Loop')
    game_loop(server)
    logger.critical('System halted.')
コード例 #3
0
ファイル: pywars.py プロジェクト: cl0neless/PythonWars-1996
def pywars():
    global server

    sys.path.append(os.getcwd())

    server = TelnetServer(port=PORT)
    server.on_connect = init_descriptor
    server.on_disconnect = close_socket

    init_monitoring()
    game_loop(server)
    notify("Termination of game", merc.CONSOLE_CRITICAL)
コード例 #4
0
def main():
    # Create LOG dir if it doesn't exist
    if not os.path.exists(defaults['LOGDIR']):
        os.mkdir(defaults['LOGDIR'])

    server = TelnetServer(port=PORT)
    server.on_connect = my_on_connect
    server.on_disconnect = my_on_disconnect

    print(f"Starting server on port {server.port}. CTRL-C to interrupt.")

    while True:
        try:
            server.poll()  # Send, Recv, and look for new connections
            kick_idle()  # Check for idle clients
            process_client()  # Check for client input
        except KeyboardInterrupt:
            server.stop()
            print("Server shutdown.")
            break
コード例 #5
0
ファイル: handler_demo.py プロジェクト: Brawn1/miniboa-py3
    """
    Example on_connect handler.
    """
    client.send('You connected from %s\n' % client.addrport())
    if CLIENTS:
        client.send('Also connected are:\n')
        for neighbor in CLIENTS:
            client.send('%s\n' % neighbor.addrport())
    else:
        client.send('Sadly, you are alone.\n')
    CLIENTS.append(client)


def my_on_disconnect(client):
    """
    Example on_disconnect handler.
    """
    CLIENTS.remove(client)


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    server = TelnetServer()
    server.on_connect=my_on_connect
    server.on_disconnect=my_on_disconnect

    logging.info("Starting server on port {}. CTRL-C to interrupt.".format(server.port))
    while True:
        server.poll()
コード例 #6
0
    Example on_connect handler.
    """
    client.send('You connected from %s\n' % client.addrport())
    if CLIENTS:
        client.send('Also connected are:\n')
        for neighbor in CLIENTS:
            client.send('%s\n' % neighbor.addrport())
    else:
        client.send('Sadly, you are alone.\n')
    CLIENTS.append(client)


def my_on_disconnect(client):
    """
    Example on_disconnect handler.
    """
    CLIENTS.remove(client)


if __name__ == "__main__":
    logging.basicConfig(level=logging.DEBUG)

    server = TelnetServer()
    server.on_connect = my_on_connect
    server.on_disconnect = my_on_disconnect

    logging.info("Starting server on port {}. CTRL-C to interrupt.".format(
        server.port))
    while True:
        server.poll()
コード例 #7
0
    os.chdir(telnet_lib_dir)
    sys.path.insert(0, telnet_lib_dir)

    ## start telnet server on port 4711
    CLIENTS = []
    def on_connect(client):
        CLIENTS.append(client)
        client.send('You connected from %s\r\n' % client.addrport())

    def on_disconnect(client):
        CLIENTS.remove(client)

    from miniboa import TelnetServer
    server = TelnetServer(port=4711)
    server.on_connect = on_connect
    server.on_disconnect = on_disconnect
    print 'Waiting on port 4711 for connections...'
    while True:
        for client in CLIENTS:
            if client.cmd_ready:
                cmd = client.get_command()

                # ls
                if cmd.startswith('ls'):
                    client.send(
                        '\n'.join(
                            os.listdir(
                                cmd.split(' ')[1] if len(cmd.split(' ')) > 1 else '/'
                            )
                        )
                    )
コード例 #8
0
    sys.path.insert(0, telnet_lib_dir)

    ## start telnet server on port 4711
    CLIENTS = []

    def on_connect(client):
        CLIENTS.append(client)
        client.send('You connected from %s\r\n' % client.addrport())

    def on_disconnect(client):
        CLIENTS.remove(client)

    from miniboa import TelnetServer
    server = TelnetServer(port=4711)
    server.on_connect = on_connect
    server.on_disconnect = on_disconnect
    print 'Waiting on port 4711 for connections...'
    while True:
        for client in CLIENTS:
            if client.cmd_ready:
                cmd = client.get_command()

                # ls
                if cmd.startswith('ls'):
                    client.send('\n'.join(
                        os.listdir(
                            cmd.split(' ')[1]
                            if len(cmd.split(' ')) > 1 else '/')))

                # date
                elif cmd.startswith('date'):