From 5d4c7224d9c5e1ec0978b45e3636f77c2979619d Mon Sep 17 00:00:00 2001 From: Matthew Stratford Date: Sat, 12 Mar 2022 17:08:29 +0000 Subject: [PATCH] Pep8 lint --- controllers/mattchbox_usb.py | 2 +- launch.py | 1 + player.py | 23 +++++++++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/controllers/mattchbox_usb.py b/controllers/mattchbox_usb.py index ec236e7..0105bdc 100644 --- a/controllers/mattchbox_usb.py +++ b/controllers/mattchbox_usb.py @@ -70,7 +70,7 @@ class MattchBox(Controller): self.ser = serial.serial_for_url(port, do_not_open=True) if self.ser: self.ser.baudrate = 2400 - self.ser.timeout = 0.1 # Speed up waiting for a byte. + self.ser.timeout = 0.1 # Speed up waiting for a byte. try: self.ser.open() self.logger.log.info("Connected to serial port {}".format(port)) diff --git a/launch.py b/launch.py index 7816d7b..712bb6a 100755 --- a/launch.py +++ b/launch.py @@ -49,6 +49,7 @@ def startServer(notifications=False): def printer(msg: Any): print("LAUNCHER:{}".format(msg)) + def notif(msg: str): print("NOTIFICATION:{}".format(msg)) diff --git a/player.py b/player.py index 396fd55..4d0daa7 100644 --- a/player.py +++ b/player.py @@ -132,7 +132,9 @@ class Player: if not self.state.get()["loaded_item"] or not self.isInit: loaded = False elif not self.isPlaying: - # Because this function can be called very often, only some (less frequent) checks will initiate a full trial of loading success, for efficiency. + # Because this function can be called very often, only some (less + # frequent) checks will initiate a full trial of loading success, for + # efficiency. if not short_test: # We're not playing now, so we can quickly test run # If that works, we're truely loaded. @@ -184,9 +186,9 @@ class Player: # Audio Playout Related Methods - # Loads a plan item into the player, ready for playing. # This includes some retry logic to try and double-down on ensuring it plays successfully. + def load(self, weight: int): if not self.isPlaying: # If we have something loaded already, unload it first. @@ -350,7 +352,7 @@ class Player: self.logger.log.exception("Failed to unload channel.") return False - #self._potentially_end_tracklist() + # self._potentially_end_tracklist() # If we unloaded successfully, reset the tracklist_id, ready for the next item. if not self.isLoaded: self.state.update("tracklist_id", None) @@ -358,8 +360,8 @@ class Player: # If we successfully unloaded, this will return true, for success! return not self.isLoaded - # Starts playing the loaded item, from a given position (secs) + def play(self, pos: float = 0): self.logger.log.info("Playing from pos: " + str(pos)) if not self.isLoaded: @@ -513,9 +515,9 @@ class Player: except Exception: self.logger.log.exception("Failed to quit mixer.") - # Sets whether auto advance is on or off # Auto advance is where the next item in the list is selected after the current item is finished playing. + def set_auto_advance(self, message: bool) -> bool: self.state.update("auto_advance", message) return True @@ -534,7 +536,6 @@ class Player: self.state.update("play_on_load", message) return True - # Show Plan Related Methods def _check_ghosts(self, item: PlanItem): @@ -775,7 +776,8 @@ class Player: # If we're going to live (potentially from not live/PFL), potentially tracklist if it's playing. if live: self._potentially_tracklist() - # If the fader is now not live, don't bother stopping the tracklist, incase it's faded up again during the same playback. + # If the fader is now not live, don't bother stopping the tracklist, + # incase it's faded up again during the same playback. return True # Helper functions @@ -786,9 +788,9 @@ class Player: time: int = -1 if mode == "on": - time = 0 # Let's do it pretty quickly. + time = 0 # Let's do it pretty quickly. if mode == "fader-live": - time = 4 # Give presenter a bit of a grace period in case they accidentally fade up the wrong one. + time = 4 # Give presenter a bit of a grace period in case they accidentally fade up the wrong one. elif mode == "delayed": # Let's do it in a bit, once we're sure it's been playing. (Useful if we've got no idea if it's live or cueing.) time = TRACKLISTING_DELAYED_S @@ -1049,7 +1051,8 @@ class Player: "Message return Queue is missing!!!! Can't send message." ) - # Send the current status to all other modules/clients. Used for updating all client UIs when one of them causes a change etc. + # Send the current status to all other modules/clients. Used for updating + # all client UIs when one of them causes a change etc. def _send_status(self): self._retMsg(str(self.status), okay_str=True, custom_prefix="ALL:STATUS:")