open webui only after asking for repatching in text console, as it can otherwise be easily missed.

This commit is contained in:
Fabian Dill 2020-08-11 21:59:43 +02:00
parent c163134062
commit d92c461ad3
1 changed files with 12 additions and 11 deletions

View File

@ -1305,17 +1305,6 @@ async def main():
parser.add_argument('--disable_web_ui', default=False, action='store_true', help="Turn off emitting a webserver for the webbrowser based user interface.") parser.add_argument('--disable_web_ui', default=False, action='store_true', help="Turn off emitting a webserver for the webbrowser based user interface.")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(format='%(message)s', level=getattr(logging, args.loglevel.upper(), logging.INFO)) logging.basicConfig(format='%(message)s', level=getattr(logging, args.loglevel.upper(), logging.INFO))
port = None
if not args.disable_web_ui:
# Find an available port on the host system to use for hosting the websocket server
while True:
port = randrange(49152, 65535)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
if not sock.connect_ex(('localhost', port)) == 0:
break
import threading
WebUI.start_server(
port, on_start=threading.Timer(1, webbrowser.open, (f'http://localhost:5050?port={port}',)).start)
if args.diff_file: if args.diff_file:
import Patch import Patch
@ -1332,6 +1321,18 @@ async def main():
logging.exception(e) logging.exception(e)
asyncio.create_task(run_game(adjustedromfile if adjusted else romfile)) asyncio.create_task(run_game(adjustedromfile if adjusted else romfile))
port = None
if not args.disable_web_ui:
# Find an available port on the host system to use for hosting the websocket server
while True:
port = randrange(49152, 65535)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
if not sock.connect_ex(('localhost', port)) == 0:
break
import threading
WebUI.start_server(
port, on_start=threading.Timer(1, webbrowser.open, (f'http://localhost:5050?port={port}',)).start)
ctx = Context(args.snes, args.connect, args.password, args.founditems, port) ctx = Context(args.snes, args.connect, args.password, args.founditems, port)
input_task = create_named_task(console_loop(ctx), name="Input") input_task = create_named_task(console_loop(ctx), name="Input")
if not args.disable_web_ui: if not args.disable_web_ui: