Skip to content
Snippets Groups Projects
Commit 75341417 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-742: By default use the TANGO_HOST as configured already

parent 5bf38694
No related branches found
No related tags found
1 merge request!300L2SS-742: Use FQDN for TANGO_HOST to avoid confusion in hdbpp, which adds the...
......@@ -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):
......
......@@ -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'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment