Source

detox-patches / report-activity-group

Full commit
# HG changeset patch
# Parent f9f8c0107cc160444cc32e303bff3939941d2837
have reporting lines group envs by activity

diff --git a/detox/proc.py b/detox/proc.py
--- a/detox/proc.py
+++ b/detox/proc.py
@@ -9,49 +9,34 @@ import eventlet
 import tox._config
 import tox._cmdline
 
+from itertools import cycle
+spin_chars = cycle("-\|/-\|/")
+
+
 def timelimited(secs, func):
     if secs is not None:
         with Timeout(secs):
             return func()
     return func()
 
-class FileSpinner:
-    chars = "- \ | / - \ | /".split()
-    def __init__(self):
-        self.path2last = {}
-
-    def getchar(self, path):
-        try:
-            lastsize, charindex = self.path2last[path]
-        except KeyError:
-            lastsize, charindex = 0, 0
-        newsize = path.size()
-        if newsize != lastsize:
-            charindex += 1
-        self.path2last[path] = (lastsize, charindex)
-        return self.chars[charindex % len(self.chars)]
-
 
 class ToxReporter(tox._cmdline.Reporter):
     actionchar = "+"
 
     def _loopreport(self):
-        filespinner = FileSpinner()
         while 1:
             eventlet.sleep(0.2)
-            msg = []
+            activity_envs = {}
+
             for action in self.session._actions:
                 for popen in action._popenlist:
                     if popen.poll() is None:
-                        spinnchar = filespinner.getchar(popen.outpath)
-                        if action.venv:
-                            id = action.venv.envconfig.envname
-                        else:
-                            id = ""
-                        msg.append("%s %s %s" % (
-                            id, action.activity, spinnchar))
-            if msg:
-                self.tw.reline("   ".join(msg))
+                        l = activity_envs.setdefault(action.activity, set())
+                        l.add(action.id)
+            if activity_envs:
+                msg = ' '.join('%s {%s}'%(activity,' '.join(sorted(envnames)))
+                               for activity, envnames in activity_envs.items())
+                self.tw.reline('%s %s'%(msg, next(spin_chars) ), remove=True)
 
     def __getattr__(self, name):
         if name[0] == "_":