Skip to content
Snippets Groups Projects
Commit 61e5c959 authored by Jan David Mol's avatar Jan David Mol
Browse files

Use () syntax behind wrappers for consistency with Tango/SKA wrappers

parent 1cc99173
No related branches found
No related tags found
1 merge request!7Resolve #2021 "03 16 branched from master elk stack"
...@@ -61,7 +61,7 @@ class hardware_device(Device): ...@@ -61,7 +61,7 @@ class hardware_device(Device):
self.value_dict = {i: i.initial_value() for i in self.attr_list()} self.value_dict = {i: i.initial_value() for i in self.attr_list()}
@log_exceptions @log_exceptions()
def init_device(self): def init_device(self):
""" Instantiates the device in the OFF state. """ """ Instantiates the device in the OFF state. """
...@@ -165,7 +165,7 @@ class hardware_device(Device): ...@@ -165,7 +165,7 @@ class hardware_device(Device):
"""Method always executed before any TANGO command is executed.""" """Method always executed before any TANGO command is executed."""
pass pass
@log_exceptions @log_exceptions()
def delete_device(self): def delete_device(self):
"""Hook to delete resources allocated in init_device. """Hook to delete resources allocated in init_device.
......
...@@ -54,15 +54,18 @@ def device_logging_to_python(log_extra: dict = None): ...@@ -54,15 +54,18 @@ def device_logging_to_python(log_extra: dict = None):
return inner return inner
def log_exceptions(func): def log_exceptions():
""" Decorator that logs all exceptions that the function raises. """ """ Decorator that logs all exceptions that the function raises. """
@wraps(func) def wrapper(func):
def inner(self, *args, **kwargs): @wraps(func)
try: def inner(self, *args, **kwargs):
return func(self, *args, **kwargs) try:
except Exception as e: return func(self, *args, **kwargs)
self.error_stream("Caught exception: %s: %s", e.__class__.__name__, e, exc_info=1) except Exception as e:
raise e self.error_stream("Caught exception: %s: %s", e.__class__.__name__, e, exc_info=1)
raise e
return inner return inner
return wrapper
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