From eb9614a9ac93b38bd6d6e8e2e55c917b712866ea Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 8 Aug 2022 15:42:41 +0200 Subject: [PATCH] more fixes to frappy command - frappy(main=) must (re)load only - frappy() does re(load) standard stick, if available --- commands.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/commands.py b/commands.py index ba8b8b0..838bf98 100644 --- a/commands.py +++ b/commands.py @@ -146,23 +146,37 @@ def set_se_list(): @usercommand @helparglist('main [, stick [, addons]]') -def frappy(main=None, stick=None, addons=None): +def frappy(*args, main=None, stick=None, addons=None): """(re)start frappy server(s) with given configs and load setup if needed - without argument: list running frappy servers - frappy(''): if available, the standard stick is added too - frappy(''): the stick is removed too - - addons are not changed when not given! + - addons are not changed when not given + - frappy(main='') # main cfg is changed, but stick is kept """ - if main is not None: - if stick is None: - if main: - stickcfg = main + 'stick' - if stickcfg in FrappyNode.available_cfg('stick'): - # if a default stick is available, start this also - stick = stickcfg - else: - stick = '' + if args: + if main is not None: + raise TypeError('got multiple values for main') + main = args[0] + if len(args) == 1: # special case: main given as single argument + if stick is None: # auto stick + if main == '': + stick = '' # remove stick with main + else: + stickcfg = main + 'stick' + if stickcfg in FrappyNode.available_cfg('stick'): + # if a default stick is available, start this also + stick = stickcfg + else: + if stick is not None: + raise TypeError('got multiple values for stick') + stick, *alist = args + if alist: + if addons is not None: + raise TypeError('got multiple values for addons') + addons = ','.join(alist) + session.log.info('frappy_start %r %r %r', main, stick, addons) all_cfg = frappy_start(main=main, stick=stick, addons=addons) session.log.info(all_info(all_cfg)) @@ -217,6 +231,7 @@ def frappy_list(service=None): printTable(['command'], [['frappy_list(%r)' % s] for s in SERVICES], session.log.info) session.log.info(' ') for cfgdir in bases: + table.append('--- %s' % cfgdir) for cfgfile in glob(join(cfgdir, '*.cfg')): parser = ConfigParser() parser.read(cfgfile)