[WIP] sea info: return '?' for when confirmed device does not match
This commit is contained in:
13
seaman.py
13
seaman.py
@ -29,8 +29,8 @@ import re
|
||||
from os.path import join, exists
|
||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||
|
||||
CFGLINE = re.compile(r'(device makeitem (name|stick_name) "(.*)" ""|'
|
||||
r'addon_list makeitem (.*) ("permanent"|"volatile"))')
|
||||
CFGLINE = re.compile(r'(?:device makeitem (name|stick_name|confirmed) "(.*)" ""'
|
||||
r'|addon_list makeitem (.*) (?:"permanent"|"volatile"))')
|
||||
|
||||
|
||||
def run_command(cmd, wait=False):
|
||||
@ -128,20 +128,25 @@ class SeaManager(ServiceManager):
|
||||
if not exists(seastatus):
|
||||
return '?'
|
||||
result = ['', '']
|
||||
confirmed = ''
|
||||
with open(seastatus, 'r', encoding='utf-8') as f:
|
||||
for line in f:
|
||||
match = CFGLINE.match(line)
|
||||
if match:
|
||||
_, key, dev, addon, _ = match.groups()
|
||||
key, dev, addon = match.groups()
|
||||
if addon:
|
||||
if addon != result[1]:
|
||||
result.append(addon)
|
||||
elif key == 'name':
|
||||
result[0] = dev
|
||||
else:
|
||||
elif key == 'stick_name':
|
||||
result[1] = dev
|
||||
elif key == 'confirmed':
|
||||
confirmed = dev
|
||||
if not result[-1]:
|
||||
result.pop()
|
||||
if confirmed and confirmed != result[0]:
|
||||
result[0] = '?'
|
||||
return '/'.join(result)
|
||||
except Exception as e:
|
||||
return repr(e)
|
||||
|
Reference in New Issue
Block a user