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