Skip to content

Commit

Permalink
Add basic qusb2snes error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
krelbel committed May 17, 2021
1 parent bf12bb6 commit 63eac00
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"
Expand All @@ -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",
Expand Down

0 comments on commit 63eac00

Please sign in to comment.