def render_formatted_value(self, session, item, value, escape=False): # Since this routine delegates to CuminStatistic which may produce # xml for None values, we need to handle escaping here and in # CuminStatistic def fmt_b(value): return value is not None and fmt_bytes(value) or None def fmt_kb(value): return value is not None and fmt_bytes(value * 1024) or None def fmt_mb(value): return value is not None and fmt_bytes(value * 1024 * 1024) or None try: format = self.get_item_unit(session, item) if format: if format == "MiB": return fmt_mb(value) elif format == "KiB": return fmt_kb(value) except: pass return CuminStatistic.fmt_value(value, escape)
def render_item_value(self, session, item): stat, value = item if stat.name in self.fmt_as_bytes: return fmt_bytes(value*1024) return CuminStatistic.fmt_value(value, escape=True)