improve missing arg handling
- better error messages - missing instrument is only allowed with 'list' - missing argument to be replaced with ? in error message - sea cli may now be given with 'graph' or 'sea' for service
This commit is contained in:
20
base.py
20
base.py
@ -222,7 +222,7 @@ class ServiceManager:
|
||||
|
||||
or None, when no wildcard character in ins
|
||||
"""
|
||||
if ins is None or ins == 'all':
|
||||
if not ins or ins == 'all':
|
||||
return list(self.info)
|
||||
pat = re.sub(r'(\.|\*)', '.*', ins)
|
||||
if pat == ins:
|
||||
@ -282,9 +282,9 @@ class ServiceManager:
|
||||
return done
|
||||
|
||||
def do_stop(self, ins, service=None, *args):
|
||||
if not ins:
|
||||
raise UsageError(f'need instrument or "all" to stop all')
|
||||
self.get_info()
|
||||
if ins is None:
|
||||
raise ValueError('use stop all if you really want to stop all')
|
||||
ins_list = self.wildcard(ins)
|
||||
if ins_list is not None:
|
||||
return ins_list
|
||||
@ -301,6 +301,8 @@ class ServiceManager:
|
||||
return env.get('%s_ROOT' % gr, ''), env
|
||||
|
||||
def do_start(self, ins, service=None, cfg='', restart=False, wait=False, logger=None, opts=''):
|
||||
if not ins:
|
||||
raise UsageError(f'need instrument or "all" to start all')
|
||||
ins_list = self.wildcard(ins)
|
||||
if ins_list is not None:
|
||||
return ins_list
|
||||
@ -319,10 +321,10 @@ class ServiceManager:
|
||||
return
|
||||
try:
|
||||
service_ports = self.get_ins_info(ins)
|
||||
except ValueError:
|
||||
raise ValueError('do not know %r' % ins)
|
||||
except (KeyError, ValueError):
|
||||
raise UsageError('do not know %r' % ins)
|
||||
if ins in self.remote_hosts:
|
||||
raise ValueError('can not start, %s is running on a remote host' % self.group)
|
||||
raise UsageError('can not start, %s is running on a remote host' % self.group)
|
||||
services = list(service_ports) if service is None else [service]
|
||||
if restart:
|
||||
self.stop(ins, service)
|
||||
@ -406,8 +408,8 @@ class ServiceManager:
|
||||
os.chdir(wd)
|
||||
|
||||
def do_restart(self, ins, service=None, cfg=None, logger=None):
|
||||
if ins is None:
|
||||
raise UsageError("need instance or 'all' or wildcard")
|
||||
if not ins:
|
||||
raise UsageError("need instrument or 'all' or wildcard")
|
||||
ins_list = self.wildcard(ins)
|
||||
if ins_list is not None:
|
||||
if cfg is not None:
|
||||
@ -418,7 +420,7 @@ class ServiceManager:
|
||||
def do_run(self, ins, service=None, cfg=None, opts=''):
|
||||
"""for tests: run and wait"""
|
||||
if self.wildcard(ins) is not None:
|
||||
raise UsageError('no wildcards allowed with %s run' % self.group)
|
||||
raise UsageError('need instrument and service for "%s run"' % self.group)
|
||||
if not service:
|
||||
try:
|
||||
service, = self.services
|
||||
|
Reference in New Issue
Block a user