From 3cabe7a8dff074cc0028f064b9ec21858ad2e6ae Mon Sep 17 00:00:00 2001 From: lukken <lukken@astron.nl> Date: Wed, 13 Oct 2021 16:50:50 +0000 Subject: [PATCH] L2SS-287: Fix some import paths and add boot device entrypoint --- docker-compose/device-boot.yml | 8 ++------ tangostationcontrol/setup.cfg | 1 + .../tangostationcontrol}/devices/boot.py | 20 ++++--------------- .../devices/hardware_device.py | 4 ++-- .../test/clients/test_opcua_client.py | 5 ++--- 5 files changed, 11 insertions(+), 27 deletions(-) rename {devices => tangostationcontrol/tangostationcontrol}/devices/boot.py (94%) diff --git a/docker-compose/device-boot.yml b/docker-compose/device-boot.yml index 58a9aa7df..1d89047b7 100644 --- a/docker-compose/device-boot.yml +++ b/docker-compose/device-boot.yml @@ -30,12 +30,8 @@ services: environment: - TANGO_HOST=${TANGO_HOST} entrypoint: - - /usr/local/bin/wait-for-it.sh - - ${TANGO_HOST} - - --timeout=30 - - --strict - - -- + - bin/start-ds.sh # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA # can't know about our Docker port forwarding - - python3 -u /opt/lofar/tango/devices/devices/boot.py LTS -v -ORBendPoint giop:tcp:0:5708 -ORBendPointPublish giop:tcp:${HOSTNAME}:5708 + - l2ss-boot LTS -v -ORBendPoint giop:tcp:0:5708 -ORBendPointPublish giop:tcp:${HOSTNAME}:5708 restart: unless-stopped diff --git a/tangostationcontrol/setup.cfg b/tangostationcontrol/setup.cfg index 3fea7a30c..529dde984 100644 --- a/tangostationcontrol/setup.cfg +++ b/tangostationcontrol/setup.cfg @@ -34,6 +34,7 @@ where=./ [options.entry_points] console_scripts = + l2ss-boot = tangostationcontrol.devices.boot:main l2ss-docker-device = tangostationcontrol.devices.docker_device:main l2ss-observation = tangostationcontrol.devices.observation:main l2ss-observation-control = tangostationcontrol.devices.observation_control:main diff --git a/devices/devices/boot.py b/tangostationcontrol/tangostationcontrol/devices/boot.py similarity index 94% rename from devices/devices/boot.py rename to tangostationcontrol/tangostationcontrol/devices/boot.py index fb8a6947c..6909e2bab 100644 --- a/devices/devices/boot.py +++ b/tangostationcontrol/tangostationcontrol/devices/boot.py @@ -13,12 +13,6 @@ Boots the rest of the station software. """ -# 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 @@ -29,10 +23,8 @@ import numpy from device_decorators import * -from clients.attribute_wrapper import attribute_wrapper -from devices.hardware_device import hardware_device -from common.lofar_logging import device_logging_to_python, log_exceptions -from common.lofar_git import get_version +from tangostationcontrol.devices.hardware_device import hardware_device +from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions import logging logger = logging.getLogger() @@ -285,13 +277,9 @@ class Boot(hardware_device): # Run server # ---------- def main(args=None, **kwargs): - """Main function of the RECV module.""" + """Main function of the Boot module.""" - from common.lofar_logging import configure_logger + from tangostationcontrol.common.lofar_logging import configure_logger configure_logger() return run((Boot,), args=args, **kwargs) - - -if __name__ == '__main__': - main() diff --git a/tangostationcontrol/tangostationcontrol/devices/hardware_device.py b/tangostationcontrol/tangostationcontrol/devices/hardware_device.py index bb4625826..72832a06b 100644 --- a/tangostationcontrol/tangostationcontrol/devices/hardware_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/hardware_device.py @@ -15,7 +15,7 @@ from abc import abstractmethod # PyTango imports from tango.server import Device, command, DeviceMeta, attribute -from tango import DevState, DebugIt, Attribute, DeviceProxy +from tango import AttrWriteType, DevState, DebugIt, Attribute, DeviceProxy import time import math @@ -23,7 +23,7 @@ import math # Additional import from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper from tangostationcontrol.common.lofar_logging import log_exceptions -from tangostationcontrol.common.lofar_git import get_version +from tangostationcontrol.common.lofar_version import get_version from tangostationcontrol.devices.abstract_device import AbstractDeviceMetas from tangostationcontrol.devices.device_decorators import only_in_states, fault_on_error diff --git a/tangostationcontrol/tangostationcontrol/test/clients/test_opcua_client.py b/tangostationcontrol/tangostationcontrol/test/clients/test_opcua_client.py index b1e730013..52398dca6 100644 --- a/tangostationcontrol/tangostationcontrol/test/clients/test_opcua_client.py +++ b/tangostationcontrol/tangostationcontrol/test/clients/test_opcua_client.py @@ -1,12 +1,11 @@ import numpy import asyncua import io -import asyncio +import asynctest from unittest import mock -from test import base -import asynctest + from tangostationcontrol.clients.opcua_client import OPCUAConnection from tangostationcontrol.clients import opcua_client -- GitLab