1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

add --last parameter for build logs to show last finished log file, if currently building

This commit is contained in:
Adrian Schröter 2013-08-13 10:38:43 +02:00
parent 531251a86c
commit 6461c9faf0
3 changed files with 14 additions and 3 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
0.141 0.141
- support for kiwi appliance builds using obsrepositories:/ directive - support for kiwi appliance builds using obsrepositories:/ directive
- support for manual release of sources and binaries - support for manual release of sources and binaries
- add --last parameter for build logs to show last finished log file, if currently building
0.140 0.140
- support python 2.7 and python 3 in parallel now - support python 2.7 and python 3 in parallel now

View File

@ -4700,6 +4700,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.alias('bl') @cmdln.alias('bl')
@cmdln.alias('blt') @cmdln.alias('blt')
@cmdln.alias('buildlogtail') @cmdln.alias('buildlogtail')
@cmdln.option('-l', '--last', action='store_true',
help='Show the last finished log file')
@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', @cmdln.option('-s', '--strip-time', action='store_true',
@ -4742,6 +4744,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
offset = 0 offset = 0
if subcmd == "blt" or subcmd == "buildlogtail": if subcmd == "blt" or subcmd == "buildlogtail":
query = { 'view': 'entry' } query = { 'view': 'entry' }
if opts.last:
query['last'] = 1
u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query) u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query)
f = http_GET(u) f = http_GET(u)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
@ -4755,7 +4759,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
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'] strip_time = opts.strip_time or conf.config['buildlog_strip_time']
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time) print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last)
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'):
@ -4782,6 +4786,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.alias('rblt') @cmdln.alias('rblt')
@cmdln.alias('rbuildlogtail') @cmdln.alias('rbuildlogtail')
@cmdln.alias('remotebuildlogtail') @cmdln.alias('remotebuildlogtail')
@cmdln.option('-l', '--last', action='store_true',
help='Show the last finished log file')
@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', @cmdln.option('-s', '--strip-time', action='store_true',
@ -4817,6 +4823,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
offset = 0 offset = 0
if subcmd == "rblt" or subcmd == "rbuildlogtail" or subcmd == "remotebuildlogtail": if subcmd == "rblt" or subcmd == "rbuildlogtail" or subcmd == "remotebuildlogtail":
query = { 'view': 'entry' } query = { 'view': 'entry' }
if opts.last:
query['last'] = 1
u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query) u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query)
f = http_GET(u) f = http_GET(u)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
@ -4830,7 +4838,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
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'] strip_time = opts.strip_time or conf.config['buildlog_strip_time']
print_buildlog(apiurl, project, package, repository, arch, offset, strip_time) print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last)
@cmdln.alias('lbl') @cmdln.alias('lbl')
@cmdln.option('-o', '--offset', metavar='OFFSET', @cmdln.option('-o', '--offset', metavar='OFFSET',

View File

@ -5240,7 +5240,7 @@ def buildlog_strip_time(data):
return time_regex.sub('', data) return time_regex.sub('', data)
def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=False): def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=False, last=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
@ -5249,6 +5249,8 @@ def print_buildlog(apiurl, prj, package, repository, arch, offset=0, strip_time=
remove_bytes = all_bytes[:10] + all_bytes[11:32] # accept newlines remove_bytes = all_bytes[:10] + all_bytes[11:32] # accept newlines
query = {'nostream' : '1', 'start' : '%s' % offset} query = {'nostream' : '1', 'start' : '%s' % offset}
if last:
query['last'] = 1
while True: while True:
query['start'] = offset query['start'] = offset
start_offset = offset start_offset = offset