diff --git a/tangostationcontrol/tangostationcontrol/devices/snmp_device.py b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py index c74f51661de8b43c70065e0e59609215c54e9d70..4bfbd9778725df60b52b21767c0495fe66a5f3a9 100644 --- a/tangostationcontrol/tangostationcontrol/devices/snmp_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py @@ -12,13 +12,15 @@ """ # PyTango imports -from tango.server import run +from tangostationcontrol.common.entrypoint import entry +from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper +from tangostationcontrol.devices.lofar_device import lofar_device + from tango.server import device_property +import os # Additional import from tangostationcontrol.clients.snmp_client import SNMP_client, mib_loader -from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper -from tangostationcontrol.devices.lofar_device import lofar_device import numpy @@ -40,6 +42,8 @@ class SNMP(lofar_device): - Type:'DevULong' SNMP_community - Type:'DevString' + SNMP_rel_mib_dir + - Type:'DevString' SNMP_timeout - Type:'DevDouble' """ @@ -58,7 +62,7 @@ class SNMP(lofar_device): mandatory=True ) - SNMP_mib_dir = device_property( + SNMP_rel_mib_dir = device_property( dtype='DevString', mandatory=False ) @@ -108,8 +112,14 @@ class SNMP(lofar_device): # create the mib_loader loader = mib_loader() + # get the full mib directory adding the given relative path to the absolute path of this + if self.SNMP_rel_mib_dir[0] == "/": + mib_path = os.path.dirname(__file__) + self.SNMP_rel_mib_dir + else: + mib_path = os.path.dirname(__file__) + "/" + self.SNMP_rel_mib_dir + # set the directory with the compiled mib files. - loader.set_pymib_dir(self.SNMP_mib_dir) + loader.set_pymib_dir(mib_path) for i in self.attr_list(): try: @@ -130,9 +140,5 @@ class SNMP(lofar_device): # ---------- def main(args=None, **kwargs): """Main function of the module.""" - - from tangostationcontrol.common.lofar_logging import configure_logger - configure_logger() - - return run((SNMP,), args=args, **kwargs) + return entry((SNMP,), args=args, **kwargs)