Author: justi9
Date: 2007-11-05 13:16:13 -0500 (Mon, 05 Nov 2007)
New Revision: 1236
Added:
mgmt/cumin/python/cumin/formats.py
Log:
This file was supposed to with change 1235.
Added: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py (rev 0)
+++ mgmt/cumin/python/cumin/formats.py 2007-11-05 18:16:13 UTC (rev 1236)
@@ -0,0 +1,45 @@
+from datetime import datetime
+
+from util import *
+
+def fmt_datetime(dtime):
+ return dtime.strftime("%d %b %Y %H:%M")
+
+def fmt_rate(value, unit1, unit2):
+ #return "%i <small>%s/%s</small>" % (value, unit1, unit2)
+ return "%i<small>/%s</small>" % (value, unit2)
+
+def fmt_predicate(predicate):
+ return predicate and "Yes" or "No"
+
+def fmt_status(errors, warnings, active=True):
+ count = errors + warnings
+
+ if count == 0:
+ number = " "
+ elif count > 9:
+ number = "+"
+ else:
+ number = str(count)
+
+ if active:
+ if count == 0:
+ class_ = "green"
+ else:
+ class_ = errors and "red" or "yellow"
+ else:
+ class_ = "inactive"
+
+ return "<div class=\"statuslight %s\">%s</div>" %
(class_, number)
+
+def fmt_none():
+ return "<span class=\"none\">None</span>"
+
+def fmt_link(href, content, class_=""):
+ return "<a href=\"%s\"%s>%s</a>" % \
+ (href, class_ and " class=\"%s\" " % class_ or "
", content)
+
+def fmt_olink(session, object, selected=False):
+ return fmt_link(session.marshal(),
+ getattr(object, "name", object),
+ selected and "selected")
Show replies by date