Permalink
Browse files

fixing weird bug in gmreader, more common classes for metric buckets

  • Loading branch information...
1 parent 8889b91 commit 314b93b8deb05589923a8169e7d94a526dce434a @davidbirdsong committed Dec 11, 2010
Showing with 30 additions and 0 deletions.
  1. +28 −0 common.py
  2. +2 −0 gmreader.py
View
28 common.py
@@ -0,0 +1,28 @@
+
+class MetricContainer(object):
+ def __init__(self):
+ self.vals = []
+
+ def get_metric(self):
+ pass
+
+ def append(self, v):
+ self.vals.append(v)
+
+class MaxContainer(MetricContainer):
+ def get_metric(self):
+ if not self.vals:
+ return 0
+ m = max(self.vals)
+ self.vals = []
+ return m
+
+class AverageContainer(MetricContainer):
+ def get_metric(self):
+ if not self.vals:
+ return 0
+ m = sum(self.vals) / len(self.vals)
+ self.vals = []
+ return m
+
+
View
2 gmreader.py
@@ -35,6 +35,8 @@ def _get_chunk(self):
if len(s) == 2:
data, self._buffer = s
else:
+ if type(s) == list:
+ s = ''.join(s)
data, self._buffer = '', s
return data

0 comments on commit 314b93b

Please sign in to comment.