From: kaliko Date: Sat, 12 Dec 2020 18:18:08 +0000 (+0100) Subject: Add a PluginConfException X-Git-Tag: 0.16.0~17 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=0ff817170b0d08b560ead415d3a13660985fbae1;p=mpd-sima.git Add a PluginConfException --- 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