improvements towards multi instrument machines
This commit is contained in:
@@ -99,9 +99,16 @@ class Config:
|
||||
def __init__(self):
|
||||
configfile = Path('/sq_sw/linse/etc/linsetools.cfg')
|
||||
self.sections = read_config(configfile)
|
||||
if Path('/home/l_samenv').is_dir():
|
||||
for section_name, section in self.sections.items():
|
||||
for key, value in section.items():
|
||||
if value.startswith('/home/linse'):
|
||||
section[key] = value.replace('/home/linse', '/home/l_samenv')
|
||||
instconfig = Path('/home/linse/.config/instrument.cfg')
|
||||
if not instconfig.is_file():
|
||||
instconfig = Path('/home/l_samenv/.config/instrument.cfg')
|
||||
cfg = Path('/home/l_samenv/.config/instrument.cfg')
|
||||
if cfg.is_file():
|
||||
instconfig = cfg
|
||||
if instconfig.is_file():
|
||||
self.instruments = read_config(instconfig)
|
||||
else:
|
||||
@@ -147,7 +154,6 @@ class Logger:
|
||||
method = log.show
|
||||
for lev in log.levels:
|
||||
setattr(log, lev, method)
|
||||
print(lev, level)
|
||||
if lev == level:
|
||||
method = log.hide
|
||||
return log
|
||||
@@ -213,8 +219,7 @@ class MarcheControl:
|
||||
def connect(self):
|
||||
if self._client is None:
|
||||
if self.user == 'l_samenv':
|
||||
x = 1
|
||||
arg = f'{2**4+x}lns{x}'
|
||||
arg = ''
|
||||
else:
|
||||
arg = self.user.upper() + 'LNS'
|
||||
self._client = Client(self.host, self.port, self.user, arg)
|
||||
@@ -277,10 +282,15 @@ class MarcheControl:
|
||||
config = Config()
|
||||
argdict = config.parse_args(cls.argmap, args, cls.otherarg)
|
||||
instrument = argdict.pop('instrument', None)
|
||||
if instrument is None and argdict.get('action') == 'list': # TODO: make more generic if needed
|
||||
if instrument is None:
|
||||
instruments = list(config.instruments)
|
||||
if len(instruments) != 1:
|
||||
if argdict.get('action') != 'list': # TODO: make more generic if needed
|
||||
raise ValueError('missing instrument')
|
||||
instruments[1:] = []
|
||||
else:
|
||||
instruments = [instrument]
|
||||
for ins in instruments:
|
||||
print('---', ins)
|
||||
control = cls(ins, config=config)
|
||||
control.do(**argdict)
|
||||
|
||||
Reference in New Issue
Block a user