]> kaliko git repositories - mpd-sima.git/blobdiff - sima/core.py
Shuffles track to add
[mpd-sima.git] / sima / core.py
index e3bde2c6abfec4b43d2034ff8d46f5dd2a75691d..87501e83b7d8bc60a616c252229f401d3bfc571e 100644 (file)
@@ -6,6 +6,7 @@ __version__ = '0.12.0.b'
 __author__ = 'kaliko jack'
 __url__ = 'git://git.kaliko.me/sima.git'
 
+import random
 import sys
 import time
 
@@ -15,12 +16,15 @@ from logging import getLogger
 from .client import PlayerClient
 from .client import PlayerError, PlayerUnHandledError
 from .lib.simadb import SimaDB
+from .lib.daemon import Daemon
 
-class Sima(object):
+class Sima(Daemon):
     """Main class, plugin and player management
     """
 
     def __init__(self, conf):
+        ## Set daemon
+        Daemon.__init__(self, conf.get('daemon', 'pidfile'))
         self.enabled = True
         self.config = conf
         self.sdb = SimaDB(db_path=conf.get('sima', 'db_file'))
@@ -73,12 +77,12 @@ class Sima(object):
             if pl_callback:
                 to_add.extend(pl_callback)
         if not to_add:
-            self.log.warning('Queue plugins returned anything!')
+            self.log.warning('Queue plugins returned nothing!')
             for plugin in self.plugins:
-                self.log.info('calling fb for {}'.format(plugin))
                 pl_callback =  getattr(plugin, 'callback_need_track_fb')()
                 if pl_callback:
                     to_add.extend(pl_callback)
+        random.shuffle(to_add)
         for track in to_add:
             self.player.add(track)