]> kaliko git repositories - mpd-sima.git/blobdiff - sima/launch.py
Simplified first loop iteration detection
[mpd-sima.git] / sima / launch.py
index 890f96bfd1641db6c1b6a3b1e357ffe7ea4c8571..4b77f89a29c5320212b1fe72e16f02701735eda7 100644 (file)
@@ -39,6 +39,7 @@ from .lib.simadb import SimaDB
 from .utils.config import ConfMan
 from .utils.startopt import StartOpt
 from .utils.utils import exception_log, SigHup, MPDSimaException
+from .utils.blcli import BLCli
 # core plugins
 from .plugins.core.history import History
 from .plugins.core.mpdoptions import MpdOptions
@@ -86,7 +87,10 @@ def start(sopt, restart=False):
     logger = logging.getLogger('sima')
     logfile = config.get('log', 'logfile', fallback=None)
     verbosity = config.get('log', 'verbosity')
-    set_logger(verbosity, logfile)
+    if sopt.options.get('command'):  # disable file logging
+        set_logger(verbosity)
+    else:
+        set_logger(verbosity, logfile)
     logger.debug('Command line say: %s', sopt.options)
 
     # Create database if not present
@@ -104,6 +108,9 @@ def start(sopt, restart=False):
 
     if sopt.options.get('command'):
         cmd = sopt.options.get('command')
+        if cmd.startswith('bl-'):
+            BLCli(config, sopt.options)
+            sys.exit(0)
         if cmd == "generate-config":
             config.write(sys.stdout, space_around_delimiters=True)
             sys.exit(0)
@@ -141,7 +148,8 @@ def start(sopt, restart=False):
     for cplgn in core_plugins:
         logger.debug('Register core %(name)s (%(doc)s)', cplgn.info())
         sima.register_core_plugin(cplgn)
-    logger.debug('core loaded, prioriy: %s', ' > '.join(map(str, sima.core_plugins)))
+    logger.debug('core loaded, prioriy: %s',
+                 ' > '.join(map(str, sima.core_plugins)))
 
     #  Loading internal plugins
     load_plugins(sima, 'internal')
@@ -181,11 +189,12 @@ def run(sopt, restart=False):
     except Exception:  # Unhandled exception
         exception_log()
 
+
 # Script starts here
 def main():
     """Entry point"""
     nfo = dict({'version': info.__version__,
-                'prog': 'sima'})
+                'prog': 'mpd-sima'})
     # StartOpt gathers options from command line call (in StartOpt().options)
     sopt = StartOpt(nfo)
     run(sopt)