Author: tmckay
Date: 2012-02-17 00:27:09 +0000 (Fri, 17 Feb 2012)
New Revision: 5223
Modified:
trunk/cumin/python/cumin/model.py
trunk/sage/python/sage/aviary/aviaryoperations.py
trunk/sage/python/sage/qmf/qmfoperations.py
trunk/sage/python/sage/util.py
Log:
Change level to DEBUG from ERROR in CallSync when methods return non-zero status.
Add the name of the method being invoked and the data returned.
Messages will now be suppressed under INFO level logging. Any additional logging can
be done in the caller as needed.
BZ782539 (but applies generally, not just to HFS quota)
Modified: trunk/cumin/python/cumin/model.py
===================================================================
--- trunk/cumin/python/cumin/model.py 2012-02-16 16:58:34 UTC (rev 5222)
+++ trunk/cumin/python/cumin/model.py 2012-02-17 00:27:09 UTC (rev 5223)
@@ -663,7 +663,8 @@
def execute(self, remote, negotiator, groups, prepend=""):
default = {'Value': 0}
for group in groups:
- sync = self.syncs.add_sync(group, default)
+ sync = self.syncs.add_sync(group, default,
+ remote.get_raw_config.__name__)
try:
remote.get_raw_config(negotiator, prepend+group, sync.get_completion())
except Exception, e:
Modified: trunk/sage/python/sage/aviary/aviaryoperations.py
===================================================================
--- trunk/sage/python/sage/aviary/aviaryoperations.py 2012-02-16 16:58:34 UTC (rev 5222)
+++ trunk/sage/python/sage/aviary/aviaryoperations.py 2012-02-17 00:27:09 UTC (rev 5223)
@@ -628,19 +628,21 @@
return result
def _call_sync(self, process_results, meth, *meth_args, **meth_kwargs):
- # Common interface with QMF operations requires that a MethodResult
- # object (or something just like it) be returned for synchronous calls.
- # Might as well use the CallSync since the completion() routine
- # handles status semantics.
- sync = CallSync()
- try:
- result = meth(*meth_args, **meth_kwargs)
- except Exception, e:
- result = e
- cb_args = process_results(result)
- sync.get_completion()(*cb_args)
- return sync
+ # Common interface with QMF operations requires that a MethodResult
+ # object (or something just like it) be returned for synchronous calls.
+ # Might as well use the CallSync since the completion() routine
+ # handles status semantics.
+ # meth here is a suds.client.Method which has a name attr....
+ sync = CallSync(log, name=meth.method.name)
+ try:
+ result = meth(*meth_args, **meth_kwargs)
+ except Exception, e:
+ result = e
+ cb_args = process_results(result)
+ sync.get_completion()(*cb_args)
+ return sync
+
class AviaryOperations(_AviaryCommon, _AviaryJobMethods, _AviaryQueryMethods):
def __init__(self, name, datadir, job_servers, query_servers,
key="", cert="", root_cert="",
domain_verify=True):
Modified: trunk/sage/python/sage/qmf/qmfoperations.py
===================================================================
--- trunk/sage/python/sage/qmf/qmfoperations.py 2012-02-16 16:58:34 UTC (rev 5222)
+++ trunk/sage/python/sage/qmf/qmfoperations.py 2012-02-17 00:27:09 UTC (rev 5223)
@@ -236,7 +236,7 @@
self.session.call_method(cb, obj, meth, args)
else:
try:
- sync = CallSync(log, dflt)
+ sync = CallSync(log, dflt, meth)
self.session.call_method(sync.get_completion(),
obj, meth, args)
except Exception, e:
Modified: trunk/sage/python/sage/util.py
===================================================================
--- trunk/sage/python/sage/util.py 2012-02-16 16:58:34 UTC (rev 5222)
+++ trunk/sage/python/sage/util.py 2012-02-17 00:27:09 UTC (rev 5223)
@@ -32,10 +32,11 @@
of the 'completion'.
The 'done' method can be polled to determine if the operation has completed.
'''
- def __init__(self, log=None, default=None):
+ def __init__(self, log=None, default=None, name=""):
super(CallSync, self).__init__()
self.data = default
self.log = log
+ self.meth = name
def get_completion(self):
# Note that because of the way binding is done in Python,
@@ -45,6 +46,11 @@
# function without an object reference (the reference is hidden
# inside the bound function). Formally known as a "closure"
+ def log_debug(self, status, data):
+ if self.log:
+ self.log.debug("CallSync: method '%s' returned "\
+ "status '%s' and data '%s'" % (self.meth,
status, data))
+
def completion(*args):
# Callback argument formats come in two basic flavors in Cumin
# depending on the semantics of the async op:
@@ -52,12 +58,10 @@
# callback(result) where type(result) == Exception indicates
# a failure status
# Allow this general mechanism to handle both types.
-
data = None
if len(args) == 0:
# Just call it successful with no data
status = 0
-
elif len(args) == 1:
status = args[0]
if not isinstance(status, Exception):
@@ -72,9 +76,7 @@
self.got_data = True
else:
self.error = Exception(status)
- msg = "CallSync: call returned with status of %s" %
str(status)
- if self.log is not None:
- self.log.error(msg)
+ log_debug(self, status, data)
return completion
def done(self):
@@ -92,8 +94,8 @@
self.timeout = timeout
self.log = log
- def add_sync(self, key, default=None):
- sync = CallSync(self.log, default)
+ def add_sync(self, key, default=None, name=""):
+ sync = CallSync(self.log, default, name)
self.syncs[key] = sync
return sync