X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fcore.py;h=4b7307ea72796cc57fee1ba0d9208ccb37cf6830;hb=37dd60538984a3917354b794a5c96b0a025f8e95;hp=7f3631cfb610c03346218c032da5d95e9ce143ad;hpb=a978d2975c3201dbac0c9e43a08337a800438d2f;p=mpd-sima.git diff --git a/sima/core.py b/sima/core.py index 7f3631c..4b7307e 100644 --- a/sima/core.py +++ b/sima/core.py @@ -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']