summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/progress.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-07-06 16:26:10 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-19 15:04:37 +0100
commit45baa90c8cb0f5e92e6a2847d84312b52b0582a2 (patch)
tree1264d6664a4d8fc710838237c3e842ff54fd1c76 /bitbake/lib/bb/progress.py
parent843f7ae4108ad862b02ae84eef4f8cf7f6a3c950 (diff)
downloadpoky-45baa90c8cb0f5e92e6a2847d84312b52b0582a2.tar.gz
bitbake: fetch2: implement progress support
Implement progress reporting support specifically for the fetchers. For fetch tasks we don't necessarily know which fetcher will be used (we might initially be fetching a git:// URI, but if we instead download a mirror tarball we may fetch that over http using wget). These programs also have different abilities as far as reporting progress goes (e.g. wget gives us percentage complete and rate, git gives this some of the time depending on what stage it's at). Additionally we filter out the progress output before it makes it to the logs, in order to prevent the logs filling up with junk. At the moment this is only implemented for the wget and git fetchers since they are the most commonly used (and svn doesn't seem to support any kind of progress output, at least not without doing a relatively expensive remote file listing first). Line changes such as the ones you get in git's output as it progresses don't make it to the log files, you only get the final state of the line so the logs aren't filled with progress information that's useless after the fact. Part of the implementation for [YOCTO #5383]. (Bitbake rev: 4027649f422ee64b1c4e1ad8d48ac295050afbff) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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)