diff --git a/devices/common/lofar_git.py b/devices/common/lofar_git.py index f4f6217280fe612fa2e9a7830c1f026c1e36a815..edc4dd5698c31993e6b882728ec3e3a44bcb2342 100644 --- a/devices/common/lofar_git.py +++ b/devices/common/lofar_git.py @@ -80,5 +80,5 @@ except: pass -if __name__ == "__main__": +def main(args=None, **kwargs): print(get_version()) diff --git a/devices/devices/docker_device.py b/devices/devices/docker_device.py index 5ff0ec366c436a2dfc75d4cd479219a04c6938d3..a85f7b4fa9c150f5f678e63e1e46041ae82252b1 100644 --- a/devices/devices/docker_device.py +++ b/devices/devices/docker_device.py @@ -11,12 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango import DebugIt from tango.server import run, command @@ -161,7 +155,3 @@ def main(args=None, **kwargs): configure_logger() return run((Docker,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/hardware_device.py b/devices/devices/hardware_device.py index f8f6ca50d7e02f5a8694c2ec4f9135dd874cd516..809401298306338096d504160ce227ccfc864e9b 100644 --- a/devices/devices/hardware_device.py +++ b/devices/devices/hardware_device.py @@ -223,4 +223,3 @@ class hardware_device(Device, metaclass=AbstractDeviceMetas): except Exception as e: # log which attribute we're addressing raise Exception(f"Cannot assign default to attribute {name}") from e - diff --git a/devices/devices/observation.py b/devices/devices/observation.py index 0ac9cbc1837fdd8e7ded14bb6c8459226c223866..2297c5304abf9861ac820d186ebd5faeb9089d75 100644 --- a/devices/devices/observation.py +++ b/devices/devices/observation.py @@ -5,13 +5,6 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. - -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango import server, Except, DevState, AttrWriteType, DevString, DebugIt from tango.server import Device, run, command, attribute @@ -120,7 +113,3 @@ class Observation(Device): def main(args = None, **kwargs): """Main function of the ObservationControl module.""" return run((Observation,), args = args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/observation_control.py b/devices/devices/observation_control.py index 9b60f86bb983057d023483ebaa61164bdfba5bee..0cba0af6aa6990c0f8a4ec837a92a115eb6f28d9 100644 --- a/devices/devices/observation_control.py +++ b/devices/devices/observation_control.py @@ -5,13 +5,6 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. - -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango import Except, DevFailed, DevState, AttrWriteType, DebugIt, DeviceProxy, Util, DevBoolean, DevString from tango.server import Device, run, command, device_property, attribute @@ -448,7 +441,3 @@ class ObservationControl(Device): def main(args = None, **kwargs): """Main function of the ObservationControl module.""" return run((ObservationControl, Observation), verbose = True, args = args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/recv.py b/devices/devices/recv.py index 6f1de6aedc9e6db463c2edcd7a1a8bdf3daf7c2e..18dcac5ea6ab2a365c7d2adc34c2020e37dcc07c 100644 --- a/devices/devices/recv.py +++ b/devices/devices/recv.py @@ -11,12 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango import DebugIt from tango.server import run, command @@ -253,7 +247,3 @@ def main(args=None, **kwargs): configure_logger() return run((RECV,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/sdp/sdp.py b/devices/devices/sdp/sdp.py index 16f6d89737742f1f3d475c619a60513e4579a115..a60b7604623dc47293d2687621b7b4f22c5cbf22 100644 --- a/devices/devices/sdp/sdp.py +++ b/devices/devices/sdp/sdp.py @@ -11,13 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango.server import device_property, attribute @@ -215,7 +208,3 @@ def main(args=None, **kwargs): configure_logger() return run((SDP,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/sdp/sst.py b/devices/devices/sdp/sst.py index 3b2f36236a841adb0511b284cbeb4a0fbc6ee296..acd3e7c66af0ee28adc9b05ceaddb8d01ece535b 100644 --- a/devices/devices/sdp/sst.py +++ b/devices/devices/sdp/sst.py @@ -11,13 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango.server import device_property, attribute @@ -110,7 +103,3 @@ def main(args=None, **kwargs): configure_logger() return run((SST,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/sdp/statistics.py b/devices/devices/sdp/statistics.py index 7d0b970b089ff29931bfc088f8b4b208d347402c..05ed2983717310c132d81f2d8da08a689f4c033e 100644 --- a/devices/devices/sdp/statistics.py +++ b/devices/devices/sdp/statistics.py @@ -11,13 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - from abc import ABCMeta, abstractmethod # PyTango imports diff --git a/devices/devices/sdp/statistics_packet.py b/devices/devices/sdp/statistics_packet.py index 9bac227071dfbdec9ea0b0fd1fa63fa36176a8d9..b68525039c49fdd14b2c47ab8eaadefc97154395 100644 --- a/devices/devices/sdp/statistics_packet.py +++ b/devices/devices/sdp/statistics_packet.py @@ -331,7 +331,7 @@ class BSTPacket(StatisticsPacket): return header -if __name__ == "__main__": +def main(args=None, **kwargs): # parse one packet from stdin import sys import pprint diff --git a/devices/devices/sdp/xst.py b/devices/devices/sdp/xst.py index caeeb5d3488369ecaf17208d1b33c2b7e6c76511..2ae5519a1de0ef62f518b6bb1bad0104fb3a7bb6 100644 --- a/devices/devices/sdp/xst.py +++ b/devices/devices/sdp/xst.py @@ -11,13 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango.server import device_property, attribute @@ -144,7 +137,3 @@ def main(args=None, **kwargs): configure_logger() return run((XST,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/devices/unb2.py b/devices/devices/unb2.py index 7c2575991605354de5bba608906fb9ea248f021b..71c92f49de53fda7e7e3b7c8f9d076092109c05b 100644 --- a/devices/devices/unb2.py +++ b/devices/devices/unb2.py @@ -11,12 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango.server import device_property, attribute @@ -225,8 +219,3 @@ def main(args=None, **kwargs): configure_logger() return run((UNB2,), args=args, **kwargs) - - -if __name__ == '__main__': - main() - diff --git a/devices/examples/HW_device_template.py b/devices/examples/HW_device_template.py index 6059733023c5ee8448369a706ea2be5c8fa6b840..c51538c9db16b0894a74a9f149a715ede94a8acb 100644 --- a/devices/examples/HW_device_template.py +++ b/devices/examples/HW_device_template.py @@ -9,12 +9,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango import AttrWriteType @@ -90,7 +84,3 @@ class HW_dev(hardware_device): def main(args=None, **kwargs): """Main function of the hardware device module.""" return run((HW_dev,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/examples/load_from_disk/ini_device.py b/devices/examples/load_from_disk/ini_device.py index 07b2f419ab6b4cd5d78eb84a66c3906e169da99d..8391d2823b68be53e56bd6f8b650b0f46362f429 100644 --- a/devices/examples/load_from_disk/ini_device.py +++ b/devices/examples/load_from_disk/ini_device.py @@ -9,13 +9,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango import AttrWriteType @@ -130,10 +123,5 @@ class ini_device(hardware_device): def main(args=None, **kwargs): write_ini_file("example.ini") - """Main function of the hardware device module.""" return run((ini_device,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/examples/snmp/snmp.py b/devices/examples/snmp/snmp.py index 2a912ce1443bbd8e83b662d4ed9764627d947943..9ef61ada5a88ae8b9a19447c5cdcf2b42c21149e 100644 --- a/devices/examples/snmp/snmp.py +++ b/devices/examples/snmp/snmp.py @@ -11,13 +11,6 @@ """ -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango.server import run from tango.server import device_property @@ -123,7 +116,3 @@ def main(args=None, **kwargs): configure_logger(logging.getLogger()) return run((SNMP,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/devices/setup.cfg b/devices/setup.cfg index 55b29032e6aefc1787179c054b701b7fc51323ac..26fb9e4fbb77178f32cfd9589904f8315bb17597 100644 --- a/devices/setup.cfg +++ b/devices/setup.cfg @@ -26,5 +26,20 @@ package_dir=./ [entry_points] console_scripts = - SDP = SDP:main - RECV = RECV:main + l2ss-docker-device = devices.docker_device:main + l2ss-observation = devices.observation:main + l2ss-observation-control = devices.observation_control:main + l2ss-receiver = devices.recv:main + l2ss-sdp = devices.sdp.sdp:main + l2ss-sst = devices.sdp.sst:main + l2ss-unb2 = devices.unb2:main + l2ss-xst = devices.sdp.xst:main + +# The following entry points should eventually be removed / replaced + l2ss-cold-start = toolkit.lts_cold_start:main + l2ss-hardware-device-template = examples.HW_device_template:main + l2ss-ini-device = examples.load_from_disc.ini_device:main + l2ss-parse-statistics-packet = devices.sdp.statistics_packet:main + l2ss-random-data = test.devices.random_data:main + l2ss-snmp = examples.snmp.snmp:main + l2ss-version = common.lofar_git:main diff --git a/devices/test/devices/random_data.py b/devices/test/devices/random_data.py index 43e1a037624a516f88d05d644fd86e23fab6baa8..51d7b269f99c814cb340dc9f0e8feb44f3393f94 100644 --- a/devices/test/devices/random_data.py +++ b/devices/test/devices/random_data.py @@ -7,13 +7,6 @@ # Distributed under the terms of the APACHE license. # See LICENSE.txt for more info. -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -parentdir = os.path.dirname(parentdir) -sys.path.append(parentdir) - # PyTango imports from tango import DevState from tango.server import run, Device, attribute, command @@ -497,6 +490,3 @@ def main(args = None, **kwargs): Main function of the RandomData module. """ return run((Random_Data,), args = args, **kwargs) - -if __name__ == '__main__': - main() diff --git a/devices/toolkit/lts_cold_start.py b/devices/toolkit/lts_cold_start.py index 47d3243e2064dc39fba8127e33da842acba19416..1158422d81361b321db48f4fed5fe497ba187a1d 100644 --- a/devices/toolkit/lts_cold_start.py +++ b/devices/toolkit/lts_cold_start.py @@ -2,12 +2,6 @@ import logging from time import sleep -# TODO(Corne): Remove sys.path.append hack once packaging is in place! -import os, sys -currentdir = os.path.dirname(os.path.realpath(__file__)) -parentdir = os.path.dirname(currentdir) -sys.path.append(parentdir) - from toolkit.startup import startup from toolkit.lofar2_config import configure_logging @@ -223,6 +217,6 @@ def lts_cold_start(): logging.info("LTS has been successfully started and configured.") +def main(args=None, **kwargs): -if __name__ == '__main__': - lts_cold_start() + return lts_cold_start() \ No newline at end of file