diff --git a/__init__.py b/__init__.py index b7d2074..cf3212d 100644 --- a/__init__.py +++ b/__init__.py @@ -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 diff --git a/base.py b/base.py index 00f023a..fd2e399 100644 --- a/base.py +++ b/base.py @@ -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 """ diff --git a/seaman.py b/seaman.py index c42271f..e8c5e2a 100644 --- a/seaman.py +++ b/seaman.py @@ -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)