better message when server is not running

when a client is started and the server is not running,
issue 'please use ".. start .."' message
This commit is contained in:
zolliker 2021-04-09 10:15:32 +02:00
parent 9900af0e3f
commit 3748948b5d
3 changed files with 9 additions and 6 deletions

View File

@ -63,8 +63,8 @@ def run(group, arglist):
return
action = arglist.pop(0) if hasattr(serv, 'do_' + arglist[0]) else 'gui'
instance = arglist.pop(0) if arglist[0] and arglist[0] not in serv.services else None
if instance is None and len(serv.info) == 1:
instance = list(serv.info)[0]
if instance is None and serv.main_ins:
instance = serv.main_ins
if instance is not None:
arglist.insert(0, instance)
arglist.pop() # remove dummy argument

10
base.py
View File

@ -83,7 +83,7 @@ class ServiceManager:
pkg = ''
revcmd = {}
USAGE = None
main_instrument = basename(expanduser('~'))
main_ins = basename(expanduser('~'))
def __init__(self):
self.env = {}
@ -137,7 +137,7 @@ class ServiceManager:
for ins in parser.sections():
section = dict(parser[ins])
if ins == 'MAIN':
ins = self.main_instrument
ins = self.main_ins
command = section.get('%s_command' % self.group)
self.revcmd[command] = self.group
nr = section.get(self.group)
@ -193,7 +193,7 @@ class ServiceManager:
match = cmdpat.match(cmd)
if match:
gdict = match.groupdict()
ins = gdict.get('ins', self.main_instrument)
ins = gdict.get('ins', self.main_ins)
serv = gdict.get('serv', '')
if cfginfo is not None and 'cfg' in gdict:
cfginfo[ins, serv] = gdict['cfg']
@ -204,8 +204,10 @@ class ServiceManager:
self.get_info()
if ins not in self.info:
raise KeyError("don't know %r" % ins)
sp_ins = ' ' + ins if ins != self.main_ins else ''
if not self.get_procs().get(ins, {}).get(service):
raise ServiceDown('%s %s is not running' % (service, ins))
startcmd = '%s start%s' % (self.group, sp_ins)
raise ServiceDown('%s%s is not running - please use %r' % (self.group, sp_ins, startcmd))
def stop(self, ins, service=None):
"""stop service (or all services) of instance <ins>"""

View File

@ -78,6 +78,7 @@ class SeaManager(ServiceManager):
except ServiceDown as e:
self.usage()
print(str(e))
return
except KeyError: # running on an other machine?
self.usage()
run_command('SeaClient %s' % ins)