From 63eac00e0ca7b59e4c5d06e48254c591ab5a091d Mon Sep 17 00:00:00 2001 From: krelbel Date: Mon, 17 May 2021 01:55:21 -0700 Subject: [PATCH] Add basic qusb2snes error handling --- Main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Main.py b/Main.py index c3aa6b5..352ed83 100644 --- a/Main.py +++ b/Main.py @@ -16,7 +16,7 @@ import pickle from tempfile import TemporaryDirectory -__version__ = '0.8' +__version__ = '0.8.1' # Creates a shuffled MSU-1 pack for ALttP Randomizer from one or more source # MSU-1 packs. @@ -530,7 +530,12 @@ def print_pack(path): async def query(prevtrack): addr = "ws://localhost:8080" - ws = await websockets.connect(addr, ping_timeout=None, ping_interval=None) + try: + ws = await websockets.connect(addr, ping_timeout=None, ping_interval=None) + except Exception as e: + print("Failed to connect to qusb2snes") + return 0 + devlist = { "Opcode": "DeviceList", "Space": "SNES" @@ -539,7 +544,10 @@ async def query(prevtrack): reply = json.loads(await ws.recv()) devices = reply['Results'] if 'Results' in reply and len(reply['Results']) > 0 else None if not devices: - print("Failed to connect to qusb2snes") + print("Failed to connect to SNES through qusb2snes") + await ws.close() + return 0 + device = devices[0] attachreq = { "Opcode": "Attach",