From 7fc5936fafce2d846d0ef92c6e41b2ab4fc442bd Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Thu, 22 May 2014 14:55:06 +0000 Subject: [PATCH] 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 --- osc/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osc/core.py b/osc/core.py index 1ab2103e..d7f40846 100644 --- a/osc/core.py +++ b/osc/core.py @@ -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)