[rhmessaging-commits] rhmessaging commits: r1441 - in mgmt: notes and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Dec 7 11:34:34 EST 2007
Author: justi9
Date: 2007-12-07 11:34:34 -0500 (Fri, 07 Dec 2007)
New Revision: 1441
Modified:
mgmt/cumin/python/cumin/charts.py
mgmt/cumin/python/cumin/formats.py
mgmt/cumin/python/cumin/model.py
mgmt/notes/justin-todo.txt
Log:
It's not as nice as I'd like, but it's a start. Adds x axis
timestamps to charts.
Also adds a fmt_duration_brief function for compact rendering of
durations.
Modified: mgmt/cumin/python/cumin/charts.py
===================================================================
--- mgmt/cumin/python/cumin/charts.py 2007-12-06 19:27:01 UTC (rev 1440)
+++ mgmt/cumin/python/cumin/charts.py 2007-12-07 16:34:34 UTC (rev 1441)
@@ -1,6 +1,9 @@
from cairo import *
from random import random
+from time import mktime
+from formats import *
+
class LineChart(object):
def __init__(self, width, height):
self.width = width
@@ -37,25 +40,29 @@
cr.stroke()
- def plot_x_axis(self, values, interval=40):
+ def plot_x_axis(self, values, interval=50):
if values:
cr = Context(self.surface)
cr.set_line_width(0.2)
cr.set_source_rgb(0.8, 0.8, 0.8)
- zero = values[0]
- xs = range(self.width, 0 - interval, -interval)
+ if values:
+ tzero = mktime(values[0].timetuple())
- for x in xs:
- cr.move_to(x, 0)
- cr.line_to(x, self.height + 10)
+ xs = range(self.width, 0 - interval, -interval)
- # XXX
- #index = 120 - x // self.value_interval
- #value = values[index] - zero
- #print x, index, value
- #cr.show_text(value.strftime("%S"))
+ for x, i in zip(xs, range(0, 120)):
+ cr.move_to(x, 0)
+ cr.line_to(x, self.height + 10)
+ if i % 4 == 0:
+ index = 120 - x // self.value_interval
+
+ if len(values) > index:
+ value = mktime(values[index].timetuple()) - tzero
+
+ cr.show_text(fmt_duration_brief(value))
+
cr.stroke()
def plot_y_axis(self):
Modified: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py 2007-12-06 19:27:01 UTC (rev 1440)
+++ mgmt/cumin/python/cumin/formats.py 2007-12-07 16:34:34 UTC (rev 1441)
@@ -12,6 +12,9 @@
def fmt_duration(secs):
"""Takes a duration in seconds, which can be a float"""
+ sign = secs < 0 and " ago" or ""
+ secs = abs(secs)
+
elems = list()
periods = (86400, 3600, 60, 1)
units = ("day", "hour", "min", "sec")
@@ -22,12 +25,34 @@
elems.append("%i %s%s" % (count, unit, ess(count)))
if len(elems) == 2:
- return ", ".join(elems)
+ return ", ".join(elems) + sign
secs = secs % period
- return ", ".join(elems)
+ return ", ".join(elems) + sign
+def fmt_duration_brief(secs):
+ """Takes a duration in seconds, which can be a float"""
+
+ sign = secs < 0 and "-" or ""
+ secs = abs(secs)
+
+ elems = list()
+ periods = (86400, 3600, 60, 1)
+ units = ("d", "h", "m", "s")
+
+ for period, unit in zip(periods, units):
+ if secs > period:
+ count = secs // period
+ elems.append("%i%s" % (count, unit))
+
+ if len(elems) == 2:
+ return sign + "".join(elems)
+
+ secs = secs % period
+
+ return sign + "".join(elems)
+
def fmt_rate(value, unit1, unit2):
#return "%i <small>%s/%s</small>" % (value, unit1, unit2)
return "%i<small>/%s</small>" % (nvl(value, 0), unit2)
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-12-06 19:27:01 UTC (rev 1440)
+++ mgmt/cumin/python/cumin/model.py 2007-12-07 16:34:34 UTC (rev 1441)
@@ -70,6 +70,7 @@
name = self.cumin_class.name
cls = self.cumin_class.mint_stats_class
+ # XXX get rid of this
stats = cls.select("%s_id = %i" % (name, object.id),
orderBy="-id")[:limit]
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-06 19:27:01 UTC (rev 1440)
+++ mgmt/notes/justin-todo.txt 2007-12-07 16:34:34 UTC (rev 1441)
@@ -10,8 +10,6 @@
* Add legends to charts
- * Add x and y axis values to charts
-
* Prepare for journal stats on queue
* Make sure queue accel. a proper rate value
More information about the rhmessaging-commits
mailing list