More fixes

This commit is contained in:
Matthew Stratford 2021-04-08 22:05:47 +01:00
parent f4dc7199a4
commit 833dbbf043
4 changed files with 17 additions and 17 deletions

View file

@ -28,7 +28,7 @@ def resolve_local_file_path(relative_path: str):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path: str = sys._MEIPASS
except Exception:
except Exception :
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)

View file

@ -81,7 +81,7 @@ class Player:
def isInit(self):
try:
mixer.music.get_busy()
except Exception:
except Exception :
return False
return True
@ -110,10 +110,10 @@ class Player:
position: float = self.state.state["pos"]
mixer.music.set_volume(0)
mixer.music.play(0)
except Exception:
except Exception :
try:
mixer.music.set_volume(1)
except Exception:
except Exception :
self.logger.log.exception(
"Failed to reset volume after attempting loaded test."
)
@ -148,7 +148,7 @@ class Player:
try:
mixer.music.play(0, pos)
self.state.update("pos_offset", pos)
except Exception:
except Exception :
self.logger.log.exception("Failed to play at pos: " + str(pos))
return False
self.state.update("paused", False)
@ -159,7 +159,7 @@ class Player:
def pause(self):
try:
mixer.music.pause()
except Exception:
except Exception :
self.logger.log.exception("Failed to pause.")
return False
@ -172,7 +172,7 @@ class Player:
position: float = self.state.state["pos_true"]
try:
self.play(position)
except Exception:
except Exception :
self.logger.log.exception(
"Failed to unpause from pos: " + str(position)
)
@ -186,7 +186,7 @@ class Player:
# if self.isPlaying or self.isPaused:
try:
mixer.music.stop()
except Exception:
except Exception :
self.logger.log.exception("Failed to stop playing.")
return False
self.state.update("pos", 0)
@ -203,7 +203,7 @@ class Player:
if self.isPlaying:
try:
self.play(pos)
except Exception:
except Exception :
self.logger.log.exception("Failed to seek to pos: " + str(pos))
return False
return True
@ -330,7 +330,7 @@ class Player:
self.logger.log.info("Loading file: " +
str(loaded_item.filename))
mixer.music.load(loaded_item.filename)
except Exception:
except Exception :
# We couldn't load that file.
self.logger.log.exception(
"Couldn't load file: " + str(loaded_item.filename)
@ -346,7 +346,7 @@ class Player:
"length", mixer.Sound(
loaded_item.filename).get_length() / 1000
)
except Exception:
except Exception :
self.logger.log.exception(
"Failed to update the length of item.")
return False
@ -362,7 +362,7 @@ class Player:
mixer.music.unload()
self.state.update("paused", False)
self.state.update("loaded_item", None)
except Exception:
except Exception :
self.logger.log.exception("Failed to unload channel.")
return False
return not self.isLoaded
@ -372,7 +372,7 @@ class Player:
mixer.quit()
self.state.update("paused", False)
self.logger.log.info("Quit mixer.")
except Exception:
except Exception :
self.logger.log.exception("Failed to quit mixer.")
def output(self, name: Optional[str] = None):
@ -387,7 +387,7 @@ class Player:
mixer.init(44100, -16, 2, 1024, devicename=name)
else:
mixer.init(44100, -16, 2, 1024)
except Exception:
except Exception :
self.logger.log.exception(
"Failed to init mixer with device name: " + str(name)
)
@ -683,7 +683,7 @@ class Player:
self.logger.log.info("Received SystemExit")
except Exception as e:
self.logger.log.exception(
"Received unexpected exception: {}".format(e))
"Received unexpected Exception: {}".format(e))
self.logger.log.info("Quiting player " + str(channel))
self.quit()

View file

@ -31,7 +31,7 @@ class PlayerHandler:
ui_to_q[channel].put(message)
if source in ["ALL", "CONTROLLER"]:
controller_to_q[channel].put(message)
except Exception:
except Exception :
pass
sleep(0.02)

View file

@ -39,7 +39,7 @@ class WebsocketServer:
try:
asyncio.get_event_loop().run_forever()
except Exception:
except Exception :
# Sever died somehow, just quit out.
self.quit()