[WIP] next try
This commit is contained in:
16
commands.py
16
commands.py
@ -69,7 +69,7 @@ def all_info(all_cfg):
|
|||||||
info.append('%s=%r' % (srv, cfginfo))
|
info.append('%s=%r' % (srv, cfginfo))
|
||||||
else:
|
else:
|
||||||
info.append(repr(cfginfo))
|
info.append(repr(cfginfo))
|
||||||
return 'currently configured: frappy(%s)' % ', '.join(info)
|
return 'frappy(%s)' % ', '.join(info)
|
||||||
|
|
||||||
|
|
||||||
def frappy_start(**services):
|
def frappy_start(**services):
|
||||||
@ -178,10 +178,10 @@ def frappy(*args, main=None, stick=None, addons=None):
|
|||||||
raise TypeError('got multiple values for addons')
|
raise TypeError('got multiple values for addons')
|
||||||
addons = ','.join(alist)
|
addons = ','.join(alist)
|
||||||
allcfg = frappy_start(main=main, stick=stick, addons=addons)
|
allcfg = frappy_start(main=main, stick=stick, addons=addons)
|
||||||
session.log.info(all_info(allcfg))
|
session.log.info('currently configured %s', all_info(allcfg))
|
||||||
else:
|
else:
|
||||||
allcfg = frappy_start(main=main, stick=stick, addons=addons)
|
allcfg = frappy_start(main=main, stick=stick, addons=addons)
|
||||||
session.log.info(all_info(allcfg))
|
session.log.info('currently configured %s', all_info(allcfg))
|
||||||
guess1 = {}
|
guess1 = {}
|
||||||
guess2 = {}
|
guess2 = {}
|
||||||
for s in SERVICES:
|
for s in SERVICES:
|
||||||
@ -198,9 +198,9 @@ def frappy(*args, main=None, stick=None, addons=None):
|
|||||||
elif guess1 or guess2:
|
elif guess1 or guess2:
|
||||||
session.log.info('please consider to call:')
|
session.log.info('please consider to call:')
|
||||||
if guess1:
|
if guess1:
|
||||||
session.log.info(all_info(guess1))
|
session.log.info('from frappy / cache: %s', all_info(guess1))
|
||||||
if guess2:
|
if guess2:
|
||||||
session.log.info(all_info(guess2))
|
session.log.info('including info from sea: %s', all_info(guess2))
|
||||||
|
|
||||||
|
|
||||||
@usercommand
|
@usercommand
|
||||||
@ -211,7 +211,7 @@ def frappy_main(cfg=None):
|
|||||||
- without argument: list running frappy servers
|
- without argument: list running frappy servers
|
||||||
- cfg = "": stop frappy_main server
|
- cfg = "": stop frappy_main server
|
||||||
"""
|
"""
|
||||||
session.log.info(all_info(frappy_start(main=cfg)))
|
session.log.info('currently configured %s', all_info(frappy_start(main=cfg)))
|
||||||
|
|
||||||
|
|
||||||
@usercommand
|
@usercommand
|
||||||
@ -222,7 +222,7 @@ def frappy_stick(cfg=None):
|
|||||||
- without argument: list running frappy servers
|
- without argument: list running frappy servers
|
||||||
- cfg = "": stop frappy_stick server
|
- cfg = "": stop frappy_stick server
|
||||||
"""
|
"""
|
||||||
session.log.info(all_info(frappy_start(stick=cfg)))
|
session.log.info('currently configured %s', all_info(frappy_start(stick=cfg)))
|
||||||
|
|
||||||
|
|
||||||
@usercommand
|
@usercommand
|
||||||
@ -233,7 +233,7 @@ def frappy_addons(cfg=None):
|
|||||||
- without argument: list running frappy servers
|
- without argument: list running frappy servers
|
||||||
- cfg = "": stop frappy_addons server
|
- cfg = "": stop frappy_addons server
|
||||||
"""
|
"""
|
||||||
session.log.info(all_info(frappy_start(addons=cfg)))
|
session.log.info('currently configured %s', all_info(frappy_start(addons=cfg)))
|
||||||
|
|
||||||
|
|
||||||
@usercommand
|
@usercommand
|
||||||
|
24
devices.py
24
devices.py
@ -229,7 +229,6 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
type=str, default='', settable=True),
|
type=str, default='', settable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_service_manager = FrappyManager()
|
|
||||||
_cfgvalue = None
|
_cfgvalue = None
|
||||||
|
|
||||||
def doStart(self, value):
|
def doStart(self, value):
|
||||||
@ -251,8 +250,12 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
return self.secnode.descriptive_data['_frappy_config']
|
return self.secnode.descriptive_data['_frappy_config']
|
||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
pass
|
pass
|
||||||
if self._cfgvalue is None and self._cache:
|
if self._cfgvalue is None:
|
||||||
self._cfgvalue = self._cache.get(self, 'value')
|
sea_cfg = FrappyManager().cfg_from_sea(config.instrument).get(self.service)
|
||||||
|
if sea_cfg:
|
||||||
|
return sea_cfg
|
||||||
|
if self._cache:
|
||||||
|
self._cfgvalue = self._cache.get(self, 'value')
|
||||||
return self._cfgvalue
|
return self._cfgvalue
|
||||||
|
|
||||||
def createDevices(self):
|
def createDevices(self):
|
||||||
@ -269,9 +272,7 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def config_dirs(cls, ins, service):
|
def config_dirs(cls, ins, service):
|
||||||
# TODO: no more needed after allowing ~cfg in FrappyManager.do_start
|
# TODO: no more needed after allowing ~cfg in FrappyManager.do_start
|
||||||
sm = cls._service_manager
|
return FrappyManager().config_dirs(ins, service)
|
||||||
sm.get_info()
|
|
||||||
return sm.config_dirs(ins, service)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def available_cfg(cls, service):
|
def available_cfg(cls, service):
|
||||||
@ -308,12 +309,13 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
if cfg is None:
|
if cfg is None:
|
||||||
cfg = self._cfgvalue
|
cfg = self._cfgvalue
|
||||||
ins = config.instrument
|
ins = config.instrument
|
||||||
info = self._service_manager.get_ins_info(ins)
|
fm = FrappyManager()
|
||||||
|
info = fm.get_ins_info(ins)
|
||||||
cfginfo = {}
|
cfginfo = {}
|
||||||
self._service_manager.get_procs(cfginfo=cfginfo)
|
fm.get_procs(cfginfo=cfginfo)
|
||||||
running_cfg = cfginfo.get((ins, self.service), '')
|
running_cfg = cfginfo.get((ins, self.service), '')
|
||||||
if not forced:
|
if not forced:
|
||||||
sea_cfg = self._service_manager.cfg_from_sea(ins).get(self.service)
|
sea_cfg = fm.cfg_from_sea(ins).get(self.service)
|
||||||
if sea_cfg == '?':
|
if sea_cfg == '?':
|
||||||
self.log.warning('undefined sea device')
|
self.log.warning('undefined sea device')
|
||||||
cfg = '' # stop server
|
cfg = '' # stop server
|
||||||
@ -327,7 +329,7 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
self.disable()
|
self.disable()
|
||||||
if running_cfg:
|
if running_cfg:
|
||||||
self._disconnect()
|
self._disconnect()
|
||||||
self._service_manager.do_stop(ins, self.service)
|
fm.do_stop(ins, self.service)
|
||||||
is_cfg = cfg and ':' not in cfg
|
is_cfg = cfg and ':' not in cfg
|
||||||
if is_cfg:
|
if is_cfg:
|
||||||
available_cfg = self.available_cfg(self.service)
|
available_cfg = self.available_cfg(self.service)
|
||||||
@ -347,7 +349,7 @@ class FrappyNode(SecNodeDevice, Moveable):
|
|||||||
self.uri = '' # disconnect
|
self.uri = '' # disconnect
|
||||||
if uri:
|
if uri:
|
||||||
if is_cfg:
|
if is_cfg:
|
||||||
self._service_manager.do_start(ins, self.service, cfg, logger=self.log)
|
fm.do_start(ins, self.service, cfg, logger=self.log)
|
||||||
self.uri = uri # connect
|
self.uri = uri # connect
|
||||||
self._cfgvalue = cfg
|
self._cfgvalue = cfg
|
||||||
if self._cache:
|
if self._cache:
|
||||||
|
Reference in New Issue
Block a user