def gui(args): """ Loads recipy GUI from the command-line """ from recipyGui import recipyGui import threading import webbrowser import socket def get_free_port(): port = None base_port = config.get_gui_port() for trial_port in range(base_port, base_port + 5): try: s = socket.socket() s.bind(('', trial_port)) s.close() port = trial_port break except Exception: # port already bound # Please note that this also happens when the gui is run in # debug mode! pass if not port: # no free ports above, fall back to random s = socket.socket() s.bind(('', 0)) port = s.getsockname()[1] s.close() return port port = get_free_port() url = "http://127.0.0.1:{0}".format(port) if not args['--no-browser']: # Give the application some time before it starts threading.Timer(1.25, lambda: webbrowser.open(url)).start() # Turn off reloading by setting debug = False (this also fixes starting the # application twice) recipyGui.run(debug=args['--debug'], port=port)
def gui(args): from recipyGui import recipyGui import threading, webbrowser, socket def get_free_port(): s = socket.socket() s.bind(('', 0)) port = s.getsockname()[1] s.close() return port port = get_free_port() url = "http://127.0.0.1:{0}".format(port) # Give the application some time before it starts threading.Timer(1.25, lambda: webbrowser.open(url) ).start() # Turn off reloading by setting debug = False (this also fixes starting the # application twice) recipyGui.run(debug = args['--debug'], port=port)
#!/usr/bin/env python from recipyGui import recipyGui import threading, webbrowser, socket def get_free_port(): s = socket.socket() s.bind(('', 0)) port = s.getsockname()[1] s.close() return port port = get_free_port() url = "http://127.0.0.1:{0}".format(port) # Give the application some time before it starts threading.Timer(1.25, lambda: webbrowser.open(url)).start() # Turn off reloading by setting debug = False (this also fixes starting the # application twice) recipyGui.run(debug=False, port=port)