more fixes to frappy command

- frappy(main=<maincfg>) must (re)load only <maincfg>
- frappy(<maincfg>) does re(load) standard stick, if available
This commit is contained in:
2022-08-08 15:42:41 +02:00
parent 53a8517464
commit eb9614a9ac

View File

@ -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('<cfg>'): 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='<cfg>') # 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)