From 840b88e7639594e11d6edd9fb0aebcbe6783550d Mon Sep 17 00:00:00 2001
From: Andrea Parenti <andrea.parenti@xfel.eu>
Date: Tue, 21 Jan 2025 14:14:37 +0100
Subject: [PATCH] Refactor / 7

---
 src/tempus/Tempus.py | 42 ------------------------------------------
 1 file changed, 42 deletions(-)

diff --git a/src/tempus/Tempus.py b/src/tempus/Tempus.py
index 3003c0d..dd0842e 100644
--- a/src/tempus/Tempus.py
+++ b/src/tempus/Tempus.py
@@ -12,7 +12,6 @@
 # Karabo itself is licensed under the terms of the MPL 2.0 license.
 #############################################################################
 
-from asyncio import create_subprocess_exec, subprocess  # CancelledError
 from time import time
 
 from paramiko.client import SSHClient
@@ -65,7 +64,6 @@ class NetworkStats(Configurable):
 class Tempus(Device):
     __version__ = deviceVersion
 
-    COMMAND = "ssh"
     APP_DIR = "/home/timepix4/application"
     SCRIPT_DIR = "/home/timepix4/master"
     CFG_DIR = "/home/timepix4/master/control/config"
@@ -126,46 +124,6 @@ class Tempus(Device):
             last_time = actual_time
             await sleep(1)
 
-    async def _execute_command(self, cmnd, end_state, end_status):
-        """Execute the specified command on the controller and set the device
-        state and status.
-
-        :param cmnd: the command to be executed on the controller, e.g.
-        ["ssh", "root@169.254.1.5", "python3",
-        "/home/timepix4/master/karabo_init.py"]
-        :param end_state: the end state in case the command is successful, e.g.
-        State.ON
-        :param end_status: the end status in case the command is successful
-        """
-        try:
-            self.logger.debug(f"Sending command: {cmnd}")
-            process = await create_subprocess_exec(
-                *cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-
-            stdout, stderr = await process.communicate()
-            if stdout:
-                self.logger.info(stdout.decode())
-            if stderr:
-                clean_sterr = self.clean_stderr(stderr.decode())
-                if clean_sterr:
-                    raise Exception(clean_sterr)
-
-            self.state = end_state
-            self.status = end_status
-            self.commandLog = (
-                f"Successfully executed command:\n{' '.join(cmnd)}\n\n"
-                f"{stdout.decode()}")
-
-        except Exception as e:
-            self.logger.error(e)
-            self.state = State.ERROR
-            self.status = str(e)
-            self.commandLog = (
-                f"Error while executing command :\n{' '.join(cmnd)}\n\n"
-                f"{e}")
-
-        self.background_task = None
-
     def clean_stderr(self, msg):
         """Strip harmless lines from stderr"""
         clean_msg = ""
-- 
GitLab