r5460 - in branches/tmckay: cumin/python/cumin/grid sage/python/sage
tmckay at fedoraproject.org
tmckay at fedoraproject.org
Mon Sep 10 18:08:15 UTC 2012
Author: tmckay
Date: 2012-09-10 18:08:13 +0000 (Mon, 10 Sep 2012)
New Revision: 5460
Modified:
branches/tmckay/cumin/python/cumin/grid/job.py
branches/tmckay/cumin/python/cumin/grid/limit.py
branches/tmckay/cumin/python/cumin/grid/negotiator.py
branches/tmckay/sage/python/sage/util.py
Log:
Fix up error handling for remote reconfig() calls
Modified: branches/tmckay/cumin/python/cumin/grid/job.py
===================================================================
--- branches/tmckay/cumin/python/cumin/grid/job.py 2012-09-07 16:02:45 UTC (rev 5459)
+++ branches/tmckay/cumin/python/cumin/grid/job.py 2012-09-10 18:08:13 UTC (rev 5460)
@@ -20,16 +20,11 @@
from wooly.widgets import ModeSet, PropertySet, TemplateRenderer, Notice
from wooly.template import WidgetTemplate
from wooly.parameters import ListParameter, IntegerParameter, DictParameter
+from sage.util import ErrorResult
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.job")
-class ErrorResult(object):
- def __init__(self, err):
- self.status = "Failed"
- self.error = err
- self.data = None
-
class SubmissionObjectFrame(ObjectFrame):
def get_submission_sched(self, session, id):
submission = self.get_object(session, id)
Modified: branches/tmckay/cumin/python/cumin/grid/limit.py
===================================================================
--- branches/tmckay/cumin/python/cumin/grid/limit.py 2012-09-07 16:02:45 UTC (rev 5459)
+++ branches/tmckay/cumin/python/cumin/grid/limit.py 2012-09-10 18:08:13 UTC (rev 5460)
@@ -151,8 +151,12 @@
def do_invoke(self, invoc, negotiator, limit_name, limit_max):
def do_reconfig(self, invoc, negotiator):
- call_async(invoc.make_callback(),
- self.app.remote.reconfig, negotiator)
+ cb = invoc.make_callback()
+ try:
+ call_async(invoc.make_callback(),
+ self.app.remote.reconfig, negotiator)
+ except Exception, e:
+ cb(e)
# Use a custom callback so we can launch reconfig() as a
# second asynchronous task if set_limit succeeds and let that
Modified: branches/tmckay/cumin/python/cumin/grid/negotiator.py
===================================================================
--- branches/tmckay/cumin/python/cumin/grid/negotiator.py 2012-09-07 16:02:45 UTC (rev 5459)
+++ branches/tmckay/cumin/python/cumin/grid/negotiator.py 2012-09-10 18:08:13 UTC (rev 5460)
@@ -10,7 +10,7 @@
from wooly.parameters import ListParameter, StringParameter
from wooly.template import WidgetTemplate
from cumin.stat import StatFlashChart
-from sage.util import call_async
+from sage.util import call_async, ErrorResult
strings = StringCatalog(__file__)
log = logging.getLogger("cumin.grid.negotiator")
@@ -243,6 +243,8 @@
self.buttons = list()
+ self.reconfig_task = NegotiatorReconfigTask(self.app, self.task.frame)
+
#self.defer_enabled = True
def render_group_name(self, session, group):
@@ -381,7 +383,7 @@
changed = True
if changed:
- self.task.reconfig(negotiator)
+ self.reconfig_task.invoke(session, negotiator)
self.app.model.update_negotiator_config_value(negotiator)
def process_submit(self, session):
@@ -430,6 +432,13 @@
def render_height(self, session):
return 210
+class NegotiatorReconfigTask(ObjectFrameTask):
+ def do_invoke(self, invoc, negotiator):
+ invoc.description = "Reconfig"
+ result = self.app.remote.reconfig(negotiator)
+ invoc.status_code = result.status
+ invoc.end()
+
class NegotiatorGroupTask(ObjectFrameTask):
def do_exit(self, session):
self.app.main_page.main.grid.view.show(session)
@@ -447,9 +456,6 @@
invoc.status_code = result.status
invoc.end()
- def reconfig(self, negotiator):
- self.app.remote.reconfig(negotiator)
-
class NegotiatorEditDynamicQuota(NegotiatorGroupTask):
def __init__(self, app, frame):
super(NegotiatorEditDynamicQuota, self).__init__(app, frame)
Modified: branches/tmckay/sage/python/sage/util.py
===================================================================
--- branches/tmckay/sage/python/sage/util.py 2012-09-07 16:02:45 UTC (rev 5459)
+++ branches/tmckay/sage/python/sage/util.py 2012-09-10 18:08:13 UTC (rev 5460)
@@ -13,7 +13,7 @@
or a descendent of this class.
self.data will contain any data returned from the call
self.got_data will be True if the call succeeded
- self.error will be True if the call raised an error
+ self.error will evaluate to True if the call raised an error
self.status will be 'OK' or 0 if the call succeeded and
may contain explanatory text otherwise
'''
@@ -23,6 +23,19 @@
self.error = False
self.status = None
+class ErrorResult(MethodResult):
+ '''
+ Simple error result type.
+ This is handy when enveloping code knows there
+ is some error condition and needs to send back
+ an error result as if the method returned a failed status.
+ '''
+ def __init__(self, err):
+ super(ErrorResult, self).__init__()
+
+ self.error = err
+ self.status = "Failed"
+
class CallSync(MethodResult):
'''
General callback object for asynchronous operations.
More information about the cumin-developers
mailing list