respect sea cfg and confirmed plugged device

This commit is contained in:
zolliker 2023-09-13 17:20:07 +02:00
parent c5a7f4a494
commit b651ad205f
2 changed files with 16 additions and 16 deletions

View File

@ -242,26 +242,27 @@ class FrappyManager(ServiceManager):
def cfg_from_sea(self, ins):
sea = SeaManager()
sea.get_info()
cfgs = sea.get_cfg(ins, 'sea').split('/')
cfgs, confirmed = sea.get_cfg(ins, 'sea', True)
cfgs = cfgs.split('/')
result = {}
def check_cfg_file(self, cfg, allcfg, stick=''):
if cfg in allcfg:
return cfg
if cfg + stick in allcfg:
return cfg + stick
return cfg + '?'
def check_cfg_file(cfg, allcfg):
if cfg is 'none':
return ''
return cfg if cfg in allcfg else cfg + '?'
if cfgs[0]:
result['main'] = check_cfg_file(cfgs[0], self.all_cfg(ins, 'main'))
allmain = self.all_cfg(ins, 'main')
allsticks = self.all_cfg(ins, 'stick')
if cfgs[0]:
result['main'] = check_cfg_file(cfgs[0], allmain)
if len(cfgs) > 1:
stick = cfgs[1]
if stick:
if stick + 'stick' in allsticks:
cfg = stick + 'stick'
result['stick'] = check_cfg_file(cfg, allsticks)
if stick not in allsticks and stick in allmain:
stick += 'stick'
result['stick'] = check_cfg_file(stick, allsticks)
addons = [check_cfg_file(a) for a in cfgs[2:]]
if addons:
result['addons'] = ','.join(addons)
result['confirmed'] = confirmed
return result

View File

@ -111,7 +111,7 @@ class SeaManager(ServiceManager):
os.system('cp %s ./' % sea_server_src)
return start_dir, env
def get_cfg(self, ins, service):
def get_cfg(self, ins, service, addconfirmed=False):
"""return cfg info about running programs, if relevant
return samenv name
@ -145,9 +145,8 @@ class SeaManager(ServiceManager):
confirmed = dev
if not result[-1]:
result.pop()
if confirmed and confirmed != result[0]:
result[0] = '?'
return '/'.join(result)
result = '/'.join(result)
return (result, confirmed) if addconfirmed else result
except Exception as e:
return repr(e)