def run_application(self, ip, port): try: server_process = Process(target=self.run, kwargs={'host': ip, 'port': port, 'quiet': True, 'server': 'cherrypy'}) server_process.start() if self.export_svg: try: utils.run_selenium_and_export_svg("http://%s:%d/app/index.html" % (ip, port), self.args.export_svg, browser_path=self.browser_path, run=run) except Exception as e: print(e) finally: server_process.terminate() sys.exit(0) if not self.server_only: utils.open_url_in_browser(url="http://%s:%d" % (ip, port), browser_path=self.browser_path, run=run) run.info_single('The server is now listening the port number "%d". When you are finished, press CTRL+C to terminate the server.' % port, 'green', nl_before = 1, nl_after=1) server_process.join() except KeyboardInterrupt: run.warning('The server is being terminated.', header='Please wait...') server_process.terminate() sys.exit(0)
def run_application(self, ip, port): try: server_process = Process(target=self.run, kwargs={ 'host': ip, 'port': port, 'quiet': True, 'server': 'cherrypy' }) server_process.start() if self.export_svg: try: utils.run_selenium_and_export_svg( "http://%s:%d/app/index.html" % (ip, port), self.args.export_svg, browser_path=self.browser_path, run=run) except Exception as e: print(e) finally: server_process.terminate() sys.exit(0) if not self.server_only: # Sometimes browser opens before web server actually starts so we see # message like "Website can not be reached" and user needs to refresh # I have added sleep below to delay web browser little bit. time.sleep(1.5) utils.open_url_in_browser(url="http://%s:%d" % (ip, port), browser_path=self.browser_path, run=run) run.info_single( 'The server is now listening the port number "%d". When you are finished, press CTRL+C to terminate the server.' % port, 'green', nl_before=1, nl_after=1) server_process.join() except KeyboardInterrupt: run.warning('The server is being terminated.', header='Please wait...') server_process.terminate() sys.exit(0)