]> kaliko git repositories - mpd-sima.git/blobdiff - sima/launch.py
Fixed blacklisting in track mode
[mpd-sima.git] / sima / launch.py
index dbd15256569a76ab1fee96e495d04c1aa033f210..19fac0c3c06979283acda38ead04dc3b3ddfacf7 100644 (file)
@@ -1,4 +1,22 @@
 # -*- coding: utf-8 -*-
+# Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
+#
+#  This file is part of sima
+#
+#  sima is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  sima is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with sima.  If not, see <http://www.gnu.org/licenses/>.
+#
+#
 """Sima
 """
 
@@ -31,7 +49,7 @@ def load_plugins(sima, source):
         sima:   sima.core.Sima instance
         source: ['internal', 'contrib']
     """
-    if not sima.config.get('sima', source ):
+    if not sima.config.get('sima', source):
         return
     logger = logging.getLogger('sima')
     for plugin in sima.config.get('sima', source).split(','):
@@ -40,14 +58,18 @@ def load_plugins(sima, source):
         try:
             mod_obj = __import__(module, fromlist=[plugin])
         except ImportError as err:
-            logger.error('Failed to load plugin\'s module: {0} ({1})'.format(module, err))
+            logger.error('Failed to load plugin\'s module: ' +
+                         '{0} ({1})'.format(module, err))
             sima.shutdown()
+            sys.exit(1)
         try:
             plugin_obj = getattr(mod_obj, plugin)
         except AttributeError as err:
             logger.error('Failed to load plugin {0} ({1})'.format(plugin, err))
             sima.shutdown()
-        logger.info('Loading {0} plugin: {name} ({doc})'.format(source, **plugin_obj.info()))
+            sys.exit(1)
+        logger.info('Loading {0} plugin: {name} ({doc})'.format(
+                             source, **plugin_obj.info()))
         sima.register_plugin(plugin_obj)
 
 
@@ -113,13 +135,14 @@ def run(sopt, restart=False):
     # pylint: disable=broad-except
     try:
         start(sopt, restart)
-    except SigHup as err:  # SigHup inherit from Exception
+    except SigHup:  # SigHup inherit from Exception
         run(sopt, True)
     except Exception:  # Unhandled exception
         exception_log()
 
 # Script starts here
 def main():
+    """Entry point"""
     nfo = dict({'version': info.__version__,
                  'prog': 'sima'})
     # StartOpt gathers options from command line call (in StartOpt().options)