rework sea cfg

use seaststus.tcl instead of a live connection for getting
the current SEA cfg. cfg is now shown also when all instruments
are listed
This commit is contained in:
l_samenv 2022-12-21 13:37:17 +01:00
parent b387177668
commit 91cf31dde5
2 changed files with 27 additions and 7 deletions

View File

@ -416,10 +416,7 @@ class ServiceManager:
for serv, port in info_grp.items(): for serv, port in info_grp.items():
plist = procs_dict.get(serv) plist = procs_dict.get(serv)
if plist: if plist:
if ins is None: cfg = cfginfo.get((ins_i, serv), '') or sm.get_cfg(ins_i, serv)
cfg = ''
else:
cfg = cfginfo.get((ins_i, serv), '') or sm.get_cfg(ins_i, serv)
if sm == self: if sm == self:
show_ins = True show_ins = True
gs = '%s %s' % (group, serv) gs = '%s %s' % (group, serv)
@ -434,7 +431,7 @@ class ServiceManager:
if show_ins: if show_ins:
rows.extend(run_info) rows.extend(run_info)
print('') print('')
printTable(('inst', 'service', 'port', '' if ins is None else 'cfg'), rows, print) printTable(('inst', 'service', 'port', 'cfg'), rows, print)
@staticmethod @staticmethod
def extra_info(ins): def extra_info(ins):

View File

@ -25,9 +25,12 @@ import time
import termios import termios
import subprocess import subprocess
import os import os
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
from servicemanager.sicsclient import sics_client
CFGLINE = re.compile(r'(device makeitem (name|stick_name) "(.*)" ""|'
r'addon_list makeitem (.*) ("permanent"|"volatile"))')
def run_command(cmd, wait=False): def run_command(cmd, wait=False):
@ -116,7 +119,27 @@ class SeaManager(ServiceManager):
if service != 'sea': # ignore when service == 'graph' if service != 'sea': # ignore when service == 'graph'
return '' return ''
try: try:
return sics_client(('localhost', self.info[ins]['sea']), 'samenv name') searoot = self.env[ins].get('SEA_ROOT', '')
seastatus = join(searoot, ins, 'status', 'seastatus.tcl')
if not exists(seastatus):
seastatus = join(searoot, 'status', 'seastatus.tcl')
if not exists(seastatus):
return '?'
result = ['', '']
with open(seastatus, 'r', encoding='utf-8') as f:
for line in f:
match = CFGLINE.match(line)
if match:
_, key, dev, addon, _ = match.groups()
if addon:
result.append(addon)
elif key == 'name':
result[0] = dev
else:
result[1] = dev
if not result[-1]:
result.pop()
return '/'.join(result)
except Exception as e: except Exception as e:
return repr(e) return repr(e)