X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fcore.py;h=7a17c5f8844923c3c590648afe4c344954ce5bcd;hb=4f1b17d6b72946b60f79b8c3f5fa5557710b9aac;hp=634db4b1cc06c83e651e99f88a9c0c23fd949afa;hpb=92860d5ab0d6008fad149eea960de91acd15719a;p=mpd-sima.git diff --git a/sima/core.py b/sima/core.py index 634db4b..7a17c5f 100644 --- a/sima/core.py +++ b/sima/core.py @@ -46,6 +46,7 @@ class Sima(Daemon): self.plugins = list() self.player = self.__get_player() # Player client try: + self.log.info('Connecting MPD: {0}:{1}'.format(*self.player._mpd)) self.player.connect() except (PlayerError, PlayerUnHandledError) as err: self.log.warning('Player: {}'.format(err)) @@ -63,7 +64,7 @@ class Sima(Daemon): self.short_history.appendleft(self.player.current) def register_plugin(self, plugin_class): - """Registers plubin in Sima instance...""" + """Registers plugin in Sima instance...""" self.plugins.append(plugin_class(self)) def foreach_plugin(self, method, *args, **kwds): @@ -122,16 +123,20 @@ class Sima(Daemon): def hup_handler(self, signum, frame): self.log.warning('Caught a sighup!') - self.player.disconnect() + # Cleaning pending command + self.player.clean() self.foreach_plugin('shutdown') + self.player.disconnect() raise SigHup('SIGHUP caught!') def shutdown(self): """General shutdown method """ self.log.warning('Starting shutdown.') - self.player.disconnect() + # Cleaning pending command + self.player.clean() self.foreach_plugin('shutdown') + self.player.disconnect() self.log.info('The way is shut, it was made by those who are dead. ' 'And the dead keep it…')