summaryrefslogtreecommitdiffstats
path: root/src/software/lmi
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2013-10-14 09:43:13 +0200
committerMichal Minar <miminar@redhat.com>2013-10-18 11:27:27 +0200
commit8b7c781b7f6f427d7b78e5cd4ca42e513697f1d3 (patch)
tree0b3342ab0c4bf65b2f679c9f5f5f5c676ac52acd /src/software/lmi
parent1c81ff825046681ae0d9f7a27da33e7abed8bf96 (diff)
downloadopenlmi-providers-8b7c781b7f6f427d7b78e5cd4ca42e513697f1d3.tar.gz
openlmi-providers-8b7c781b7f6f427d7b78e5cd4ca42e513697f1d3.tar.xz
openlmi-providers-8b7c781b7f6f427d7b78e5cd4ca42e513697f1d3.zip
software: decorate function correctly
Preserve the attributes of function being wrapped when creating a wrapper in decorator. Also removed redundant logging.
Diffstat (limited to 'src/software/lmi')
-rw-r--r--src/software/lmi/software/yumdb/__init__.py3
-rw-r--r--src/software/lmi/software/yumdb/jobmanager.py3
-rw-r--r--src/software/lmi/software/yumdb/process.py8
3 files changed, 8 insertions, 6 deletions
diff --git a/src/software/lmi/software/yumdb/__init__.py b/src/software/lmi/software/yumdb/__init__.py
index 6992c29..85f809e 100644
--- a/src/software/lmi/software/yumdb/__init__.py
+++ b/src/software/lmi/software/yumdb/__init__.py
@@ -33,6 +33,7 @@ only accessor to yum api.
"""
import errno
+from functools import wraps
import inspect
import os
import re
@@ -113,6 +114,7 @@ def job_request(async=False):
Decorator that just logs the method's call and returns job's result.
"""
logged = cmpi_logging.trace_method(method, 2)
+ @wraps(method)
def _new_func(self, *args, **kwargs):
"""Wrapper for YumDB's method."""
return logged(self, *args, **kwargs).result_data
@@ -124,6 +126,7 @@ def job_request(async=False):
the method returns jobid. Job's result is returned otherwise.
"""
logged = cmpi_logging.trace_method(method, 2)
+ @wraps(method)
def _new_func(self, *args, **kwargs):
"""Wrapper for YumDB's method."""
callargs = inspect.getcallargs(method, self, *args, **kwargs)
diff --git a/src/software/lmi/software/yumdb/jobmanager.py b/src/software/lmi/software/yumdb/jobmanager.py
index 1b986bd..50c3345 100644
--- a/src/software/lmi/software/yumdb/jobmanager.py
+++ b/src/software/lmi/software/yumdb/jobmanager.py
@@ -30,6 +30,7 @@ Before using ``JobManager``, module's variable ``JOB_TO_MODEL`` should
be set to callable taking ``YumJob`` instance and returning its matching
CIM abstraction instance.
"""
+from functools import wraps
import heapq
import inspect
import logging
@@ -71,6 +72,7 @@ def job_handler(job_from_target=True):
"""
logged = cmpi_logging.trace_method(method, frame_level=2)
+ @wraps(method)
def _new_func(self, *args, **kwargs):
"""Wrapper around method."""
if 'target' in kwargs:
@@ -87,6 +89,7 @@ def job_handler(job_from_target=True):
def _simple_wrapper(method):
"""Just locks the job lock."""
+ @wraps(method)
def _new_func(self, *args, **kwargs):
"""Wrapper around method."""
with self._job_lock: #pylint: disable=W0212
diff --git a/src/software/lmi/software/yumdb/process.py b/src/software/lmi/software/yumdb/process.py
index 29355d4..d38d198 100644
--- a/src/software/lmi/software/yumdb/process.py
+++ b/src/software/lmi/software/yumdb/process.py
@@ -24,6 +24,7 @@ Module holding the code of separate process accessing the YUM API.
"""
import errno
+from functools import wraps
from itertools import chain
import logging
from multiprocessing import Process
@@ -178,6 +179,7 @@ def _needs_database(method):
no session is active.
"""
logged = cmpi_logging.trace_method(method, frame_level=2)
+ @wraps(method)
def _wrapper(self, *args, **kwargs):
"""
Wrapper for the job handler method.
@@ -189,13 +191,7 @@ def _needs_database(method):
created_session = True
self._lock_database() #pylint: disable=W0212
try:
- LOG.debug("calling job handler %s with args=(%s)",
- method.__name__,
- ", ".join(chain(
- (str(a) for a in args),
- ("%s=%s"%(k, str(v)) for k, v in kwargs.items()))))
result = logged(self, *args, **kwargs)
- LOG.debug("job handler %s finished", method.__name__)
return result
finally:
if created_session is True: #pylint: disable=W0212