From 91cf31dde51ea2ead1d86168654a19ff28d0c784 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Wed, 21 Dec 2022 13:37:17 +0100 Subject: [PATCH] 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 --- base.py | 7 ++----- seaman.py | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/base.py b/base.py index d316347..0f4c18e 100644 --- a/base.py +++ b/base.py @@ -416,10 +416,7 @@ class ServiceManager: for serv, port in info_grp.items(): plist = procs_dict.get(serv) if plist: - if ins is None: - cfg = '' - else: - cfg = cfginfo.get((ins_i, serv), '') or sm.get_cfg(ins_i, serv) + cfg = cfginfo.get((ins_i, serv), '') or sm.get_cfg(ins_i, serv) if sm == self: show_ins = True gs = '%s %s' % (group, serv) @@ -434,7 +431,7 @@ class ServiceManager: if show_ins: rows.extend(run_info) print('') - printTable(('inst', 'service', 'port', '' if ins is None else 'cfg'), rows, print) + printTable(('inst', 'service', 'port', 'cfg'), rows, print) @staticmethod def extra_info(ins): diff --git a/seaman.py b/seaman.py index e8df24b..42326f5 100644 --- a/seaman.py +++ b/seaman.py @@ -25,9 +25,12 @@ import time import termios import subprocess import os +import re from os.path import join, exists 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): @@ -116,7 +119,27 @@ class SeaManager(ServiceManager): if service != 'sea': # ignore when service == 'graph' return '' 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: return repr(e)