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:
parent
bfa108810a
commit
737bac561b
@ -4439,6 +4439,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
@cmdln.alias('buildlogtail')
|
@cmdln.alias('buildlogtail')
|
||||||
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
||||||
help='get log start or end from the 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):
|
def do_buildlog(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Shows the build log of a package
|
"""${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
|
offset=0
|
||||||
elif opts.offset:
|
elif opts.offset:
|
||||||
offset = int(opts.offset)
|
offset = int(opts.offset)
|
||||||
|
strip_time = opts.strip_time or conf.config['buildlog_strip_time']
|
||||||
print_buildlog(apiurl, project, package, repository, arch, offset)
|
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'):
|
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.alias('remotebuildlogtail')
|
||||||
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
||||||
help='get log starting or ending from the 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):
|
def do_remotebuildlog(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Shows the build log of a package
|
"""${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
|
offset=0
|
||||||
elif opts.offset:
|
elif opts.offset:
|
||||||
offset = int(opts.offset)
|
offset = int(opts.offset)
|
||||||
|
strip_time = opts.strip_time or conf.config['buildlog_strip_time']
|
||||||
print_buildlog(apiurl, project, package, repository, arch, offset)
|
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time)
|
||||||
|
|
||||||
@cmdln.alias('lbl')
|
@cmdln.alias('lbl')
|
||||||
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
@cmdln.option('-o', '--offset', metavar='OFFSET',
|
||||||
help='get log starting from 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):
|
def do_localbuildlog(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Shows the build log of a local buildchroot
|
"""${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)
|
f.seek(offset)
|
||||||
data = f.read(BUFSIZE)
|
data = f.read(BUFSIZE)
|
||||||
while len(data):
|
while len(data):
|
||||||
|
if opts.strip_time or conf.config['buildlog_strip_time']:
|
||||||
|
data = buildlog_strip_time(data)
|
||||||
sys.stdout.write(data)
|
sys.stdout.write(data)
|
||||||
data = f.read(BUFSIZE)
|
data = f.read(BUFSIZE)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -103,6 +103,8 @@ DEFAULTS = {'apiurl': 'https://api.opensuse.org',
|
|||||||
'builtin_signature_check': '1', # by default use builtin check for verify pkgs
|
'builtin_signature_check': '1', # by default use builtin check for verify pkgs
|
||||||
'icecream': '0',
|
'icecream': '0',
|
||||||
|
|
||||||
|
'buildlog_strip_time': '0', # strips the build time from the build log
|
||||||
|
|
||||||
'debug': '0',
|
'debug': '0',
|
||||||
'http_debug': '0',
|
'http_debug': '0',
|
||||||
'http_full_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',
|
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',
|
'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',
|
'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']
|
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
|
# This should not be 0
|
||||||
# build-uid =
|
# 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)
|
# extra packages to install when building packages locally (osc build)
|
||||||
# this corresponds to osc build's -x option and can be overridden with that
|
# 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
|
# -x '' can also be given on the command line to override this setting, or
|
||||||
|
10
osc/core.py
10
osc/core.py
@ -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))
|
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"""
|
"""prints out the buildlog on stdout"""
|
||||||
|
|
||||||
# to protect us against control characters
|
# 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)
|
u = makeurl(apiurl, ['build', prj, repository, arch, package, '_log'], query=query)
|
||||||
for data in streamfile(u):
|
for data in streamfile(u):
|
||||||
offset += len(data)
|
offset += len(data)
|
||||||
|
if strip_time:
|
||||||
|
data = buildlog_strip_time(data)
|
||||||
sys.stdout.write(data.translate(all_bytes, remove_bytes))
|
sys.stdout.write(data.translate(all_bytes, remove_bytes))
|
||||||
if start_offset == offset:
|
if start_offset == offset:
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user