1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

Merge branch 'filter_results_based_on_code' of https://github.com/lethliel/osc

Add a --status-filter option to "osc results" that can be used to
show, for instance, only the repos where a package failed to build. As
a short circuit, a -f/--failed option is added, too.
Add a --brief option to "osc prjresults" and "osc results" that can be
used to get a more compact representation of the results. In case of
"osc results", --brief is ignored if the results for a package are
requested.
This commit is contained in:
Marcus Huewe 2020-07-07 17:08:32 +02:00
commit aa855b1c69
2 changed files with 51 additions and 22 deletions

View File

@ -5289,6 +5289,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Show results only for specified repo(s)')
@cmdln.option('-a', '--arch', action='append', default = [],
help='Show results only for specified architecture(s)')
@cmdln.option('-b', '--brief', action='store_true',
help='show the result in "pkgname repo arch result". Default for -f')
@cmdln.option('-v', '--verbose', action='store_true', default=False,
help='more verbose output')
@cmdln.option('--no-multibuild', action='store_true', default=False,
@ -5299,6 +5301,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='list packages vertically instead horizontally for entire project')
@cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building')
@cmdln.option('-s', '--status-filter',
help='only show packages with the given build status')
@cmdln.option('-f', '--failed', action='store_true',
help='show only failed results')
@cmdln.option('', '--xml', action='store_true', default=False,
help='generate output in XML (former results_meta)')
@cmdln.option('', '--csv', action='store_true', default=False,
@ -5337,10 +5343,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if project == None:
raise oscerr.WrongOptions("No project given")
if opts.failed and opts.status_filter:
raise oscerr.WrongArgs('-s and -f cannot be used together')
if opts.failed:
opts.status_filter = 'failed'
opts.brief = True
if package == None:
opts.hide_legend = None
opts.name_filter = None
opts.status_filter = None
opts.show_non_building = None
opts.show_excluded = None
return self.do_prjresults('prjresults', opts, *args)
@ -5350,7 +5362,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
kwargs = {'apiurl': apiurl, 'project': project, 'package': package,
'lastbuild': opts.last_build, 'repository': opts.repo,
'arch': opts.arch, 'wait': opts.watch, 'showexcl': opts.show_excluded}
'arch': opts.arch, 'wait': opts.watch, 'showexcl': opts.show_excluded,
'code': opts.status_filter}
if opts.multibuild_package:
opts.no_multibuild = False
kwargs['multibuild_packages'] = opts.multibuild_package
@ -5378,6 +5391,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# as well when adding a new option!
@cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend')
@cmdln.option('-b', '--brief', action='store_true',
help='show the result in "pkgname repo arch result"')
@cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building, only supported with --xml')
@cmdln.option('-c', '--csv', action='store_true',
@ -5436,7 +5451,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
csv=opts.csv, status_filter=opts.status_filter, \
name_filter=opts.name_filter, repo=opts.repo, \
arch=opts.arch, vertical=opts.vertical, \
show_excluded=opts.show_excluded)))
show_excluded=opts.show_excluded, brief=opts.brief)))
@cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend')

View File

@ -5695,7 +5695,7 @@ def get_binarylist_published(apiurl, prj, repo, arch):
return r
def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[], oldstate=None, multibuild=False, locallink=False):
def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[], oldstate=None, multibuild=False, locallink=False, code=None):
query = []
if package:
query.append('package=%s' % quote_plus(package))
@ -5707,6 +5707,8 @@ def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[],
query.append('multibuild=1')
if locallink:
query.append('locallink=1')
if code:
query.append('code=%s' % quote_plus(code))
for repo in repository:
query.append('repository=%s' % quote_plus(repo))
for a in arch:
@ -5779,6 +5781,7 @@ def get_results(apiurl, project, package, verbose=False, printJoin='', *args, **
printed = False
multibuild_packages = kwargs.pop('multibuild_packages', [])
show_excluded = kwargs.pop('showexcl', False)
code_filter = kwargs.get('code')
for results in get_package_results(apiurl, project, package, **kwargs):
r = []
for res, is_multi in result_xml_to_dicts(results):
@ -5811,7 +5814,10 @@ def get_results(apiurl, project, package, verbose=False, printJoin='', *args, **
res['status'] += '(unpublished)'
else:
res['status'] += '*'
# we need to do the code filtering again, because result_xml_to_dicts returns the code
# of the repository if the result is already prefiltered by the backend. So we need
# to filter out the repository states.
if code_filter is None or code_filter == res['code']:
if is_multi:
r.append(result_line_mb_templ % res)
else:
@ -5868,7 +5874,7 @@ def get_package_results(apiurl, project, package=None, wait=False, *args, **kwar
yield xml
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None, show_excluded=None):
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None, show_excluded=None, brief=False):
#print '----------------------------------------'
global buildstatus_symbols
@ -5908,8 +5914,8 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
targets.sort()
# filter option
filters = []
if status_filter or name_filter or not show_excluded:
pacs_to_show = []
targets_to_show = []
@ -5919,10 +5925,11 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
# a list is needed because if status_filter == "U"
# we have to filter either an "expansion error" (obsolete)
# or an "unresolvable" state
filters = []
for txt, sym in buildstatus_symbols.items():
if sym == status_filter:
filters.append(txt)
else:
filters.append(status_filter)
for filt_txt in filters:
for pkg in status.keys():
for repo in status[pkg].keys():
@ -5932,7 +5939,6 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
targets_to_show.append(repo)
elif name_filter in pkg:
pacs_to_show.append(pkg)
#filtering for Package Name
elif name_filter:
for pkg in pacs:
@ -5968,6 +5974,14 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
r.append(';'.join(row))
return r
if brief:
for pac, repo_states in status.items():
for repo, state in repo_states.items():
if filters and state not in filters:
continue
r.append('%s %s %s %s' % (pac, repo[0], repo[1], state))
return r
if not vertical:
# human readable output
max_pacs = 40