From 0496ddce2b4afc4449c34e270fc800b46e7c3390 Mon Sep 17 00:00:00 2001
From: Romain BRONES <romain.brones@synchrotron-soleil.fr>
Date: Fri, 20 Sep 2024 17:26:56 +0200
Subject: [PATCH] Fix function return

* Return True on success
* Decorator forward the return
---
 FofbTool/Configuration.py |  2 +-
 FofbTool/Operation.py     | 21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/FofbTool/Configuration.py b/FofbTool/Configuration.py
index f371cdf..cea7fef 100644
--- a/FofbTool/Configuration.py
+++ b/FofbTool/Configuration.py
@@ -18,7 +18,7 @@ logger = logging.getLogger("FofbTool")
 def trycatch_tango_devfailed(func):
     def inner_function(*args, **kwargs):
         try:
-            func(*args, **kwargs)
+            return func(*args, **kwargs)
         except tango.DevFailed as e:
             logger.error("DevFailed met during configuration")
             logger.debug(e)
diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py
index 1a57bff..d734b29 100644
--- a/FofbTool/Operation.py
+++ b/FofbTool/Operation.py
@@ -19,7 +19,7 @@ logger = logging.getLogger("FofbTool")
 def trycatch_tango_devfailed(func):
     def inner_function(*args, **kwargs):
         try:
-            func(*args, **kwargs)
+            return func(*args, **kwargs)
         except tango.DevFailed as e:
             logger.error("DevFailed met during operation")
             logger.debug(e)
@@ -155,6 +155,8 @@ def stop_ccn(node_tangopath, ccnif=[]):
             prx["ccnpack{}_control".format(n)] = False
             prx["ccnunpack{}_control".format(n)] = False
 
+    return True
+
 @trycatch_tango_devfailed
 def reset_ccn(node_tangopath, ccnif=[]):
     """
@@ -196,6 +198,8 @@ def reset_ccn(node_tangopath, ccnif=[]):
 
     ack_ccn(node_tangopath, ccnif)
 
+    return True
+
 @trycatch_tango_devfailed
 def start_ccn(node_tangopath, ccnif=[]):
     """
@@ -235,6 +239,8 @@ def start_ccn(node_tangopath, ccnif=[]):
             prx["ccnpack{}_control".format(n)] = 1
             prx["ccnunpack{}_control".format(n)] = 1
 
+    return True
+
 @trycatch_tango_devfailed
 def ack_ccn(node_tangopath, ccnif=[]):
     """
@@ -273,6 +279,8 @@ def ack_ccn(node_tangopath, ccnif=[]):
         prx["ccnpack{}_reset_error".format(n)] = False
         prx["ccnunpack{}_reset_error".format(n)] = False
 
+    return True
+
 ###################################################################################################
 #    OPERATIONS ON COMBPM
 ###################################################################################################
@@ -302,6 +310,8 @@ def stop_combpm(node_tangopath):
     prx["combpm_reset"] = 1
     prx["combpm_gt_control"] = 0x5
 
+    return True
+
 @trycatch_tango_devfailed
 def start_combpm(node_tangopath):
     """
@@ -321,7 +331,7 @@ def start_combpm(node_tangopath):
         prx.ping()
     except tango.DevFailed:
         logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath))
-        return None
+        return False
 
     logger.info("Starting ComBpm on {}".format(node_tangopath))
     prx["combpm_reset"] = 0
@@ -329,6 +339,7 @@ def start_combpm(node_tangopath):
     time.sleep(1)
     ack_combpm(node_tangopath)
 
+    return True
 
 @trycatch_tango_devfailed
 def ack_combpm(node_tangopath):
@@ -356,6 +367,7 @@ def ack_combpm(node_tangopath):
     time.sleep(1)
     prx["combpm_reset_error"] = False
 
+    return True
 
 ###################################################################################################
 #    OPERATIONS ON COMLBP
@@ -389,6 +401,8 @@ def stop_comlbp(node_tangopath):
     for n in range(4):
         prx["comlbp{}_control".format(n)] = 0
 
+    return True
+
 @trycatch_tango_devfailed
 def start_comlbp(node_tangopath):
     """
@@ -414,6 +428,8 @@ def start_comlbp(node_tangopath):
     for n in range(4):
         prx["comlbp{}_control".format(n)] = 0x10
 
+    return True
+
 
 @trycatch_tango_devfailed
 def reset_comlbp(node_tangopath):
@@ -444,6 +460,7 @@ def reset_comlbp(node_tangopath):
     for n in range(4):
         prx["comlbp{}_control".format(n)] = 0x0
 
+    return True
 
 
 ###################################################################################################
-- 
GitLab