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