diff --git a/NEWS b/NEWS index 5cda37e0..a13606a2 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 0.141 - support for kiwi appliance builds using obsrepositories:/ directive - 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 - support python 2.7 and python 3 in parallel now diff --git a/osc/commandline.py b/osc/commandline.py index ff6425ee..8e52eb3c 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4700,6 +4700,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.alias('bl') @cmdln.alias('blt') @cmdln.alias('buildlogtail') + @cmdln.option('-l', '--last', action='store_true', + help='Show the last finished log file') @cmdln.option('-o', '--offset', metavar='OFFSET', help='get log start or end from the offset') @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 if subcmd == "blt" or subcmd == "buildlogtail": query = { 'view': 'entry' } + if opts.last: + query['last'] = 1 u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query) f = http_GET(u) root = ET.parse(f).getroot() @@ -4755,7 +4759,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. elif 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, 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'): @@ -4782,6 +4786,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. @cmdln.alias('rblt') @cmdln.alias('rbuildlogtail') @cmdln.alias('remotebuildlogtail') + @cmdln.option('-l', '--last', action='store_true', + help='Show the last finished log file') @cmdln.option('-o', '--offset', metavar='OFFSET', help='get log starting or ending from the offset') @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 if subcmd == "rblt" or subcmd == "rbuildlogtail" or subcmd == "remotebuildlogtail": query = { 'view': 'entry' } + if opts.last: + query['last'] = 1 u = makeurl(self.get_api_url(), ['build', project, repository, arch, package, '_log'], query=query) f = http_GET(u) root = ET.parse(f).getroot() @@ -4830,7 +4838,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. elif 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, strip_time) + print_buildlog(apiurl, project, package, repository, arch, offset, strip_time, opts.last) @cmdln.alias('lbl') @cmdln.option('-o', '--offset', metavar='OFFSET', diff --git a/osc/core.py b/osc/core.py index e7273975..235a1335 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5240,7 +5240,7 @@ def buildlog_strip_time(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""" # 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 query = {'nostream' : '1', 'start' : '%s' % offset} + if last: + query['last'] = 1 while True: query['start'] = offset start_offset = offset