示例#1
0
def main():
    # parse the command line arguments
    parser = ArgumentParser(usage=__doc__)
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    # make a network
    network = IPNetwork()

    console = ConsoleClient()
    middle_man = MiddleMan()

    bip = BIPSimple()
    annexj = AnnexJCodec()
    mux = FauxMultiplexer("192.168.0.1/24", network)
    bind(console, middle_man, bip, annexj, mux)

    # add some more debugging nodes
    for i in range(2, 4):
        debug_address = "192.168.0.{}/24".format(i)

        debug_debug = Debug(debug_address)
        debug_bip = BIPSimple()
        debug_annexj = AnnexJCodec()
        debug_mux = FauxMultiplexer(debug_address, network)

        bind(debug_debug, debug_bip, debug_annexj, debug_mux)

    _log.debug("running")

    run()

    _log.debug("fini")
示例#2
0
def main():
    """
    Main function, called when run as an application.
    """
    global server_address

    # check the version
    if (sys.version_info[:2] != (2, 5)):
        sys.stderr.write("Python 2.5 only\n")
        sys.exit(1)

    # parse the command line arguments
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        "host",
        nargs='?',
        help="address of host (default %r)" % (SERVER_HOST, ),
        default=SERVER_HOST,
    )
    parser.add_argument(
        "port",
        nargs='?',
        type=int,
        help="server port (default %r)" % (SERVER_PORT, ),
        default=SERVER_PORT,
    )
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    # extract the server address and port
    host = args.host
    port = args.port
    server_address = (host, port)
    if _debug: _log.debug("    - server_address: %r", server_address)

    # build the stack
    this_console = ConsoleClient()
    if _debug: _log.debug("    - this_console: %r", this_console)

    this_middle_man = MiddleMan()
    if _debug: _log.debug("    - this_middle_man: %r", this_middle_man)

    this_director = TCPClientDirector()
    if _debug: _log.debug("    - this_director: %r", this_director)

    bind(this_console, this_middle_man, this_director)
    bind(MiddleManASE(), this_director)

    # create a task manager for scheduled functions
    task_manager = TaskManager()
    if _debug: _log.debug("    - task_manager: %r", task_manager)

    # don't wait to connect
    this_director.connect(server_address)

    if _debug: _log.debug("running")

    run()
示例#3
0
def main():
    # parse the command line arguments
    parser = ArgumentParser(usage=__doc__)
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    address = Address("192.168.0.1/24")
    if _debug: _log.debug("    - local_address: %r", address)

    # make a network
    network = IPNetwork()

    console = ConsoleClient()
    middle_man = MiddleMan()

    fauxmux = FauxMux(address, network)
    bind(console, middle_man, fauxmux)

    # add some more debugging nodes
    for i in range(2, 4):
        debug_address = "192.168.0.{}/24".format(i)

        debug_debug = Debug(debug_address)
        debug_fauxmux = FauxMux(Address(debug_address), network)

        bind(debug_debug, debug_fauxmux)

    _log.debug("running")

    run()

    _log.debug("fini")
示例#4
0
def main():
    """
    Main function, called when run as an application.
    """
    global server_address

    # parse the command line arguments
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        "host",
        nargs='?',
        help="address of host",
        default=default_server_host,
    )
    parser.add_argument(
        "port",
        nargs='?',
        type=int,
        help="server port",
        default=default_server_port,
    )
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    # extract the server address and port
    host = args.host
    port = args.port
    server_address = (host, port)
    if _debug: _log.debug("    - server_address: %r", server_address)

    # build the stack
    this_console = ConsoleClient()
    if _debug: _log.debug("    - this_console: %r", this_console)

    this_middle_man = MiddleMan()
    if _debug: _log.debug("    - this_middle_man: %r", this_middle_man)

    this_director = TCPClientDirector()
    if _debug: _log.debug("    - this_director: %r", this_director)

    bind(this_console, this_middle_man, this_director)
    bind(MiddleManASE(), this_director)

    # create a task manager for scheduled functions
    task_manager = TaskManager()
    if _debug: _log.debug("    - task_manager: %r", task_manager)

    # don't wait to connect
    this_director.connect(server_address)

    if _debug: _log.debug("running")

    run()
示例#5
0
def main():
    """
    Main function, called when run as an application.
    """
    global args, server_address

    # parse the command line arguments
    parser = ArgumentParser(description=__doc__)
    parser.add_argument(
        "host",
        nargs='?',
        help="address of host (default %r)" % (SERVER_HOST, ),
        default=SERVER_HOST,
    )
    parser.add_argument(
        "port",
        nargs='?',
        type=int,
        help="server port (default %r)" % (SERVER_PORT, ),
        default=SERVER_PORT,
    )
    parser.add_argument(
        "--hello",
        action="store_true",
        default=False,
        help="send a hello message",
    )
    parser.add_argument(
        "--connect-timeout",
        nargs='?',
        type=int,
        help="idle connection timeout",
        default=CONNECT_TIMEOUT,
    )
    parser.add_argument(
        "--idle-timeout",
        nargs='?',
        type=int,
        help="idle connection timeout",
        default=IDLE_TIMEOUT,
    )
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    # extract the server address and port
    host = args.host
    port = args.port
    server_address = (host, port)
    if _debug: _log.debug("    - server_address: %r", server_address)

    # build the stack
    this_console = ConsoleClient()
    if _debug: _log.debug("    - this_console: %r", this_console)

    this_middle_man = MiddleMan()
    if _debug: _log.debug("    - this_middle_man: %r", this_middle_man)

    this_director = TCPClientDirector(
        connect_timeout=args.connect_timeout,
        idle_timeout=args.idle_timeout,
    )
    if _debug: _log.debug("    - this_director: %r", this_director)

    bind(this_console, this_middle_man, this_director)
    bind(MiddleManASE(), this_director)

    # create a task manager for scheduled functions
    task_manager = TaskManager()
    if _debug: _log.debug("    - task_manager: %r", task_manager)

    # don't wait to connect
    deferred(this_director.connect, server_address)

    # send hello maybe
    if args.hello:
        deferred(this_middle_man.indication, PDU(b'Hello, world!\n'))

    if _debug: _log.debug("running")

    run()

    if _debug: _log.debug("fini")
示例#6
0
def main():
    global local_unicast_tuple, local_broadcast_tuple

    # parse the command line arguments
    parser = ArgumentParser(usage=__doc__)
    parser.add_argument(
        "address",
        help="address of socket",
    )
    parser.add_argument(
        "--nobroadcast",
        action="store_true",
        dest="noBroadcast",
        default=False,
        help="do not create a broadcast socket",
    )

    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    if args.address == "any":
        local_unicast_tuple = ('', 47808)
        local_broadcast_tuple = ('255.255.255.255', 47808)

    elif args.address.startswith("any:"):
        port = int(args.address[4:])
        local_unicast_tuple = ('', port)
        local_broadcast_tuple = ('255.255.255.255', port)

    else:
        address = Address(args.address)
        if _debug: _log.debug("    - local_address: %r", address)

        local_unicast_tuple = address.addrTuple
        local_broadcast_tuple = address.addrBroadcastTuple

    if _debug: _log.debug("    - local_unicast_tuple: %r", local_unicast_tuple)
    if _debug:
        _log.debug("    - local_broadcast_tuple: %r", local_broadcast_tuple)

    console = ConsoleClient()
    middle_man = MiddleMan()
    unicast_director = UDPDirector(local_unicast_tuple)
    bind(console, middle_man, unicast_director)

    if args.noBroadcast:
        _log.debug("    - skipping broadcast")

    elif not local_broadcast_tuple:
        _log.debug("    - no local broadcast")

    elif local_unicast_tuple == local_broadcast_tuple:
        _log.debug("    - identical unicast and broadcast tuples")

    elif local_broadcast_tuple[0] == '255.255.255.255':
        _log.debug("    - special broadcast address only for sending")

    else:
        broadcast_receiver = BroadcastReceiver()
        broadcast_director = UDPDirector(local_broadcast_tuple, reuse=True)
        bind(broadcast_receiver, broadcast_director)

    _log.debug("running")

    run()

    _log.debug("fini")
示例#7
0
        default=SERVER,
    )

    # add an option to pick a controller
    parser.add_argument(
        '--controller',
        help="controller name",
        default=CONTROLLER,
    )

    # parse the command line arguments
    args = parser.parse_args()

    if _debug: _log.debug("initialization")
    if _debug: _log.debug("    - args: %r", args)

    # create a proxy for the real server
    testServer = IOProxy(args.controller, args.server)

    console = ConsoleClient()
    middleMan = MiddleMan()
    bind(console, middleMan)

    _log.debug("running")
    run()

except Exception, e:
    _log.exception("an error has occurred: %s", e)
finally:
    _log.debug("finally")