1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-26 09:56:13 +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)')
@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,
@ -5269,6 +5271,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,
@ -5307,10 +5313,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)
@ -5320,7 +5332,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
@ -5348,6 +5361,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',
@ -5406,7 +5421,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,11 +5814,14 @@ def get_results(apiurl, project, package, verbose=False, printJoin='', *args, **
res['status'] += '(unpublished)'
else:
res['status'] += '*'
if is_multi:
r.append(result_line_mb_templ % res)
else:
r.append(result_line_templ % res)
# 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:
r.append(result_line_templ % res)
if printJoin:
if printed:
@ -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,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"
# 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)
for filt_txt in filters:
for pkg in status.keys():
for repo in status[pkg].keys():
if status[pkg][repo] == filt_txt:
if not name_filter:
pacs_to_show.append(pkg)
targets_to_show.append(repo)
elif name_filter in pkg:
pacs_to_show.append(pkg)
else:
filters.append(status_filter)
for filt_txt in filters:
for pkg in status.keys():
for repo in status[pkg].keys():
if status[pkg][repo] == filt_txt:
if not name_filter:
pacs_to_show.append(pkg)
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