X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fcore.py;h=bf098bbb58ececa7d2442e0927d1009a7ef08e8b;hb=0236b2bf31b893ab0b53374c0d3a0bc0ab9deda3;hp=08135c0da6e26ae0ecf85895db8b24914548f497;hpb=e5c14ed5b4e6aacec5b795a1c9f5518f392ba341;p=mpd-sima.git diff --git a/sima/core.py b/sima/core.py index 08135c0..bf098bb 100644 --- a/sima/core.py +++ b/sima/core.py @@ -2,7 +2,7 @@ """Core Object dealing with plugins and player client """ -__version__ = '0.12.0.b' +__version__ = '0.12.0pr1' __author__ = 'kaliko jack' __url__ = 'git://git.kaliko.me/sima.git' @@ -16,6 +16,7 @@ from .client import PlayerClient from .client import PlayerError, PlayerUnHandledError from .lib.simadb import SimaDB from .lib.daemon import Daemon +from .utils.utils import SigHup class Sima(Daemon): """Main class, plugin and player management @@ -27,6 +28,7 @@ class Sima(Daemon): self.enabled = True self.config = conf self.sdb = SimaDB(db_path=conf.get('sima', 'db_file')) + PlayerClient.database = self.sdb self.log = getLogger('sima') self.plugins = list() self.player = self.__get_player() # Player client @@ -104,6 +106,12 @@ class Sima(Daemon): self.log.info('Got reconnected') break + def hup_handler(self, signum, frame): + self.log.warning('Caught a sighup!') + self.player.disconnect() + self.foreach_plugin('shutdown') + raise SigHup('SIGHUP caught!') + def shutdown(self): """General shutdown method """ @@ -114,7 +122,6 @@ class Sima(Daemon): self.log.info('The way is shut, it was made by those who are dead. ' 'And the dead keep it…') self.log.info('bye...') - sys.exit(0) def run(self): """ @@ -131,6 +138,7 @@ class Sima(Daemon): except PlayerError as err: self.log.warning('Player error: %s' % err) self.reconnect_player() + del(self.changed) def loop(self): """Dispatching callbacks to plugins