def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # add an argument for seconds per dog parser.add_argument( 'seconds', metavar='N', type=int, nargs='+', help='number of seconds for each dog', ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make some dogs for i, sec in enumerate(args.seconds): dog = PrairieDog(i, sec * 1000) if _debug: _log.debug(" - dog: %r", dog) _log.debug("running") run() _log.debug("fini")
def main(): global this_console # build a parser for the command line arguments parser = ArgumentParser(description=__doc__) # sample additional argument to change the prompt parser.add_argument( "--prompt", type=str, default="> ", help="change the prompt", ) # parse the command line arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a console this_console = ConsoleCmdTemplate(prompt=args.prompt) _log.debug("running") run()
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a controller this_controller = SieveClientController() if _debug: _log.debug(" - this_controller: %r", this_controller) # local IO functions bind(this_controller, ModbusClient()) # if this is being run, then a console is handy this_console = ConsoleClient(this_controller) if _debug: _log.debug(" - this_console: %r", this_console) _log.debug("running") run() _log.debug("fini")
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()
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")
def main(): global args # build a parser for the command line arguments parser = ArgumentParser(description=__doc__) # sample additional argument to change the prompt parser.add_argument( "--prompt", type=str, default="> ", help="change the prompt", ) # accept everything else parser.add_argument('args', nargs=argparse.REMAINDER) # parse the command line arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a console this_console = Shell() if _debug: _log.debug(" - this_console: %r", this_console) # enable sleeping will help with threads enable_sleeping() _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) parser.add_argument( "--host", type=str, help="address of host (default {!r})".format(SERVER_HOST), default=SERVER_HOST, ) parser.add_argument( "--port", type=int, help="server port (default {!r})".format(SERVER_PORT), default=SERVER_PORT, ) args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # local IO functions bind(SimpleServer(), ModbusServer(port=args.port)) _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() global this_switch, this_console if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make some debugging terminals debug1 = DebugTerm("a") debug2 = DebugTerm("b") # make a switch with them this_switch = Switch(a=debug1, b=debug2) if _debug: _log.debug(" this_switch: %r", this_switch) # make a test console this_console = TestConsoleCmd() if _debug: _log.debug(" this_console: %r", this_console) # bind the console to the top and bottom of the switch bind(this_console, this_switch, this_console) # enable sleeping will help with threads enable_sleeping() _log.debug("running") run() _log.debug("fini")
def main(): global args # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a controller for to_do_item requests controller = SomethingController() if _debug: _log.debug(" - controller: %r", controller) for i in range(3): # make a list bound to the contoller to_do_list = ToDoList(controller, active_limit=2) if _debug: _log.debug(" - to_do_list: %r", to_do_list) for j in range(5): to_do_list.append(SomethingToDo(i, j)) _log.debug("running") run() _log.debug("fini")
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")
def main() -> None: mqtt_port = os.environ.get("MQTT_PORT", 1883) mqtt_addr = os.environ.get("MQTT_ADDR", "127.0.0.1") ArgumentParser().parse_args() _log.info("Starting bacprop") BacPropagator().start()
def main(): global args, this_device, this_application # build a parser, add some options parser = ArgumentParser(description=__doc__) parser.add_argument( '--lan', type=str, default=default_lan_name, help='lan name', ) parser.add_argument( '--host', type=str, default=default_broker_host, help='broker host address', ) parser.add_argument( '--port', type=int, default=default_broker_port, help='broker port', ) parser.add_argument( '--keepalive', type=int, default=default_broker_keepalive, help= "maximum period in seconds allowed between communications with the broker", ) # parse the command line arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make a simple application this_application = MQTTSniffer(args.lan, args.host, args.port, args.keepalive) # enable sleeping will help with threads enable_sleeping() # start up the client this_application.startup() _log.debug("running") run() # shutdown the client this_application.shutdown() _log.debug("fini")
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # add an argument for interval parser.add_argument( 'localaddr', type=str, help='local address of the BBMD', ) # add an argument for interval parser.add_argument( 'bdtentry', type=str, nargs='*', help='list of addresses of peers', ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) local_address = Address(args.localaddr) if _debug: _log.debug(" - local_address: %r", local_address) # create a null client that will accept, but do nothing with upstream # packets from the BBMD null_client = NullClient() if _debug: _log.debug(" - null_client: %r", null_client) # create a BBMD, bound to the Annex J server on a UDP multiplexer bbmd = BIPBBMD(local_address) annexj = AnnexJCodec() multiplexer = UDPMultiplexer(local_address) # bind the layers together bind(null_client, bbmd, annexj, multiplexer.annexJ) # loop through the rest of the addresses for bdtentry in args.bdtentry: if _debug: _log.debug(" - bdtentry: %r", bdtentry) bdt_address = Address(bdtentry) bbmd.add_peer(bdt_address) if _debug: _log.debug(" - bbmd: %r", bbmd) _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # create a controller some_controller = SomeController() if _debug: _log.debug(" - some_controller: %r", some_controller) # test set tests = [ (( 1, 2, ), { 'a': 3 }), (( 4, 5, ), {}), ((6, ), { 'a': 7 }), ] for test_args, test_kwargs in tests: print("test_args, test_kwargs: %r, %r" % (test_args, test_kwargs)) # create a request with some args and kwargs iocb = IOCB(*test_args, **test_kwargs) # add a callback function , called when the request has been processed iocb.add_callback(call_me) # give the request to the controller some_controller.request_io(iocb) # wait for the request to be processed iocb.ioComplete.wait() if _debug: _log.debug(" - iocb: %r", iocb) # dump the contents print("iocb completion event set: %r" % (iocb.ioComplete.is_set(), )) print("") print("iocb successful: %r" % (iocb.ioState == COMPLETED, )) print("iocb response: %r" % (iocb.ioResponse, )) print("") print("iocb aborted: %r" % (iocb.ioState == ABORTED, )) print("iocb error: %r" % (iocb.ioError, )) print("")
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()
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # add an argument for interval parser.add_argument( 'addr1', type=str, help='address of first network', ) # add an argument for interval parser.add_argument( 'net1', type=int, help='network number of first network', ) # add an argument for interval parser.add_argument( 'addr2', type=str, help='address of second network', ) # add an argument for interval parser.add_argument( 'net2', type=int, help='network number of second network', ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # create the router router = IP2IPRouter(Address(args.addr1), args.net1, Address(args.addr2), args.net2) if _debug: _log.debug(" - router: %r", router) # send network topology deferred(router.nse.i_am_router_to_network) _log.debug("running") run() _log.debug("fini")
def main(): # 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="listening address of server or 'any' (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 if host == "any": host = '' server_address = (host, args.port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address) if _debug: _log.debug(" - this_director: %r", this_director) # create an echo echo_master = EchoMaster() if _debug: _log.debug(" - echo_master: %r", echo_master) # bind everything together bind(echo_master, this_director) bind(MiddleManASE(), this_director) _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # add an argument for local address parser.add_argument('addr1', type=str, help='address of first network', ) # add an argument for local port parser.add_argument('port1', type=int, help='port number of local network', ) # add an argument for interval parser.add_argument('net1', type=int, help='network number of local network', ) # add an argument for interval parser.add_argument('addr2', type=str, help='address of global network (outside NAT)', ) # add an argument for local port parser.add_argument('port2', type=int, help='port number of global forwarded port', ) # add an argument for interval parser.add_argument('net2', type=int, help='network number of global network', ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # create the router router = NATRouter(args.addr1, args.port1, args.net1, args.addr2, args.port2, args.net2) if _debug: _log.debug(" - router: %r", router) _log.debug("running") run() _log.debug("fini")
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) _log.debug("running") run() _log.debug("fini")
def main(): if _debug: main._debug("main") # parse the command line arguments args = ArgumentParser(description=__doc__).parse_args() if _debug: main._debug(" - args: %r", args) # suck in the test content text = sys.stdin.read() # parse it tag_list = ExtendedTagList(text) # dump it back out for tag in tag_list: tag.debug_contents()
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make the thread object and start it bacpypes_thread = BACpypesThread() bacpypes_thread.start() # main thread while True: write_flush("#") time.sleep(2)
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) parser.add_argument( "--host", nargs='?', help="listening address of server", 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 if host == "any": host = '' port = args.port server_address = (host, port) if _debug: _log.debug(" - server_address: %r", server_address) # create a director listening to the address this_director = TCPServerDirector(server_address) if _debug: _log.debug(" - this_director: %r", this_director) # create an echo echo_master = EchoMaster() if _debug: _log.debug(" - echo_master: %r", echo_master) # bind everything together bind(echo_master, this_director) bind(MiddleManASE(), this_director) _log.debug("running") run()
def main(): # parse the command line arguments parser = ArgumentParser(description=__doc__) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # make the thread object and start it process_thread = ProcessThread() process_thread.start() _log.debug("running") run() _log.debug("fini")
def setUp(argv=None): global test_options # create an argument parser parser = ArgumentParser(description=__doc__) # add an option parser.add_argument( '--option', help="this is an option", default=os.getenv("BACPYPES_TEST_OPTION") or BACPYPES_TEST_OPTION, ) # get the debugging args and parse them arg_str = os.getenv("BACPYPES_TEST") or BACPYPES_TEST test_options = parser.parse_args(argv or arg_str.split()) if _debug: setUp._debug("setUp") if _debug: setUp._debug(" - test_options: %r", test_options)
def setup_package(): global test_options # create an argument parser parser = ArgumentParser(description=__doc__) # add an option parser.add_argument( '--option', help="this is an option", default=os.getenv("BACPYPES_TEST_OPTION") or BACPYPES_TEST_OPTION, ) # get the debugging args and parse them arg_str = os.getenv("BACPYPES_TEST") or BACPYPES_TEST test_options = parser.parse_args(arg_str.split()) if _debug: setup_package._debug("setup_package") if _debug: setup_package._debug(" - test_options: %r", test_options) time_machine = TimeMachine() if _debug: setup_package._debug(" - time_machine: %r", time_machine)
self.annexj = AnnexJCodec() self.mux = UDPMultiplexer(local_address) # bind the bottom layers bind(self.bip, self.annexj, self.mux.annexJ) # bind the BIP stack to the local network self.nsap.bind(self.bip, local_network, local_address) # # __main__ # # parse the command line arguments parser = ArgumentParser(description=__doc__) # add an argument for interval parser.add_argument( 'addr1', type=str, help='address of first network', ) # add an argument for interval parser.add_argument( 'net1', type=int, help='network number of first network', )
def main(): # parse the command line arguments parser = ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) # add an argument for interval parser.add_argument( 'addr1', type=str, help='address of first network', ) # add an argument for interval parser.add_argument( 'net1', type=int, help='network number of first network', ) # add an argument for interval parser.add_argument( 'addr2', type=str, help='address of second network', ) # add an argument for interval parser.add_argument( 'net2', type=int, help='network number of second network', ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) local_address = Address(args.addr1) local_network = args.net1 vlan_address = Address(args.addr2) vlan_network = args.net2 # create the VLAN router, bind it to the local network router = VLANRouter(local_address, local_network) # create a VLAN vlan = Network(broadcast_address=LocalBroadcast()) # create a node for the router, address 1 on the VLAN router_node = Node(Address(1)) vlan.add_node(router_node) # bind the router stack to the vlan network through this node router.nsap.bind(router_node, vlan_network) # send network topology deferred(router.nse.i_am_router_to_network) # device identifier is assigned from the address device_instance = vlan_network * 100 + int(args.addr2) _log.debug(" - device_instance: %r", device_instance) # make a vlan device object vlan_device = \ LocalDeviceObject( objectName="VLAN Node %d" % (device_instance,), objectIdentifier=('device', device_instance), maxApduLengthAccepted=1024, segmentationSupported='noSegmentation', vendorIdentifier=15, ) _log.debug(" - vlan_device: %r", vlan_device) # make the application, add it to the network vlan_app = VLANApplication(vlan_device, vlan_address) vlan.add_node(vlan_app.vlan_node) _log.debug(" - vlan_app: %r", vlan_app) # make a random value object ravo = RandomAnalogValueObject( objectIdentifier=('analogValue', 1), objectName='Device%d/Random1' % (device_instance, ), ) _log.debug(" - ravo1: %r", ravo) # add it to the device vlan_app.add_object(ravo) _log.debug("running") run() _log.debug("fini")
def main(): global args # parse the command line arguments parser = ArgumentParser(description=__doc__) # arguments for first network parser.add_argument( 'lan', type=str, help='MQTT network name', ) parser.add_argument( 'addr1', type=str, help='address of first network', ) parser.add_argument( 'net1', type=int, help='network number of first network', ) # arguments for B/IP network parser.add_argument( 'addr2', type=str, help='address of second network', ) parser.add_argument( 'net2', type=int, help='network number of second network', ) # additional options for the MQTT client parser.add_argument( '--host', type=str, default=bacpypes_mqtt.default_broker_host, help='broker host address', ) parser.add_argument( '--port', type=int, default=bacpypes_mqtt.default_broker_port, help='broker port', ) parser.add_argument( '--keepalive', type=int, default=bacpypes_mqtt.default_broker_keepalive, help= "maximum period in seconds allowed between communications with the broker", ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) # create the router router = MQTT2IPRouter(args.lan, Address(args.addr1), args.net1, Address(args.addr2), args.net2) if _debug: _log.debug(" - router: %r", router) # start up the client router.s1_mse.startup() _log.debug("running") run() # shutdown the client router.s1_mse.shutdown() _log.debug("fini")
def main(): global args, this_application # parse the command line arguments parser = ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter, ) # add an argument for interval parser.add_argument( "addr1", type=str, help="address of first network", ) # add an argument for interval parser.add_argument( "net1", type=int, help="network number of first network", ) # add an argument for interval parser.add_argument( "net2", type=int, help="network number of second network", ) # add an argument for how many virtual devices parser.add_argument( "--count", type=int, help="number of virtual devices", default=1, ) # add an argument for how many virtual devices parser.add_argument( "--rpm", help="enable read property multiple", action="store_true", ) # add an argument for including the property list parser.add_argument( "--plist", help="enable property list property", action="store_true", ) # now parse the arguments args = parser.parse_args() if _debug: _log.debug("initialization") if _debug: _log.debug(" - args: %r", args) local_address = Address(args.addr1) local_network = args.net1 vlan_network = args.net2 # create the VLAN router, bind it to the local network router = VLANRouter(local_address, local_network) # create a VLAN vlan = Network(broadcast_address=LocalBroadcast()) # create a node for the router, address 1 on the VLAN router_addr = Address(1) router_node = Node(router_addr) vlan.add_node(router_node) # bind the router stack to the vlan network through this node router.nsap.bind(router_node, vlan_network, router_addr) # send network topology deferred(router.nse.i_am_router_to_network) # add the dynamic property list if args.plist: RandomAnalogValueObject.properties.append(CurrentPropertyList()) # register it now that all its properties are defined register_object_type(RandomAnalogValueObject, vendor_id=999) # console is the first device device_number = 2 device_instance = vlan_network * 100 + device_number _log.debug(" - console device_instance: %r", device_instance) # make a vlan device object vlan_device = LocalDeviceObject( objectName="VLAN Console Node %d" % (device_instance, ), objectIdentifier=("device", device_instance), maxApduLengthAccepted=1024, segmentationSupported="noSegmentation", vendorIdentifier=15, ) _log.debug(" - vlan_device: %r", vlan_device) vlan_address = Address(device_number) _log.debug(" - vlan_address: %r", vlan_address) # make the console application, add it to the network this_application = VLANConsoleApplication(vlan_device, vlan_address) vlan.add_node(this_application.vlan_node) _log.debug(" - this_application: %r", this_application) # make a console this_console = VLANConsoleCmd() if _debug: _log.debug(" - this_console: %r", this_console) # make a random value object ravo = RandomAnalogValueObject( objectIdentifier=("analogValue", 1), objectName="Random-1-%d" % (device_instance, ), ) _log.debug(" - ravo: %r", ravo) # add it to the device this_application.add_object(ravo) # make some more devices for device_number in range(3, 3 + args.count - 1): # device identifier is assigned from the address device_instance = vlan_network * 100 + device_number _log.debug(" - device_instance: %r", device_instance) # make a vlan device object vlan_device = LocalDeviceObject( objectName="VLAN Node %d" % (device_instance, ), objectIdentifier=("device", device_instance), maxApduLengthAccepted=1024, segmentationSupported="noSegmentation", vendorIdentifier=15, ) _log.debug(" - vlan_device: %r", vlan_device) vlan_address = Address(device_number) _log.debug(" - vlan_address: %r", vlan_address) # make the application, add it to the network vlan_app = VLANApplication(vlan_device, vlan_address) vlan.add_node(vlan_app.vlan_node) _log.debug(" - vlan_app: %r", vlan_app) # make a random value object ravo = RandomAnalogValueObject( objectIdentifier=("analogValue", 1), objectName="Random-1-%d" % (device_instance, ), ) _log.debug(" - ravo: %r", ravo) # add it to the device vlan_app.add_object(ravo) # enable sleeping will help with threads enable_sleeping() _log.debug("running") run() _log.debug("fini")
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")