Commits

Matthew Turk committed 26ef421

Fixing up some rocket issues and adding optional ports and browser-openings

  • Participants
  • Parent commits e5c0f84

Comments (0)

Files changed (2)

File yt/gui/reason/bottle_mods.py

         #print "With this response:", rv
         return rv
 
-def uuid_serve_functions(pre_routed = None, open_browser=False):
+def uuid_serve_functions(pre_routed = None, open_browser=False, port=9099):
     if pre_routed == None: pre_routed = route_functions
     debug(mode=True)
     token = uuid.uuid1()
     print
     print "Please direct your browser to:"
     print
-    print "     http://localhost:8080/%s/" % token
+    print "     http://localhost:%s/%s/" % (port, token)
     print
     print
     if open_browser:
             """Start a browser after waiting for half a second."""
             import webbrowser, threading
             def _local_browse():
-                webbrowser.open('http://localhost:%s/%s/' % (8080, token))
+                webbrowser.open('http://localhost:%s/%s/' % (port, token))
             thread = threading.Timer(0.5, _local_browse)
             thread.start()
         local_browse()
         server_name = "rocket"
         log = logging.getLogger('Rocket')
         log.setLevel(logging.INFO)
-        kwargs = {'timeout': 600}
+        kwargs = {'timeout': 600, 'max_threads': 1}
     except ImportError:
         server_name = "wsgiref"
     server_type = server_names.get(server_name)
-    server = server_type(host='localhost', port=8080, **kwargs)
+    server = server_type(host='localhost', port=port, **kwargs)
     #repl.locals['server'] = server
     mylog.info("Starting up the server.")
     run(server=server)

File yt/utilities/command_line.py

         print
         print "Good luck!"
 
+    @cmdln.option("-o", "--open-browser", action="store_true",
+                  default = False, dest='open_browser',
+                  help="Open a web browser.")
+    @cmdln.option("-p", "--port", action="store",
+                  default = 9099, dest='port',
+                  help="Port to listen on")
     def do_serve(self, subcmd, opts):
         """
         Run the Web GUI
 
         hr = ExtDirectREPL(base_extjs_path)
         bottle.debug()
-        uuid_serve_functions(open_browser=True)
+        uuid_serve_functions(open_browser=opts.open_browser,
+                    port=int(opts.port))
 
 def run_main():
     for co in ["--parallel", "--paste"]: