X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flaunch.py;h=9c31397301316ca57dae50a29f4ab42d18c8bb17;hb=ee72bcb36793822f1bd01eba010a28daced75cc3;hp=4b77f89a29c5320212b1fe72e16f02701735eda7;hpb=37dd60538984a3917354b794a5c96b0a025f8e95;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 4b77f89..9c31397 100644 --- a/sima/launch.py +++ b/sima/launch.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2014, 2015, 2020,2021 kaliko +# Copyright (c) 2013, 2014, 2015, 2020, 2021 kaliko # # This file is part of sima # @@ -36,6 +36,7 @@ from os import rename from . import core, info from .lib.logger import set_logger from .lib.simadb import SimaDB +from .mpdclient import PlayerError from .utils.config import ConfMan from .utils.startopt import StartOpt from .utils.utils import exception_log, SigHup, MPDSimaException @@ -51,19 +52,19 @@ def load_plugins(sima, source): """Handles internal/external plugins sima: sima.core.Sima instance source: ['internal', 'contrib'] - """ + """# pylint: disable=logging-not-lazy,logging-format-interpolation if not sima.config.get('sima', source): return logger = logging.getLogger('sima') # TODO: Sanity check for "sima.config.get('sima', source)" ? for plugin in sima.config.get('sima', source).split(','): plugin = plugin.strip(' \n') - module = 'sima.plugins.{0}.{1}'.format(source, plugin.lower()) + module = f'sima.plugins.{source}.{plugin.lower()}' try: mod_obj = sima_import(module, fromlist=[plugin]) except ImportError as err: - logger.error('Failed to load "{}" plugin\'s module: '.format(plugin) + - '{0} ({1})'.format(module, err)) + logger.error(f'Failed to load "{plugin}" plugin\'s module: ' + + f'{module} ({err})') sima.shutdown() sys.exit(1) try: @@ -114,7 +115,7 @@ def start(sopt, restart=False): if cmd == "generate-config": config.write(sys.stdout, space_around_delimiters=True) sys.exit(0) - logger.info('Running "%s" and exit' % cmd) + logger.info('Running "%s" and exit', cmd) if cmd == "config-test": logger.info('Config location: "%s"', cfg_mgmt.conf_file) from .utils.configtest import config_test @@ -183,7 +184,7 @@ def run(sopt, restart=False): start(sopt, restart) except SigHup: # SigHup inherit from Exception run(sopt, True) - except MPDSimaException as err: + except (MPDSimaException, PlayerError) as err: logger.error(err) sys.exit(2) except Exception: # Unhandled exception