X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;ds=sidebyside;f=sima%2Flaunch.py;h=179f1c40be5d62a7b7875f310f53a4bbcb7b8825;hb=HEAD;hp=784d23784d480fd3323a210aa44ca93974b99641;hpb=a260ebea93f23d72aa6e0178744b0f64c469b7ba;p=mpd-sima.git diff --git a/sima/launch.py b/sima/launch.py index 784d237..179f1c4 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-2022 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 @@ -135,6 +136,10 @@ def start(sopt, restart=False): sys.exit(1) SimaDB(db_path=db_file).purge_history(duration=0) sys.exit(0) + if cmd == 'random': + config['sima']['internal'] = 'Crop, Random' + if sopt.options.get('nbtracks'): + config['random']['track_to_add'] = str(sopt.options.get('nbtracks')) logger.info('Starting (%s)...', info.__version__) sima = core.Sima(config) @@ -183,7 +188,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