Author: eallen
Date: 2008-12-12 11:03:08 -0500 (Fri, 12 Dec 2008)
New Revision: 2989
Modified:
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/pool.py
Log:
Fix exception on pool statistics page when there are no job records.
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2008-12-11 22:54:19 UTC (rev 2988)
+++ mgmt/trunk/cumin/python/cumin/model.py 2008-12-12 16:03:08 UTC (rev 2989)
@@ -1960,26 +1960,32 @@
class StatusStat(CuminStat):
def value_text(self, record):
- state = self.name
- value = record[state]
- return str(value)
+ if record:
+ state = self.name
+ value = record[state]
+ return str(value)
+ return ""
def rate_text(self, record):
return ""
class PercentStat(CuminStat):
def value_text(self, record):
- state = self.name
- value = record[state]
- return str(value)
+ if record:
+ state = self.name
+ value = record[state]
+ return str(value)
+ return ""
def rate_text(self, record):
- state = self.name
- value = record[state]
- total = record["total"]
- if total:
- percent = float(value) / float(total) * 100.0
- return total and "%2.2f" % percent or "-"
+ if record:
+ state = self.name
+ value = record[state]
+ total = record["total"]
+ if total:
+ percent = float(value) / float(total) * 100.0
+ return total and "%2.2f" % percent or "-"
+ return ""
class PoolSlotVisualization(SlotVisualization):
def __init__(self, cls, name):
@@ -2041,7 +2047,9 @@
def get_stat_record(self, session, pool):
cursor = self.itemset.get_items(session, pool)
- return self.itemset.cursor_to_rows(cursor)[0]
+ rows = self.itemset.cursor_to_rows(cursor)
+ if len(rows):
+ return rows[0]
class PoolStatus(CuminAction):
def __init__(self, cls, name):
@@ -2051,7 +2059,9 @@
def get_stat_record(self, session, pool):
cursor = self.itemset.get_items(session, pool)
- return self.itemset.cursor_to_rows(cursor)[0]
+ rows = self.itemset.cursor_to_rows(cursor)
+ if len(rows):
+ return rows[0]
class StatusPoolSlotSet(SlotStatSet):
def render_sql_where(self, session, pool):
Modified: mgmt/trunk/cumin/python/cumin/pool.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/pool.py 2008-12-11 22:54:19 UTC (rev 2988)
+++ mgmt/trunk/cumin/python/cumin/pool.py 2008-12-12 16:03:08 UTC (rev 2989)
@@ -499,5 +499,5 @@
action = self.app.model.pool.poolstatus
record = action.get_stat_record(session, pool)
- return "<div><span>%i</span> of
<span>%i</span> slots active</div>" % \
- (record["active"], record["all"])
+ return record and "<div><span>%i</span> of
<span>%i</span> slots active</div>" % \
+ (record["active"], record["all"]) or ""
Show replies by date