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

- add "osc results --watch" command to wait for build results in efficient way

This commit is contained in:
Adrian Schröter 2012-01-23 17:26:53 +01:00
parent cb78230347
commit 49d91c373d
3 changed files with 44 additions and 19 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
0.134
- patchinfo call can work without checked out copy now
- use qemu as fallback for building not directly supported architectures
- "results --watch" option to watch build results until they finished building
#
# Features which requires OBS 2.3
#

View File

@ -4191,6 +4191,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Show results only for specified architecture(s)')
@cmdln.option('-v', '--verbose', action='store_true', default=False,
help='more verbose output')
@cmdln.option('-w', '--watch', action='store_true', default=False,
help='permanently watch the result')
@cmdln.option('', '--xml', action='store_true', default=False,
help='generate output in XML (former results_meta)')
@cmdln.option('', '--csv', action='store_true', default=False,
@ -4245,7 +4247,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print '\n'.join(format_results(get_package_results(*args), opts.format))
else:
args.append(opts.verbose)
print '\n'.join(get_results(*args))
args.append(opts.watch)
args.append("\n")
get_results(*args)
# WARNING: this function is also called by do_results. You need to set a default there
# as well when adding a new option!

View File

@ -4634,10 +4634,12 @@ def get_binarylist_published(apiurl, prj, repo, arch):
return r
def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[]):
def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[], oldstate=None):
query = {}
if package:
query['package'] = package
if oldstate:
query['oldstate'] = oldstate
if lastbuild:
query['lastbuild'] = 1
u = makeurl(apiurl, ['build', prj, '_result'], query=query)
@ -4655,13 +4657,15 @@ def show_prj_results_meta(apiurl, prj):
return f.readlines()
def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], oldstate=None):
""" return a package results as a list of dicts """
r = []
f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch)
f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch, oldstate)
root = ET.fromstring(''.join(f))
r.append( {'_oldstate': root.get('state')} )
for node in root.findall('result'):
rmap = {}
rmap['project'] = rmap['prj'] = prj
@ -4692,26 +4696,42 @@ def format_results(results, format):
"""apply selected format on each dict in results and return it as a list of strings"""
return [format % r for r in results]
def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False):
def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False, wait=False, printJoin=None):
r = []
result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
oldstate = None
for res in get_package_results(apiurl, prj, package, lastbuild, repository, arch):
res['status'] = res['code']
if verbose and res['details'] != '':
if res['status'] in ('unresolvable', 'expansion error'):
lines = res['details'].split(',')
res['status'] += ': ' + '\n '.join(lines)
while True:
waiting = False
r = []
for res in get_package_results(apiurl, prj, package, lastbuild, repository, arch, oldstate):
if res.has_key('_oldstate'):
oldstate = res['_oldstate']
continue
res['status'] = res['code']
if verbose and res['details'] != '':
if res['status'] in ('unresolvable', 'expansion error'):
lines = res['details'].split(',')
res['status'] += ': ' + '\n '.join(lines)
else:
res['status'] += ': %s' % (res['details'], )
if res['dirty']:
if verbose:
res['status'] = 'outdated (was: %s)' % res['status']
else:
res['status'] += '*'
else:
res['status'] += ': %s' % (res['details'], )
if res['dirty']:
waiting=True
if verbose:
res['status'] = 'outdated (was: %s)' % res['status']
else:
res['status'] += '*'
if res['status'] in ('scheduled', 'finished', 'building', 'signing', 'dispatching'):
waiting=True
r.append(result_line_templ % res)
r.append(result_line_templ % res)
if printJoin:
print printJoin.join(r)
if wait==False or waiting==False:
break
return r