Author: eallen
Date: 2010-09-03 16:23:44 -0400 (Fri, 03 Sep 2010)
New Revision: 4254
Modified:
mgmt/newdata/cumin/python/cumin/grid/job.py
mgmt/newdata/cumin/python/cumin/grid/job.strings
mgmt/newdata/cumin/python/cumin/model.py
Log:
1st half of fix for BZ 628701: Provide feedback when job info isn't available
This will display the status message returned from the qmf call when GetAds fails on the
job details page.
Modified: mgmt/newdata/cumin/python/cumin/grid/job.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-03 19:41:52 UTC (rev 4253)
+++ mgmt/newdata/cumin/python/cumin/grid/job.py 2010-09-03 20:23:44 UTC (rev 4254)
@@ -107,7 +107,8 @@
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
- rows = self.process_results(results)
+ #TODO: handle error status and create an invok message
+ rows = self.process_results(results.data)
page = rows[first_index:last_index]
return page
@@ -127,7 +128,7 @@
def get_count(self, values):
submission = values["obj"]
results = self.app.model.get_submission_job_summaries(submission)
- return results and len(results) or 0
+ return results.data and len(results.data) or 0
class JobSelector(ObjectSelector):
def __init__(self, app, name, submission):
@@ -304,6 +305,7 @@
def do_get_items(self, session):
ad_list = self.items.get(session)
+ error = False
if not ad_list:
ad_list = list()
@@ -312,14 +314,16 @@
job_id = self.frame.job_id.get(session)
action = QmfCall(self.app, {'JobAd': {}})
- ads = action.execute(job_server, "GetJobAd",
job_id).data['JobAd']
+ results = action.execute(job_server, "GetJobAd", job_id)
+ error = results.error
+ ads = results.data['JobAd']
cls = self.app.model.job_meta_data
ad_list = [self.gen_item(x, ads[x], cls, dtype=self.get_type(ads[x])) \
for x in ads if not x.startswith("!!")]
self.items.set(session, ad_list)
- return ad_list
+ return ad_list, error
def get_type(self, value):
if isinstance(value, (int, long)):
@@ -409,6 +413,7 @@
super(JobAdsGroups, self).__init__(app, name)
self.group_tmpl = WidgetTemplate(self, "group_html")
+ self.error_tmpl = WidgetTemplate(self, "error_html")
def render_groups(self, session):
writer = Writer()
@@ -420,14 +425,20 @@
return group
def render_properties(self, session, group):
- items = self.parent.get_group_items(session, group)
+ items, error = self.parent.get_group_items(session, group)
writer = Writer()
- for item in items:
- self.parent.item_renderer.render(writer, session, item)
+ if error:
+ self.error_tmpl.render(writer, session, error.message)
+ else:
+ for item in items:
+ self.parent.item_renderer.render(writer, session, item)
return writer.to_string()
+ def render_error_msg(self, session, msg):
+ return msg
+
class JobAdsViewer(JobAdsSet):
def __init__(self, app, name):
super(JobAdsViewer, self).__init__(app, name)
@@ -453,7 +464,7 @@
def get_group_items(self, session, group):
group_items = list()
- items = self.do_get_items(session)
+ items, error = self.do_get_items(session)
for item in items:
if "property" in item:
property = item["property"]
@@ -463,7 +474,7 @@
if item_group == group:
group_items.append(item)
- return group_items
+ return group_items, error
class JobAdsEditor(JobAdsViewer, CuminForm):
def __init__(self, app, name):
@@ -485,10 +496,10 @@
dtype=ads[x]["type"], error=ads[x],
orig=ads[x]["orig"]) for x in ads]
- items = super(JobAdsEditor, self).do_get_items(session)
+ items, error = super(JobAdsEditor, self).do_get_items(session)
for item in items:
item["path"] = self.ads.path
- return items
+ return items, error
def process_cancel(self, session):
branch = session.branch()
@@ -618,7 +629,7 @@
id = self.frame.id.get(session)
scheduler = self.frame.get_scheduler(session, id)
- ads = self.do_get_items(session)
+ ads, error = self.do_get_items(session)
for ad in ads:
if ad['name'] == "Out":
out_file = ad['value']
Modified: mgmt/newdata/cumin/python/cumin/grid/job.strings
===================================================================
--- mgmt/newdata/cumin/python/cumin/grid/job.strings 2010-09-03 19:41:52 UTC (rev 4253)
+++ mgmt/newdata/cumin/python/cumin/grid/job.strings 2010-09-03 20:23:44 UTC (rev 4254)
@@ -22,6 +22,15 @@
{wait}
</div>
+[JobAdsGroups.css]
+div.ads_error {
+ margin: 1em;
+ padding: 1em;
+ background-color: FFEEEE;
+ border: 1px solid red;
+ color: 660000;
+}
+
[JobAdsGroups.html]
<div id="{id}" style="position:relative;">
{groups}
@@ -44,6 +53,8 @@
</tbody>
</table>
+[JobAdsGroups.error_html]
+<div class="ads_error">{error_msg}</div>
[JobAdsViewer.property_html]
<tr>
Modified: mgmt/newdata/cumin/python/cumin/model.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/model.py 2010-09-03 19:41:52 UTC (rev 4253)
+++ mgmt/newdata/cumin/python/cumin/model.py 2010-09-03 20:23:44 UTC (rev 4254)
@@ -104,12 +104,12 @@
self.job_summaries_by_submission[submission._id] = store
for i in range(5):
- if store.data:
+ if store.data or store.status:
break
sleep(1)
- return store.data
+ return store
finally:
self.lock.release()
@@ -1559,10 +1559,10 @@
class QmfException(Exception):
def __init__(self, value):
super(QmfException, self).__init__(value)
- self.value = value
+ self.message = value
def __str__(self):
- return repr(self.value)
+ return repr(self.message)
class QmfCall(object):
def __init__(self, app, default=None, timeout=5):
@@ -1903,6 +1903,7 @@
def __init__(self, model):
self.model = model
self.data = None
+ self.status = None
self.update_thread = self.UpdateThread(self)
@@ -1950,7 +1951,11 @@
def update(self, cursor):
def completion(status, data):
- self.data = data["Limits"]
+ self.status = status
+ try:
+ self.data = data["Limits"]
+ except KeyError:
+ pass
self.model.app.session.call_method \
(completion, self.negotiator, "GetLimits", ())
@@ -1968,7 +1973,11 @@
def update(self, cursor):
def completion(status, data):
- self.data = data["Jobs"]
+ self.status = status
+ try:
+ self.data = data["Jobs"]
+ except KeyError:
+ pass
self.model.app.session.call_method \
(completion, self.submission, "GetJobSummaries", ())