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

- legend in prjresults is default enabled

- added status-filter and name-filter option to prjresults
This commit is contained in:
Tom Patzig 2008-05-15 18:09:24 +00:00
parent db6dcbe8a9
commit abcb4f8489
2 changed files with 38 additions and 6 deletions

View File

@ -1297,10 +1297,15 @@ class Osc(cmdln.Cmdln):
print '\n'.join(get_results(pac.apiurl, pac.prjname, pac.name))
@cmdln.option('-l', '--legend', action='store_true',
help='show the legend')
@cmdln.option('-q', '--hide-legend', action='store_true',
help='hide the legend')
@cmdln.option('-c', '--csv', action='store_true',
help='csv output')
@cmdln.option('-s', '--status-filter', metavar='STATUS',
help='show only packages with buildstatus STATUS (see legend)')
@cmdln.option('-n', '--name-filter', metavar='EXPR',
help='show only packages whos name matches EXPR')
def do_prjresults(self, subcmd, opts, *args):
"""${cmd_name}: Shows project-wide build results
@ -1328,7 +1333,7 @@ class Osc(cmdln.Cmdln):
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
print '\n'.join(get_prj_results(apiurl, project, show_legend=opts.legend, csv=opts.csv))
print '\n'.join(get_prj_results(apiurl, project, hide_legend=opts.hide_legend, csv=opts.csv, status_filter=opts.status_filter, name_filter=opts.name_filter))
@cmdln.alias('bl')

View File

@ -150,7 +150,7 @@ buildstatus_symbols = {'succeeded': '.',
'broken': 'B',
'blocked': 'b',
'building': '%',
'finished': '%',
'finished': 'f',
'scheduled': 's',
}
@ -2451,7 +2451,7 @@ def get_results(apiurl, prj, package):
r.append(result_line_templ % rmap)
return r
def get_prj_results(apiurl, prj, show_legend=False, csv=False):
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None):
#print '----------------------------------------'
r = []
@ -2482,6 +2482,33 @@ def get_prj_results(apiurl, prj, show_legend=False, csv=False):
status[pac][tg] = pacnode.get('code')
targets.sort()
# filter option
if status_filter or name_filter:
pacs_to_show = []
#filtering for Package Status
if status_filter:
if status_filter in buildstatus_symbols.values():
for txt, sym in buildstatus_symbols.items():
if sym == status_filter:
filt_txt = txt
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)
elif name_filter in pkg:
pacs_to_show.append(pkg)
#filtering for Package Name
elif name_filter:
for pkg in pacs:
if name_filter in pkg:
pacs_to_show.append(pkg)
pacs = [ i for i in pacs if i in pacs_to_show ]
# csv output
if csv:
# TODO: option to disable the table header
@ -2525,7 +2552,7 @@ def get_prj_results(apiurl, prj, show_legend=False, csv=False):
r.append('')
if show_legend:
if not hide_legend:
r.append(' Legend:')
for i, j in buildstatus_symbols.items():
r.append(' %s %s' % (j, i))