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

- added support to strip the build time from the buildlog when running "bl", "rbl", "lbl"

Also added a config option "buildlog_strip_time" to permanently enable/disable the
stripping of the build time.
This commit is contained in:
Marcus Huewe 2012-12-15 01:50:24 +01:00
parent bfa108810a
commit 737bac561b
3 changed files with 27 additions and 6 deletions

View File

@ -4439,6 +4439,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.alias('buildlogtail')
@cmdln.option('-o', '--offset', metavar='OFFSET',
help='get log start or end from the offset')
@cmdln.option('-s', '--strip-time', action='store_true',
help='strip leading build time from the log')
def do_buildlog(self, subcmd, opts, *args):
"""${cmd_name}: Shows the build log of a package
@ -4489,8 +4491,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
offset=0
elif opts.offset:
offset = int(opts.offset)
print_buildlog(apiurl, project, package, repository, arch, offset)
strip_time = opts.strip_time or conf.config['buildlog_strip_time']
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time)
def print_repos(self, repos_only=False, exc_class=oscerr.WrongArgs, exc_msg='Missing arguments'):
@ -4519,6 +4521,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.alias('remotebuildlogtail')
@cmdln.option('-o', '--offset', metavar='OFFSET',
help='get log starting or ending from the offset')
@cmdln.option('-s', '--strip-time', action='store_true',
help='strip leading build time from the log')
def do_remotebuildlog(self, subcmd, opts, *args):
"""${cmd_name}: Shows the build log of a package
@ -4562,12 +4566,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
offset=0
elif opts.offset:
offset = int(opts.offset)
print_buildlog(apiurl, project, package, repository, arch, offset)
strip_time = opts.strip_time or conf.config['buildlog_strip_time']
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time)
@cmdln.alias('lbl')
@cmdln.option('-o', '--offset', metavar='OFFSET',
help='get log starting from offset')
@cmdln.option('-s', '--strip-time', action='store_true',
help='strip leading build time from the log')
def do_localbuildlog(self, subcmd, opts, *args):
"""${cmd_name}: Shows the build log of a local buildchroot
@ -4620,6 +4626,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
f.seek(offset)
data = f.read(BUFSIZE)
while len(data):
if opts.strip_time or conf.config['buildlog_strip_time']:
data = buildlog_strip_time(data)
sys.stdout.write(data)
data = f.read(BUFSIZE)
f.close()

View File

@ -103,6 +103,8 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
'builtin_signature_check': '1', # by default use builtin check for verify pkgs
'icecream': '0',
'buildlog_strip_time': '0', # strips the build time from the build log
'debug': '0',
'http_debug': '0',
'http_full_debug': '0',
@ -165,7 +167,7 @@ config = DEFAULTS.copy()
boolean_opts = ['debug', 'do_package_tracking', 'http_debug', 'post_mortem', 'traceback', 'check_filelist', 'plaintext_passwd',
'checkout_no_colon', 'checkout_rooted', 'check_for_request_on_action', 'linkcontrol', 'show_download_progress', 'request_show_interactive',
'review_inherit_group', 'use_keyring', 'gnome_keyring', 'no_verify', 'builtin_signature_check', 'http_full_debug',
'include_request_from_project', 'local_service_run']
'include_request_from_project', 'local_service_run', 'buildlog_strip_time']
api_host_options = ['user', 'pass', 'passx', 'aliases', 'http_headers', 'email', 'sslcertck', 'cafile', 'capath', 'trusted_prj']
@ -232,6 +234,9 @@ apiurl = %(apiurl)s
# This should not be 0
# build-uid =
# strip leading build time information from the build log
# buildlog_strip_time = 1
# extra packages to install when building packages locally (osc build)
# this corresponds to osc build's -x option and can be overridden with that
# -x '' can also be given on the command line to override this setting, or

View File

@ -5092,7 +5092,13 @@ def streamfile(url, http_meth = http_GET, bufsize=8192, data=None, progress_obj=
raise oscerr.OscIOError(None, 'Content-Length is not matching file size for %s: %i vs %i file size' % (url, cl, read))
def print_buildlog(apiurl, prj, package, repository, arch, offset = 0):
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)
return time_regex.sub('', data)
def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=False):
"""prints out the buildlog on stdout"""
# to protect us against control characters
@ -5107,6 +5113,8 @@ def print_buildlog(apiurl, prj, package, repository, arch, offset = 0):
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_log'], query=query)
for data in streamfile(u):
offset += len(data)
if strip_time:
data = buildlog_strip_time(data)
sys.stdout.write(data.translate(all_bytes, remove_bytes))
if start_offset == offset:
break