summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/progress.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/progress.py')
-rw-r--r--bitbake/lib/bb/progress.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/bitbake/lib/bb/progress.py b/bitbake/lib/bb/progress.py
index ee6b9536b8..343b18f8c4 100644
--- a/bitbake/lib/bb/progress.py
+++ b/bitbake/lib/bb/progress.py
@@ -58,6 +58,37 @@ class ProgressHandler(object):
58 self._lastevent = ts 58 self._lastevent = ts
59 self._progress = progress 59 self._progress = progress
60 60
61class LineFilterProgressHandler(ProgressHandler):
62 """
63 A ProgressHandler variant that provides the ability to filter out
64 the lines if they contain progress information. Additionally, it
65 filters out anything before the last line feed on a line. This can
66 be used to keep the logs clean of output that we've only enabled for
67 getting progress, assuming that that can be done on a per-line
68 basis.
69 """
70 def __init__(self, d, outfile=None):
71 self._linebuffer = ''
72 super(LineFilterProgressHandler, self).__init__(d, outfile)
73
74 def write(self, string):
75 self._linebuffer += string
76 while True:
77 breakpos = self._linebuffer.find('\n') + 1
78 if breakpos == 0:
79 break
80 line = self._linebuffer[:breakpos]
81 self._linebuffer = self._linebuffer[breakpos:]
82 # Drop any line feeds and anything that precedes them
83 lbreakpos = line.rfind('\r') + 1
84 if lbreakpos:
85 line = line[lbreakpos:]
86 if self.writeline(line):
87 super(LineFilterProgressHandler, self).write(line)
88
89 def writeline(self, line):
90 return True
91
61class BasicProgressHandler(ProgressHandler): 92class BasicProgressHandler(ProgressHandler):
62 def __init__(self, d, regex=r'(\d+)%', outfile=None): 93 def __init__(self, d, regex=r'(\d+)%', outfile=None):
63 super(BasicProgressHandler, self).__init__(d, outfile) 94 super(BasicProgressHandler, self).__init__(d, outfile)