[WIP] '?' for sea devices without frappy cfg

This commit is contained in:
zolliker 2023-09-12 11:37:39 +02:00
parent 840bd59bb1
commit c5a7f4a494

View File

@ -104,13 +104,14 @@ class FrappyManager(ServiceManager):
raise UsageError('no wildcards allowed with %s start' % self.group) raise UsageError('no wildcards allowed with %s start' % self.group)
if cfg and not service and len(self.services) != 1: if cfg and not service and len(self.services) != 1:
raise UsageError('need service to start (one of %s)' % ', '.join(self.services)) raise UsageError('need service to start (one of %s)' % ', '.join(self.services))
if cfg.startswith('~'): # TODO: check if we really need this
cfg = cfg[1:] # if (cfg or '').startswith('~'):
seacfg = self.cfg_from_sea(ins).get(service) # cfg = cfg[1:]
if seacfg: # seacfg = self.cfg_from_sea(ins).get(service)
cfg = seacfg # if seacfg:
if not cfg: # cfg = seacfg
return # if not cfg:
# return
super().do_start(ins, service, cfg, restart, wait, logger) super().do_start(ins, service, cfg, restart, wait, logger)
def do_restart(self, ins, service=None, cfg=None, logger=None): def do_restart(self, ins, service=None, cfg=None, logger=None):
@ -243,16 +244,24 @@ class FrappyManager(ServiceManager):
sea.get_info() sea.get_info()
cfgs = sea.get_cfg(ins, 'sea').split('/') cfgs = sea.get_cfg(ins, 'sea').split('/')
result = {} result = {}
if cfgs[0] and cfgs[0] in self.all_cfg(ins, 'main'):
result['main'] = cfgs[0] def check_cfg_file(self, cfg, allcfg, stick=''):
if cfg in allcfg:
return cfg
if cfg + stick in allcfg:
return cfg + stick
return cfg + '?'
if cfgs[0]:
result['main'] = check_cfg_file(cfgs[0], self.all_cfg(ins, 'main'))
allsticks = self.all_cfg(ins, 'stick') allsticks = self.all_cfg(ins, 'stick')
stick = cfgs[:2][-1] if len(cfgs) > 1:
stick = cfgs[1]
if stick: if stick:
for s in (stick + 'stick', stick): if stick + 'stick' in allsticks:
if s in allsticks: cfg = stick + 'stick'
result['stick'] = s result['stick'] = check_cfg_file(cfg, allsticks)
break addons = [check_cfg_file(a) for a in cfgs[2:]]
addons = [a for a in cfgs[2:] if a in self.all_cfg(ins, 'addons')]
if addons: if addons:
result['addons'] = ','.join(addons) result['addons'] = ','.join(addons)
return result return result