Skip to content
Snippets Groups Projects
Unverified Commit 2d711491 authored by SKAJohanVenter's avatar SKAJohanVenter
Browse files

SAR-276 Lint fixes. Simplified task_result

parent b9dc83f4
No related branches found
No related tags found
No related merge requests found
......@@ -433,7 +433,6 @@ class SKABaseDevice(Device):
device.set_change_event("status", True, True)
device.set_archive_event("status", True, True)
# Long running command attributes
device.set_change_event("longRunningCommandsInQueue", True, True)
device.set_archive_event("longRunningCommandsInQueue", True, True)
device.set_change_event("longRunningCommandIDsInQueue", True, True)
......@@ -1162,9 +1161,7 @@ class SKABaseDevice(Device):
:return: ID, ResultCode, result.
"""
if not self.component_manager.task_result:
return []
return list(self.component_manager.task_result)
return self.component_manager.task_result
# --------
# Commands
......
......@@ -164,8 +164,6 @@ class BaseComponentManager:
:return: ID, ResultCode, result.
"""
if not self.queue_manager.task_result:
return []
return list(self.queue_manager.task_result)
def off(self):
......
......@@ -116,7 +116,7 @@ from uuid import uuid4
from queue import Empty, Queue
from datetime import datetime
from threading import Event
from typing import Any, Callable, Dict, Optional, Tuple
from typing import Any, Callable, Dict, Optional, Tuple, Union
import tango
......@@ -442,7 +442,7 @@ class QueueManager:
self._property_update_lock = threading.Lock()
self._logger = logger if logger else logging.getLogger(__name__)
self._task_result: Optional[Tuple[str, str, str]] = None
self._task_result: Union[Tuple[str, str, str], Tuple[()]] = ()
self._tasks_in_queue: Dict[str, str] = {} # unique_id, task_name
self._task_status: Dict[str, str] = {} # unique_id, status
self._threads = []
......@@ -476,7 +476,7 @@ class QueueManager:
return self._work_queue.full()
@property
def task_result(self) -> Tuple[str, str, str]:
def task_result(self) -> Union[Tuple[str, str, str], Tuple[()]]:
"""Return the last task result.
:return: Last task result
......
......@@ -564,8 +564,7 @@ class StoredCommand:
class LongRunningDeviceInterface:
"""This class is a convenience class to be used by clients of devices
that implement long running commands.
"""This class is a convenience class for long running command devices.
The intent of this class is that clients should not have to keep
track of command IDs or the various attributes
......@@ -614,7 +613,7 @@ class LongRunningDeviceInterface:
)
def push_event(self, ev: EventData):
"""Handles the attribute change events.
"""Handle the attribute change events.
For every event that comes in:
......
......@@ -225,6 +225,7 @@ def logger():
@pytest.fixture(scope="module")
def devices_to_test(request):
"""Fixture for devices to test."""
yield getattr(request.module, "devices_to_test")
......@@ -233,7 +234,8 @@ def multi_device_tango_context(
mocker, devices_to_test # pylint: disable=redefined-outer-name
):
"""
Creates and returns a TANGO MultiDeviceTestContext object, with
Create and return a TANGO MultiDeviceTestContext object.
tango.DeviceProxy patched to work around a name-resolving issue.
"""
......@@ -251,9 +253,7 @@ def multi_device_tango_context(
mocker.patch(
"tango.DeviceProxy",
wraps=lambda fqdn, *args, **kwargs: _DeviceProxy(
"tango://{0}:{1}/{2}#dbase=no".format(HOST, PORT, fqdn),
*args,
**kwargs
"tango://{0}:{1}/{2}#dbase=no".format(HOST, PORT, fqdn), *args, **kwargs
),
)
with MultiDeviceTestContext(
......
......@@ -61,7 +61,9 @@ class LongRunningCommandBaseTestDevice(SKABaseDevice):
self.register_command_object(
"TestProgressWithArgs",
self.TestProgressWithArgsCommand(self.component_manager, logger=self.logger),
self.TestProgressWithArgsCommand(
self.component_manager, logger=self.logger
),
)
class ShortCommand(ResponseCommand):
......@@ -194,8 +196,7 @@ class LongRunningCommandBaseTestDevice(SKABaseDevice):
def do(self):
"""Execute something on the long running device."""
interface = self.target.lrc_device_interface
interface.execute_long_running_command(
"TestProgress", 0.5, None)
interface.execute_long_running_command("TestProgress", 0.5, None)
self.logger.info("In TestProgressNoArgsCommand")
return (ResultCode.OK, "Done TestProgressNoArgsCommand")
......@@ -216,8 +217,7 @@ class LongRunningCommandBaseTestDevice(SKABaseDevice):
def do(self, argin):
"""Execute something on the long running device."""
interface = self.target.lrc_device_interface
interface.execute_long_running_command(
"TestProgress", argin, None)
interface.execute_long_running_command("TestProgress", argin, None)
self.logger.info("In TestProgressWithArgs")
return (ResultCode.OK, "Done TestProgressWithArgsCommand")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment