add info about SEA cfg in listing

+ fixed: all servers should be shown, independent whether nicos list,
  frappy list or sea list is used
This commit is contained in:
l_samenv 2020-11-03 14:08:38 +01:00
parent eee6c22b87
commit 4b9e0e905d
5 changed files with 19 additions and 12 deletions

View File

@ -95,11 +95,12 @@ class ServiceManager:
all = {} # for the list command, we want to register all service managers
virtualenv = None
pkg = ''
revcmd = {}
def __init__(self):
self.env = {}
self.commands = {}
self.revcmd = {}
# self.revcmd = {}
self.info = {}
self.all[self.group] = self
#prog, args = self.command.split(None, 1)
@ -132,7 +133,7 @@ class ServiceManager:
parser.read(expanduser('~/servman.cfg'))
defaults = parser['DEFAULT']
self.commands = {}
self.revcmd = {}
# self.revcmd = {}
for ins in parser.sections():
section = dict(parser[ins])
@ -154,7 +155,7 @@ class ServiceManager:
self.get_info()
return self.info[ins]
def get_cfg(self, service):
def get_cfg(self, ins, service):
"""return cfg info about running programs, if relevant
example for sea: return samenv name
@ -364,7 +365,7 @@ class ServiceManager:
for serv, port in info_grp.items():
plist = procs_dict.get(serv)
if plist:
cfg = cfginfo.get((ins_i, serv), '') or sm.get_cfg(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)
@ -393,6 +394,7 @@ class ServiceManager:
try:
method(*args)
except TypeError as e:
raise
errtxt = str(e)
if ' do_%s(' % action in errtxt and 'argument' in errtxt:
raise UsageError(errtxt)

View File

@ -59,5 +59,6 @@ try:
run(serv, sys.argv[1:])
except Exception as e:
raise
print(repr(e))
print(''.join(USAGE))

View File

@ -21,7 +21,7 @@
# *****************************************************************************
import re
from __init__ import ServiceManager
from servman import ServiceManager
class FrappyManager(ServiceManager):

View File

@ -26,7 +26,7 @@ import shutil
from glob import glob
from os.path import join, abspath, dirname, expanduser, exists, islink
from configparser import ConfigParser
from __init__ import ServiceManager
from servman import ServiceManager
ENV_KEYS = {

14
sea.py
View File

@ -24,8 +24,8 @@ import sys
import time
import termios
import subprocess
from __init__ import ServiceManager, ServiceDown
from sicsclient import sics_command
from servman import ServiceManager, ServiceDown
from servman.sicsclient import sics_command
def run_command(cmd, wait=False):
@ -73,11 +73,15 @@ class SeaManager(ServiceManager):
time.sleep(5)
def get_cfg(self, service):
def get_cfg(self, ins, service):
"""return cfg info about running programs, if relevant
example for sea: return samenv name
return samenv name
"""
if service != 'sea': # ignore when service == 'graph'
return ''
try:
return sics_command(('localhost', self.info['sea']['port']), 'samenv name')
return sics_command(('localhost', self.info[ins]['sea']), 'samenv name')
except Exception as e:
print(self.info)
return repr(e)