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

add brief results/prjresults with filtered code

in do_results:
  * add --brief option on prj level:
    [packagename] [repo] [arch] [buildstatus]
  * filter by --status-filter <long status name>
    works on prj and pkg level

in do_prjresults:
  * --brief
  * assume len(state)>1 as long state

core.py
  * filter packages by build status
  * long status handling in get_prj_results
  * brief output generation in get_prj_results
This commit is contained in:
lethliel 2020-06-19 08:32:00 +02:00
parent 050c94dcf3
commit 2f0918b93e
2 changed files with 51 additions and 22 deletions

View File

@ -5259,6 +5259,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='Show results only for specified repo(s)') help='Show results only for specified repo(s)')
@cmdln.option('-a', '--arch', action='append', default = [], @cmdln.option('-a', '--arch', action='append', default = [],
help='Show results only for specified architecture(s)') 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, @cmdln.option('-v', '--verbose', action='store_true', default=False,
help='more verbose output') help='more verbose output')
@cmdln.option('--no-multibuild', action='store_true', default=False, @cmdln.option('--no-multibuild', action='store_true', default=False,
@ -5269,6 +5271,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='list packages vertically instead horizontally for entire project') help='list packages vertically instead horizontally for entire project')
@cmdln.option('-w', '--watch', action='store_true', @cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building') 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, @cmdln.option('', '--xml', action='store_true', default=False,
help='generate output in XML (former results_meta)') help='generate output in XML (former results_meta)')
@cmdln.option('', '--csv', action='store_true', default=False, @cmdln.option('', '--csv', action='store_true', default=False,
@ -5307,10 +5313,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if project == None: if project == None:
raise oscerr.WrongOptions("No project given") 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: if package == None:
opts.hide_legend = None opts.hide_legend = None
opts.name_filter = None opts.name_filter = None
opts.status_filter = None
opts.show_non_building = None opts.show_non_building = None
opts.show_excluded = None opts.show_excluded = None
return self.do_prjresults('prjresults', opts, *args) return self.do_prjresults('prjresults', opts, *args)
@ -5320,7 +5332,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
kwargs = {'apiurl': apiurl, 'project': project, 'package': package, kwargs = {'apiurl': apiurl, 'project': project, 'package': package,
'lastbuild': opts.last_build, 'repository': opts.repo, '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: if opts.multibuild_package:
opts.no_multibuild = False opts.no_multibuild = False
kwargs['multibuild_packages'] = opts.multibuild_package kwargs['multibuild_packages'] = opts.multibuild_package
@ -5348,6 +5361,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# as well when adding a new option! # as well when adding a new option!
@cmdln.option('-q', '--hide-legend', action='store_true', @cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend') 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', @cmdln.option('-w', '--watch', action='store_true',
help='watch the results until all finished building, only supported with --xml') help='watch the results until all finished building, only supported with --xml')
@cmdln.option('-c', '--csv', action='store_true', @cmdln.option('-c', '--csv', action='store_true',
@ -5406,7 +5421,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
csv=opts.csv, status_filter=opts.status_filter, \ csv=opts.csv, status_filter=opts.status_filter, \
name_filter=opts.name_filter, repo=opts.repo, \ name_filter=opts.name_filter, repo=opts.repo, \
arch=opts.arch, vertical=opts.vertical, \ 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', @cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend') help='hide the legend')

View File

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