]> kaliko git repositories - mpd-sima.git/blobdiff - sima/core.py
Clean some linter warnings and errors
[mpd-sima.git] / sima / core.py
index 7f3631cfb610c03346218c032da5d95e9ce143ad..4b7307ea72796cc57fee1ba0d9208ccb37cf6830 100644 (file)
@@ -37,7 +37,7 @@ class Sima(Daemon):
     """
 
     def __init__(self, conf):
-        ## Set daemon
+        # Set daemon
         Daemon.__init__(self, conf.get('daemon', 'pidfile'))
         self.enabled = True
         self.config = conf
@@ -80,7 +80,8 @@ class Sima(Daemon):
 
     @property
     def plugins(self):
-        return [plugin[1] for plugin in sorted(self._plugins, key=lambda pl: pl[0], reverse=True)]
+        return [plugin[1] for plugin in
+                sorted(self._plugins, key=lambda pl: pl[0], reverse=True)]
 
     def need_tracks(self):
         """Is the player in need for tracks"""
@@ -126,7 +127,7 @@ class Sima(Daemon):
                 self.log.debug(err)
                 continue
             except PlayerError as err:
-                #TODO: unhandled Player exceptions
+                # TODO: unhandled Player exceptions
                 self.log.warning('Unhandled player exception: %s', err)
             self.log.info('Got reconnected')
             break
@@ -145,10 +146,12 @@ class Sima(Daemon):
         """
         self.log.warning('Starting shutdown.')
         # Cleaning pending command
-        self.player.clean()
-        self.foreach_plugin('shutdown')
-        self.player.disconnect()
-
+        try:
+            self.player.clean()
+            self.foreach_plugin('shutdown')
+            self.player.disconnect()
+        except PlayerError as err:
+            self.log.error('Player error during shutdown: %s', err)
         self.log.info('The way is shut, it was made by those who are dead. '
                       'And the dead keep it…')
         self.log.info('bye...')
@@ -175,7 +178,7 @@ class Sima(Daemon):
         """Dispatching callbacks to plugins
         """
         # hanging here until a monitored event is raised in the player
-        if getattr(self, 'changed', False): # first iteration exception
+        if getattr(self, 'changed', False):  # first iteration exception
             self.changed = self.player.monitor()
         else:  # first iteration goes through else
             self.changed = ['playlist', 'player', 'skipped']