]> mj.ucw.cz Git - eval.git/commitdiff
Updates in status and pipeline debugging
authorTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 20:42:51 +0000 (22:42 +0200)
committerTomas Gavenciak <gavento@ucw.cz>
Sat, 18 Sep 2010 20:42:51 +0000 (22:42 +0200)
New eval.debug_dump_status()
Remove extra newlines from debug messages
Rename status.str_lines -> status.dump

t/moe/eval.py
t/moe/pipeline.py
t/moe/status.py

index f19df47366244f7ecf4b072b57f3f9243e7d1a3b..8c996e29a2111bb0974fa09dd2505958f7ad9cfa 100644 (file)
@@ -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):
index bffca80ffc408e4a900a9c1835b3fe504bdfc3d9..e8138200461b943dd0c7b5007f6b51180321d18f 100644 (file)
@@ -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))
 
index 518fb1bc5dcb2089f3496c920c354bd707e69221..320d7c9308d566d5082c0217462f05fd9a6fdbd8 100644 (file)
@@ -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):