summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2020-07-31 11:42:46 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-08 09:19:34 +0100
commite4e67563083c773f5f35de2a209271ff7990ff29 (patch)
tree94b08eec64c7837fd8de79e9b4ba69656766efe4 /bitbake/lib/bb
parent6f9d4614e976f3420f6dad1bee0aeac57446f2d4 (diff)
downloadpoky-e4e67563083c773f5f35de2a209271ff7990ff29.tar.gz
bitbake: progress: modernize syntax, format
Also fixes DummyMultiStageProcessProgressReporter calling the wrong super __init__ (Bitbake rev: 7a1b4a7e4fffe54afe8d1d7e169ff558ad8c92d9) Signed-off-by: Chris Laplante <chris.laplante@agilent.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/progress.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/bitbake/lib/bb/progress.py b/bitbake/lib/bb/progress.py
index 9c755b7f73..b4e9bf0f29 100644
--- a/bitbake/lib/bb/progress.py
+++ b/bitbake/lib/bb/progress.py
@@ -14,7 +14,8 @@ import bb.event
14import bb.build 14import bb.build
15from bb.build import StdoutNoopContextManager 15from bb.build import StdoutNoopContextManager
16 16
17class ProgressHandler(object): 17
18class ProgressHandler:
18 """ 19 """
19 Base class that can pretend to be a file object well enough to be 20 Base class that can pretend to be a file object well enough to be
20 used to build objects to intercept console output and determine the 21 used to build objects to intercept console output and determine the
@@ -55,6 +56,7 @@ class ProgressHandler(object):
55 self._lastevent = ts 56 self._lastevent = ts
56 self._progress = progress 57 self._progress = progress
57 58
59
58class LineFilterProgressHandler(ProgressHandler): 60class LineFilterProgressHandler(ProgressHandler):
59 """ 61 """
60 A ProgressHandler variant that provides the ability to filter out 62 A ProgressHandler variant that provides the ability to filter out
@@ -66,7 +68,7 @@ class LineFilterProgressHandler(ProgressHandler):
66 """ 68 """
67 def __init__(self, d, outfile=None): 69 def __init__(self, d, outfile=None):
68 self._linebuffer = '' 70 self._linebuffer = ''
69 super(LineFilterProgressHandler, self).__init__(d, outfile) 71 super().__init__(d, outfile)
70 72
71 def write(self, string): 73 def write(self, string):
72 self._linebuffer += string 74 self._linebuffer += string
@@ -81,14 +83,15 @@ class LineFilterProgressHandler(ProgressHandler):
81 if lbreakpos: 83 if lbreakpos:
82 line = line[lbreakpos:] 84 line = line[lbreakpos:]
83 if self.writeline(line): 85 if self.writeline(line):
84 super(LineFilterProgressHandler, self).write(line) 86 super().write(line)
85 87
86 def writeline(self, line): 88 def writeline(self, line):
87 return True 89 return True
88 90
91
89class BasicProgressHandler(ProgressHandler): 92class BasicProgressHandler(ProgressHandler):
90 def __init__(self, d, regex=r'(\d+)%', outfile=None): 93 def __init__(self, d, regex=r'(\d+)%', outfile=None):
91 super(BasicProgressHandler, self).__init__(d, outfile) 94 super().__init__(d, outfile)
92 self._regex = re.compile(regex) 95 self._regex = re.compile(regex)
93 # Send an initial progress event so the bar gets shown 96 # Send an initial progress event so the bar gets shown
94 self._fire_progress(0) 97 self._fire_progress(0)
@@ -98,11 +101,12 @@ class BasicProgressHandler(ProgressHandler):
98 if percs: 101 if percs:
99 progress = int(percs[-1]) 102 progress = int(percs[-1])
100 self.update(progress) 103 self.update(progress)
101 super(BasicProgressHandler, self).write(string) 104 super().write(string)
105
102 106
103class OutOfProgressHandler(ProgressHandler): 107class OutOfProgressHandler(ProgressHandler):
104 def __init__(self, d, regex, outfile=None): 108 def __init__(self, d, regex, outfile=None):
105 super(OutOfProgressHandler, self).__init__(d, outfile) 109 super().__init__(d, outfile)
106 self._regex = re.compile(regex) 110 self._regex = re.compile(regex)
107 # Send an initial progress event so the bar gets shown 111 # Send an initial progress event so the bar gets shown
108 self._fire_progress(0) 112 self._fire_progress(0)
@@ -112,9 +116,10 @@ class OutOfProgressHandler(ProgressHandler):
112 if nums: 116 if nums:
113 progress = (float(nums[-1][0]) / float(nums[-1][1])) * 100 117 progress = (float(nums[-1][0]) / float(nums[-1][1])) * 100
114 self.update(progress) 118 self.update(progress)
115 super(OutOfProgressHandler, self).write(string) 119 super().write(string)
116 120
117class MultiStageProgressReporter(object): 121
122class MultiStageProgressReporter:
118 """ 123 """
119 Class which allows reporting progress without the caller 124 Class which allows reporting progress without the caller
120 having to know where they are in the overall sequence. Useful 125 having to know where they are in the overall sequence. Useful
@@ -230,6 +235,7 @@ class MultiStageProgressReporter(object):
230 out.append('Up to finish: %d' % stage_weight) 235 out.append('Up to finish: %d' % stage_weight)
231 bb.warn('Stage times:\n %s' % '\n '.join(out)) 236 bb.warn('Stage times:\n %s' % '\n '.join(out))
232 237
238
233class MultiStageProcessProgressReporter(MultiStageProgressReporter): 239class MultiStageProcessProgressReporter(MultiStageProgressReporter):
234 """ 240 """
235 Version of MultiStageProgressReporter intended for use with 241 Version of MultiStageProgressReporter intended for use with
@@ -238,7 +244,7 @@ class MultiStageProcessProgressReporter(MultiStageProgressReporter):
238 def __init__(self, d, processname, stage_weights, debug=False): 244 def __init__(self, d, processname, stage_weights, debug=False):
239 self._processname = processname 245 self._processname = processname
240 self._started = False 246 self._started = False
241 MultiStageProgressReporter.__init__(self, d, stage_weights, debug) 247 super().__init__(d, stage_weights, debug)
242 248
243 def start(self): 249 def start(self):
244 if not self._started: 250 if not self._started:
@@ -255,13 +261,14 @@ class MultiStageProcessProgressReporter(MultiStageProgressReporter):
255 MultiStageProgressReporter.finish(self) 261 MultiStageProgressReporter.finish(self)
256 bb.event.fire(bb.event.ProcessFinished(self._processname), self._data) 262 bb.event.fire(bb.event.ProcessFinished(self._processname), self._data)
257 263
264
258class DummyMultiStageProcessProgressReporter(MultiStageProgressReporter): 265class DummyMultiStageProcessProgressReporter(MultiStageProgressReporter):
259 """ 266 """
260 MultiStageProcessProgressReporter that takes the calls and does nothing 267 MultiStageProcessProgressReporter that takes the calls and does nothing
261 with them (to avoid a bunch of "if progress_reporter:" checks) 268 with them (to avoid a bunch of "if progress_reporter:" checks)
262 """ 269 """
263 def __init__(self): 270 def __init__(self):
264 MultiStageProcessProgressReporter.__init__(self, "", None, []) 271 super().__init__(None, [])
265 272
266 def _fire_progress(self, taskprogress, rate=None): 273 def _fire_progress(self, taskprogress, rate=None):
267 pass 274 pass