mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-14 00:06:15 +01:00
Merge branch 'fix-bl-strip-time' of https://github.com/rudimeier/osc
This commit is contained in:
commit
fff6f3ddb1
25
osc/core.py
25
osc/core.py
@ -5341,7 +5341,7 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
|
||||
"""
|
||||
performs http_meth on url and read bufsize bytes from the response
|
||||
until EOF is reached. After each read bufsize bytes are yielded to the
|
||||
caller.
|
||||
caller. A spezial usage is bufsize="line" to read line by line (text).
|
||||
"""
|
||||
cl = ''
|
||||
retries = 0
|
||||
@ -5366,14 +5366,23 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
|
||||
if progress_obj:
|
||||
basename = os.path.basename(urlsplit(url)[2])
|
||||
progress_obj.start(basename=basename, text=text, size=cl)
|
||||
data = f.read(bufsize)
|
||||
read = len(data)
|
||||
while len(data):
|
||||
|
||||
if bufsize == "line":
|
||||
bufsize = 8192
|
||||
xread = f.readline
|
||||
else:
|
||||
xread = f.read
|
||||
|
||||
read = 0
|
||||
while True:
|
||||
data = xread(bufsize)
|
||||
if not len(data):
|
||||
break
|
||||
read += len(data)
|
||||
if progress_obj:
|
||||
progress_obj.update(read)
|
||||
yield data
|
||||
data = f.read(bufsize)
|
||||
read += len(data)
|
||||
|
||||
if progress_obj:
|
||||
progress_obj.end(read)
|
||||
f.close()
|
||||
@ -5384,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)
|
||||
|
||||
|
||||
@ -5403,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)
|
||||
|
Loading…
Reference in New Issue
Block a user