def start_server(host, port, hide_browser): """ Initialize the blossom webserver and open the web client. Args: host: the hostname of the server socket port: the port of the server socket hide_browser: does not open the web client if set to true """ global yarn_process print(" ") import prettytable as pt sentence = "%s:%d" % (host, port) width = 26 t = pt.PrettyTable() t.field_names = ['IP ADDRESS'] [ t.add_row([sentence[i:i + width]]) for i in range(0, len(sentence), width) ] print(t) # start_yarn() if not hide_browser: addr = "%s:%d" % (host, port) webbrowser.open("http:" + addr, new=2) print("\nExample command: s -> *enter* -> yes -> *enter*") server.set_funcs(robots[0], robots, handle_input, record, stop_record, store_gesture) server.start_server(host, port)
def test_server(self): host = "0.0.0.0" port = 5489 socket_timeout = 60 def timeout_server(): # need a more robust mechanism for when to cancel the future time.sleep(2) self.stop_server_future.cancel() thread = threading.Thread(target=timeout_server) thread.daemon = True thread.start() with self.assertRaises(CancelledError): start_server(host=host, port=port, loop=self.loop, socket_timeout=socket_timeout, stop_server_future=self.stop_server_future)
def start_server(host, port, hide_browser): """ Initialize the blossom webserver and open the web client. Args: host: the hostname of the server socket port: the port of the server socket hide_browser: does not open the web client if set to true """ global yarn_process print("Starting server on %s:%d" % (host, port)) start_yarn() if not hide_browser: addr = "%s:%d" % (host, port) webbrowser.open("http://%s" % addr, new=2) print("\nExample command: s -> *enter* -> yes -> *enter*") print(prompt) server.set_funcs(master_robot, robots, handle_input, record, stop_record, store_gesture) server.start_server(host, port)
def eva(): """ Start the eva system """ # Get the hostname and port information from the configuration file config = ConfigurationManager() hostname = config.get_value('server', 'host') port = config.get_value('server', 'port') socket_timeout = config.get_value('server', 'socket_timeout') loop = asyncio.new_event_loop() stop_server_future = loop.create_future() # Launch server try: asyncio.run( start_server(host=hostname, port=port, loop=loop, socket_timeout=socket_timeout, stop_server_future=stop_server_future)) except Exception as e: LoggingManager().log(e, LoggingLevel.CRITICAL)