Skip to content
Snippets Groups Projects
Commit 0496ddce authored by BRONES Romain's avatar BRONES Romain
Browse files

Fix function return

* Return True on success
* Decorator forward the return
parent fca988c7
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ logger = logging.getLogger("FofbTool") ...@@ -18,7 +18,7 @@ logger = logging.getLogger("FofbTool")
def trycatch_tango_devfailed(func): def trycatch_tango_devfailed(func):
def inner_function(*args, **kwargs): def inner_function(*args, **kwargs):
try: try:
func(*args, **kwargs) return func(*args, **kwargs)
except tango.DevFailed as e: except tango.DevFailed as e:
logger.error("DevFailed met during configuration") logger.error("DevFailed met during configuration")
logger.debug(e) logger.debug(e)
......
...@@ -19,7 +19,7 @@ logger = logging.getLogger("FofbTool") ...@@ -19,7 +19,7 @@ logger = logging.getLogger("FofbTool")
def trycatch_tango_devfailed(func): def trycatch_tango_devfailed(func):
def inner_function(*args, **kwargs): def inner_function(*args, **kwargs):
try: try:
func(*args, **kwargs) return func(*args, **kwargs)
except tango.DevFailed as e: except tango.DevFailed as e:
logger.error("DevFailed met during operation") logger.error("DevFailed met during operation")
logger.debug(e) logger.debug(e)
...@@ -155,6 +155,8 @@ def stop_ccn(node_tangopath, ccnif=[]): ...@@ -155,6 +155,8 @@ def stop_ccn(node_tangopath, ccnif=[]):
prx["ccnpack{}_control".format(n)] = False prx["ccnpack{}_control".format(n)] = False
prx["ccnunpack{}_control".format(n)] = False prx["ccnunpack{}_control".format(n)] = False
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def reset_ccn(node_tangopath, ccnif=[]): def reset_ccn(node_tangopath, ccnif=[]):
""" """
...@@ -196,6 +198,8 @@ def reset_ccn(node_tangopath, ccnif=[]): ...@@ -196,6 +198,8 @@ def reset_ccn(node_tangopath, ccnif=[]):
ack_ccn(node_tangopath, ccnif) ack_ccn(node_tangopath, ccnif)
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def start_ccn(node_tangopath, ccnif=[]): def start_ccn(node_tangopath, ccnif=[]):
""" """
...@@ -235,6 +239,8 @@ def start_ccn(node_tangopath, ccnif=[]): ...@@ -235,6 +239,8 @@ def start_ccn(node_tangopath, ccnif=[]):
prx["ccnpack{}_control".format(n)] = 1 prx["ccnpack{}_control".format(n)] = 1
prx["ccnunpack{}_control".format(n)] = 1 prx["ccnunpack{}_control".format(n)] = 1
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def ack_ccn(node_tangopath, ccnif=[]): def ack_ccn(node_tangopath, ccnif=[]):
""" """
...@@ -273,6 +279,8 @@ def ack_ccn(node_tangopath, ccnif=[]): ...@@ -273,6 +279,8 @@ def ack_ccn(node_tangopath, ccnif=[]):
prx["ccnpack{}_reset_error".format(n)] = False prx["ccnpack{}_reset_error".format(n)] = False
prx["ccnunpack{}_reset_error".format(n)] = False prx["ccnunpack{}_reset_error".format(n)] = False
return True
################################################################################################### ###################################################################################################
# OPERATIONS ON COMBPM # OPERATIONS ON COMBPM
################################################################################################### ###################################################################################################
...@@ -302,6 +310,8 @@ def stop_combpm(node_tangopath): ...@@ -302,6 +310,8 @@ def stop_combpm(node_tangopath):
prx["combpm_reset"] = 1 prx["combpm_reset"] = 1
prx["combpm_gt_control"] = 0x5 prx["combpm_gt_control"] = 0x5
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def start_combpm(node_tangopath): def start_combpm(node_tangopath):
""" """
...@@ -321,7 +331,7 @@ def start_combpm(node_tangopath): ...@@ -321,7 +331,7 @@ def start_combpm(node_tangopath):
prx.ping() prx.ping()
except tango.DevFailed: except tango.DevFailed:
logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) 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)) logger.info("Starting ComBpm on {}".format(node_tangopath))
prx["combpm_reset"] = 0 prx["combpm_reset"] = 0
...@@ -329,6 +339,7 @@ def start_combpm(node_tangopath): ...@@ -329,6 +339,7 @@ def start_combpm(node_tangopath):
time.sleep(1) time.sleep(1)
ack_combpm(node_tangopath) ack_combpm(node_tangopath)
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def ack_combpm(node_tangopath): def ack_combpm(node_tangopath):
...@@ -356,6 +367,7 @@ def ack_combpm(node_tangopath): ...@@ -356,6 +367,7 @@ def ack_combpm(node_tangopath):
time.sleep(1) time.sleep(1)
prx["combpm_reset_error"] = False prx["combpm_reset_error"] = False
return True
################################################################################################### ###################################################################################################
# OPERATIONS ON COMLBP # OPERATIONS ON COMLBP
...@@ -389,6 +401,8 @@ def stop_comlbp(node_tangopath): ...@@ -389,6 +401,8 @@ def stop_comlbp(node_tangopath):
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0 prx["comlbp{}_control".format(n)] = 0
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def start_comlbp(node_tangopath): def start_comlbp(node_tangopath):
""" """
...@@ -414,6 +428,8 @@ def start_comlbp(node_tangopath): ...@@ -414,6 +428,8 @@ def start_comlbp(node_tangopath):
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0x10 prx["comlbp{}_control".format(n)] = 0x10
return True
@trycatch_tango_devfailed @trycatch_tango_devfailed
def reset_comlbp(node_tangopath): def reset_comlbp(node_tangopath):
...@@ -444,6 +460,7 @@ def reset_comlbp(node_tangopath): ...@@ -444,6 +460,7 @@ def reset_comlbp(node_tangopath):
for n in range(4): for n in range(4):
prx["comlbp{}_control".format(n)] = 0x0 prx["comlbp{}_control".format(n)] = 0x0
return True
################################################################################################### ###################################################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment