fix circular import in frappy_sinq

This commit is contained in:
2022-05-02 10:11:16 +02:00
parent aaaca072e4
commit 41640c6c04
2 changed files with 22 additions and 23 deletions

View File

@ -65,28 +65,6 @@ def all_info(all_cfg):
return 'currently configured: %s' % ', '.join(info)
def applyAliasConfig():
"""Apply the desired aliases from session.alias_config.
be more quiet than original
"""
# reimplemented from Session.applyAliasConfig
# apply also when target dev name does not change, as the target device might have
# be exchanged in the mean time
unused = set()
for aliasname, targets in session.alias_config.items():
if aliasname not in session.devices:
continue # silently ignore
aliasdev = session.getDevice(aliasname)
for target, _ in sorted(targets, key=lambda t: -t[1]):
if target in session.devices:
try:
aliasdev.alias = target
except Exception:
session.log.exception("could not set '%s' alias", aliasdev)
break
def frappy_start(service, cfg=None):
if service not in SERVICES:
raise ValueError('unknown service %s' % service)

View File

@ -35,7 +35,6 @@ from nicos.core import Override, Param, Moveable, status
from nicos.devices.secop import SecNodeDevice
from nicos.core import Device, anytype, listof
from nicos.utils.comparestrings import compare
from nicos_sinq.frappy_sinq.commands import applyAliasConfig
from servicemanager import FrappyManager
@ -47,6 +46,28 @@ def suggest(poi, allowed_keys):
return [m[0] for m in comp[:3] if m[1] > 2]
def applyAliasConfig():
"""Apply the desired aliases from session.alias_config.
be more quiet than original
"""
# reimplemented from Session.applyAliasConfig
# apply also when target dev name does not change, as the target device might have
# be exchanged in the mean time
unused = set()
for aliasname, targets in session.alias_config.items():
if aliasname not in session.devices:
continue # silently ignore
aliasdev = session.getDevice(aliasname)
for target, _ in sorted(targets, key=lambda t: -t[1]):
if target in session.devices:
try:
aliasdev.alias = target
except Exception:
session.log.exception("could not set '%s' alias", aliasdev)
break
class FrappyConfig(Device):
# respect the order: e.g. temperature_regulation must be after temperature
# and temperature_drivable must be the last in the temperature group