support to start sea automatically from SeaClient (with -q arg)
This commit is contained in:
46
seaman.py
46
seaman.py
@ -25,7 +25,7 @@ import time
|
||||
import termios
|
||||
import subprocess
|
||||
import os
|
||||
from servicemanager.base import ServiceManager, ServiceDown
|
||||
from servicemanager.base import ServiceManager, ServiceDown, UsageError
|
||||
from servicemanager.sicsclient import sics_client
|
||||
|
||||
|
||||
@ -73,17 +73,20 @@ class SeaManager(ServiceManager):
|
||||
self.do_help()
|
||||
run_command('six -sea %s' % ins, wait=True)
|
||||
|
||||
def do_gui(self, ins=''):
|
||||
try:
|
||||
self.check_running(ins, 'sea')
|
||||
except ServiceDown as e:
|
||||
self.do_help()
|
||||
print(str(e))
|
||||
return
|
||||
except KeyError: # running on an other machine?
|
||||
self.do_help()
|
||||
run_command('SeaClient %s' % ins)
|
||||
print('starting sea gui %s' % ins)
|
||||
def do_gui(self, ins='', *args):
|
||||
if ins:
|
||||
args = (ins,) + args
|
||||
if '-q' not in args:
|
||||
try:
|
||||
self.check_running(ins, 'sea')
|
||||
except ServiceDown as e:
|
||||
self.do_help()
|
||||
print(str(e))
|
||||
return
|
||||
except KeyError: # running on an other machine?
|
||||
self.do_help()
|
||||
run_command('SeaClient %s' % ' '.join(args))
|
||||
print('starting sea gui %s' % ' '.join(args))
|
||||
time.sleep(5)
|
||||
|
||||
def get_cfg(self, ins, service):
|
||||
@ -100,13 +103,19 @@ class SeaManager(ServiceManager):
|
||||
return repr(e)
|
||||
|
||||
def treat_args(self, argdict, unknown=(), extra=()):
|
||||
if len(unknown) == 1:
|
||||
extra = list(extra)
|
||||
for arg in unknown:
|
||||
if arg == '-q' and arg not in extra:
|
||||
extra.append(arg)
|
||||
continue
|
||||
if argdict.get('ins'):
|
||||
raise UsageError('superflous argument: %s' % arg)
|
||||
insts = set()
|
||||
filename = os.environ.get('InstrumentHostList')
|
||||
if filename:
|
||||
with open(filename) as fil:
|
||||
for line in fil:
|
||||
inst = None
|
||||
inst = ''
|
||||
sea = False
|
||||
for item in line.split():
|
||||
key, _, value = item.partition('=')
|
||||
@ -116,7 +125,8 @@ class SeaManager(ServiceManager):
|
||||
sea = True
|
||||
if inst and sea:
|
||||
insts.add(inst)
|
||||
if unknown[0] in insts:
|
||||
argdict['ins'] = unknown[0]
|
||||
return super().treat_args(argdict)
|
||||
return super().treat_args(argdict, unknown, extra)
|
||||
if arg in insts:
|
||||
argdict['ins'] = arg
|
||||
else:
|
||||
raise UsageError('unknown argument: %s' % arg)
|
||||
return [argdict.pop('ins', '')] + extra
|
||||
|
Reference in New Issue
Block a user