From: Tomas Gavenciak Date: Sat, 18 Sep 2010 20:42:51 +0000 (+0200) Subject: Updates in status and pipeline debugging X-Git-Tag: python-dummy-working~5 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=293027e28828b13ec2c2428d661e7036acb6d34a;p=eval.git Updates in status and pipeline debugging New eval.debug_dump_status() Remove extra newlines from debug messages Rename status.str_lines -> status.dump --- diff --git a/t/moe/eval.py b/t/moe/eval.py index f19df47..8c996e2 100644 --- a/t/moe/eval.py +++ b/t/moe/eval.py @@ -88,8 +88,14 @@ class Eval: "Dumps pipeline `pipe` at level DDEBUG (only compiles the dump if main level low enough)." if self.log.level <= 5: self.log.ddebug('****** Pipeline %r dump: ******'%pipe.name) - self.log.ddebug(pipe.pipe) - self.log.ddebug(pipe.dump(prefix='* ')) + self.log.ddebug('\n'.join(pipe.dump(prefix='* '))) + self.log.ddebug('**************************') + + def debug_dump_status(self): + "Dumps status metadata at level DDEBUG (only compiles the dump if main level low enough)." + if self.log.level <= 5: + self.log.ddebug('****** Status dump: ******') + self.log.ddebug('\n'.join(self.status.dump(prefix='* '))) self.log.ddebug('**************************') def hook_init_dirs(e): diff --git a/t/moe/pipeline.py b/t/moe/pipeline.py index bffca80..e813820 100644 --- a/t/moe/pipeline.py +++ b/t/moe/pipeline.py @@ -38,9 +38,10 @@ class Pipeline: Debugging dump of the pipe. Returns a list of lines. """ - l=["%s >>> Pipeline %s\n" % (prefix, self.name)] + l=["%s >>> Pipeline %s" % (prefix, self.name)] for pri, name, fun in self.pipe: - l.append("%s% 3d %s, %s\n" % (prefix, pri, name, fun)) + l.append("%s% 3d %s, %s" % (prefix, pri, name, fun)) + return l def run(self, *args, **kwargs): self.index = 0 @@ -48,14 +49,14 @@ class Pipeline: while self.index < len(self.pipe): (pri,name,fun) = self.pipe[self.index] if pri >= min_pri: - self.e.log.debug("Pipeline %r:%d running: %s\n" % (self.name, pri, name)) + self.e.log.debug("Pipeline %r:%d running: %s" % (self.name, pri, name)) try: fun(*args, **kwargs) except MoeAbortPipeline, err: min_pri = self.skip_to else: - self.e.log.debug("Pipeline %r:d skipping: %s\n" % (self.name, pri, name)) + self.e.log.debug("Pipeline %r:d skipping: %s" % (self.name, pri, name)) self.index += 1 self.index = -1 - self.e.log.debug("Pipeline %r finished\n" % (self.name)) + self.e.log.debug("Pipeline %r finished" % (self.name)) diff --git a/t/moe/status.py b/t/moe/status.py index 518fb1b..320d7c9 100644 --- a/t/moe/status.py +++ b/t/moe/status.py @@ -37,19 +37,19 @@ class MoeStatus: m[k] = [m[k]] return m[k] - def str_lines(self, indent=""): - "Return a list of lines, `indent` is indent prefix." + def dump(self, prefix=""): + "Return a list of lines, `prefix` is indent prefix." l = [] for k,v in self.stat.items(): if type(v) == types.ListType: vals = v else: vals = [v] for w in vals: if isinstance(w, MoeStatus): - l.append("\t" * indent + k + "(\n") - l.extend(self.str_lines(indent+" ")) - l.append("\t" * indent + ")\n") + l.append(prefix + k + "(\n") + l.extend(self.str_lines(prefix+" ")) + l.append(prefix + ")\n") else: - l.append("\t" * indent + k + ":" + str(w) + "\n") + l.append(prefix + k + ":" + str(w) + "\n") return l def write(self, file=None, name=None):