From 7138f070a09ce2a1204163540e3b5d1cf82e173c Mon Sep 17 00:00:00 2001 From: unga Date: Thu, 6 Apr 2017 15:17:45 +0200 Subject: [PATCH] feat: make monitor server standalone --- qcodes/monitor/monitor.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qcodes/monitor/monitor.py b/qcodes/monitor/monitor.py index 0eb3a66302a..9808083a0c6 100644 --- a/qcodes/monitor/monitor.py +++ b/qcodes/monitor/monitor.py @@ -111,7 +111,6 @@ def run(self): self.loop = asyncio.new_event_loop() asyncio.set_event_loop(self.loop) Monitor.running = self - self.show() self.loop.run_forever() def stop(self): @@ -196,7 +195,7 @@ def __init__(self, port=3000): def run(self): os.chdir(self.static_dir) log.debug("serving directory %s", self.static_dir) - log.debug("serving at port", self.port) + log.info("Open broswer at http://localhost::{}".format(self.port)) self.httpd.serve_forever() def stop(self): @@ -205,5 +204,10 @@ def stop(self): if __name__ == "__main__": - server = Server() - server.run() + server = Server(SERVER_PORT) + print("Open broswer at http://localhost:{}".format(server.port)) + try: + webbrowser.open("http://localhost:{}".format(server.port)) + server.run() + except KeyboardInterrupt: + exit()