From 0ff817170b0d08b560ead415d3a13660985fbae1 Mon Sep 17 00:00:00 2001 From: kaliko Date: Sat, 12 Dec 2020 19:18:08 +0100 Subject: [PATCH] Add a PluginConfException --- sima/launch.py | 9 ++++++--- sima/utils/utils.py | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/sima/launch.py b/sima/launch.py index c548ce9..538238b 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -37,7 +37,7 @@ from .lib.logger import set_logger from .lib.simadb import SimaDB from .utils.config import ConfMan from .utils.startopt import StartOpt -from .utils.utils import exception_log, SigHup +from .utils.utils import exception_log, SigHup, PluginConfException # core plugins from .plugins.core.history import History from .plugins.core.mpdoptions import MpdOptions @@ -72,7 +72,11 @@ def load_plugins(sima, source): sys.exit(1) logger.info('Loading {0} plugin: {name} ({doc})'.format( source, **plugin_obj.info())) - sima.register_plugin(plugin_obj) + try: + sima.register_plugin(plugin_obj) + except PluginConfException as err: + logger.error(err) + sys.exit(2) def start(sopt, restart=False): @@ -117,7 +121,6 @@ def start(sopt, restart=False): # Loading internal plugins load_plugins(sima, 'internal') - # Loading contrib plugins load_plugins(sima, 'contrib') logger.info('plugins loaded, prioriy: %s', ' > '.join(map(str, sima.plugins))) diff --git a/sima/utils/utils.py b/sima/utils/utils.py index db5baf0..5c2a312 100644 --- a/sima/utils/utils.py +++ b/sima/utils/utils.py @@ -179,6 +179,11 @@ class WSTimeout(WSError): class WSHTTPError(WSError): pass +class MPDSimaException(Exception): + pass + +class PluginConfException(MPDSimaException): + pass # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab -- 2.39.5