better argument treatment
This commit is contained in:
30
seaman.py
30
seaman.py
@ -24,6 +24,7 @@ import sys
|
||||
import time
|
||||
import termios
|
||||
import subprocess
|
||||
import os
|
||||
from servicemanager.base import ServiceManager, ServiceDown
|
||||
from servicemanager.sicsclient import sics_client
|
||||
|
||||
@ -66,21 +67,21 @@ class SeaManager(ServiceManager):
|
||||
try:
|
||||
self.check_running(ins, 'sea')
|
||||
except ServiceDown as e:
|
||||
self.usage()
|
||||
self.do_help()
|
||||
print(str(e))
|
||||
except KeyError: # running on an other machine?
|
||||
self.usage()
|
||||
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.usage()
|
||||
self.do_help()
|
||||
print(str(e))
|
||||
return
|
||||
except KeyError: # running on an other machine?
|
||||
self.usage()
|
||||
self.do_help()
|
||||
run_command('SeaClient %s' % ins)
|
||||
print('starting sea gui %s' % ins)
|
||||
time.sleep(5)
|
||||
@ -97,3 +98,24 @@ class SeaManager(ServiceManager):
|
||||
except Exception as e:
|
||||
print(self.info)
|
||||
return repr(e)
|
||||
|
||||
def treat_args(self, argdict, unknown=(), extra=()):
|
||||
if len(unknown) == 1:
|
||||
insts = set()
|
||||
filename = os.environ.get('InstrumentHostList')
|
||||
if filename:
|
||||
with open(filename) as fil:
|
||||
for line in fil:
|
||||
inst = None
|
||||
sea = False
|
||||
for item in line.split():
|
||||
key, _, value = item.partition('=')
|
||||
if key == 'instr':
|
||||
inst = value
|
||||
elif key == 'sea':
|
||||
sea = True
|
||||
if inst and sea:
|
||||
insts.add(inst)
|
||||
if unknown[0] in insts:
|
||||
return super().treat_args(argdict, (), unknown)
|
||||
return super().treat_args(argdict, unknown, extra)
|
||||
|
Reference in New Issue
Block a user