1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-12 16:56:15 +01:00

core: fix, buildlog --strip-time failed to remove time

If a time field is not complete within the same read block
then it can't be found by time_regex in buildlog_strip_time().

Fixed by simply reading line by line. I couldn't measure any
performance difference neither for real nor user time. IMO no
need to optimize for more lines per data chunk. Maybe it's
even more fluent now for interactive users.

BTW we can safely simplify time_regex.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
This commit is contained in:
Ruediger Meier 2014-05-22 14:55:06 +00:00
parent 1d7b954022
commit 7fc5936faf

View File

@ -5393,7 +5393,7 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
def buildlog_strip_time(data):
"""Strips the leading build time from the log"""
time_regex = re.compile('^\[\s{0,5}\d+s\]\s', re.M)
time_regex = re.compile('^\[[^\]]*\] ', re.M)
return time_regex.sub('', data)
@ -5412,7 +5412,7 @@ def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=
query['start'] = offset
start_offset = offset
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_log'], query=query)
for data in streamfile(u):
for data in streamfile(u, bufsize="line"):
offset += len(data)
if strip_time:
data = buildlog_strip_time(data)