From 753414177b3d72f83c8149ca330182ec921a7cee Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Wed, 6 Apr 2022 21:17:36 +0200 Subject: [PATCH] L2SS-742: By default use the TANGO_HOST as configured already --- .../tangostationcontrol/test/toolkit/test_archiver_util.py | 4 ++-- .../tangostationcontrol/toolkit/archiver_util.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/test/toolkit/test_archiver_util.py b/tangostationcontrol/tangostationcontrol/test/toolkit/test_archiver_util.py index 4265c2775..842aff836 100644 --- a/tangostationcontrol/tangostationcontrol/test/toolkit/test_archiver_util.py +++ b/tangostationcontrol/tangostationcontrol/test/toolkit/test_archiver_util.py @@ -22,12 +22,12 @@ class TestArchiverUtil(base.TestCase): def test_device_fqdn(self): """Test if a device name is correctly converted in a Tango FQDN""" - self.assertEqual(f"tango://databaseds:10000/{self.device_name}".lower(), device_fqdn(self.device_name)) + self.assertEqual(f"tango://databaseds:10000/{self.device_name}".lower(), device_fqdn(self.device_name, "databaseds:10000")) def test_attribute_fqdn(self): """Test if an attribute name is correctly converted in a Tango FQDN""" self.assertEqual(f"tango://databaseds:10000/{self.device_name}/{self.attribute_name}".lower(), - attribute_fqdn(f"{self.device_name}/{self.attribute_name}")) + attribute_fqdn(f"{self.device_name}/{self.attribute_name}", "databaseds:10000")) self.assertRaises(ValueError, lambda: attribute_fqdn(self.attribute_name)) def test_split_tango_name(self): diff --git a/tangostationcontrol/tangostationcontrol/toolkit/archiver_util.py b/tangostationcontrol/tangostationcontrol/toolkit/archiver_util.py index 0d5e8f4d9..c797c5267 100644 --- a/tangostationcontrol/tangostationcontrol/toolkit/archiver_util.py +++ b/tangostationcontrol/tangostationcontrol/toolkit/archiver_util.py @@ -6,6 +6,7 @@ from tango import DeviceProxy, CmdArgType import re +import os """ A dictionary whose keys are the Tango datatypes mapping, and the values are the relative byte size @@ -21,6 +22,8 @@ DATATYPES_SIZE_DICT = {CmdArgType.DevBoolean:1, CmdArgType.DevShort:2, CmdArgTyp CmdArgType.DevULong64:8,CmdArgType.DevVarLong64Array:None,CmdArgType.DevVarULong64Array:None, CmdArgType.DevInt:4,CmdArgType.DevEncoded:None, CmdArgType.DevEnum:None, CmdArgType.DevPipeBlob:None} +TANGO_HOST = os.environ.get("TANGO_HOST", None) + def get_db_config(device_name:str) -> dict: """ Retrieve the DB credentials from the Tango properties of Configuration Manager or EventSubscribers @@ -46,7 +49,7 @@ def get_attribute_from_fqdn(attribute_name:str): return attribute_name -def device_fqdn(device_name:str, tango_host:str = 'databaseds:10000'): +def device_fqdn(device_name:str, tango_host:str = TANGO_HOST): """ For some operations Tango devices must be transformed from the form 'domain/family/name' to 'tango://db:port/domain/family/name' @@ -59,7 +62,7 @@ def device_fqdn(device_name:str, tango_host:str = 'databaseds:10000'): return f"tango://{tango_host}/{device_name}".lower() -def attribute_fqdn(attribute_name:str, tango_host:str = 'databaseds:10000'): +def attribute_fqdn(attribute_name:str, tango_host:str = TANGO_HOST): """ For some operations Tango devices must be transformed from the form 'domain/family/name/attribute' to 'tango://db:port/domain/family/name/attribute' -- GitLab