1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

add option to prjresults to show results with packages listed vertically

This commit is contained in:
Ludwig Nussel 2010-01-11 16:36:21 +01:00
parent bd9a9774f3
commit e86d6b6223
2 changed files with 63 additions and 23 deletions

View File

@ -2667,15 +2667,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='show results only for specified architecture(s)') help='show results only for specified architecture(s)')
@cmdln.option('-r', '--repo', metavar='REPO', @cmdln.option('-r', '--repo', metavar='REPO',
help='show results only for specified repo(s)') help='show results only for specified repo(s)')
@cmdln.option('-p', '--project', metavar='PROJECT', @cmdln.option('-V', '--vertical', action='store_true',
help='show packages in project PROJECT') help='list packages vertically instead horizontally')
@cmdln.alias('pr') @cmdln.alias('pr')
def do_prjresults(self, subcmd, opts, *args): def do_prjresults(self, subcmd, opts, *args):
"""${cmd_name}: Shows project-wide build results """${cmd_name}: Shows project-wide build results
Usage: Usage:
osc prjresults (inside working copy) osc prjresults (inside working copy)
osc prjresults project osc prjresults PROJECT
${cmd_option_list} ${cmd_option_list}
""" """
@ -2685,14 +2685,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) == 1: if len(args) == 1:
project = args[0] project = args[0]
else: else:
print >>sys.stderr, 'getting results for more than one project is not supported' raise oscerr.WrongArgs('Wrong number of arguments.')
return 2
else: else:
wd = os.curdir wd = os.curdir
project = store_read_project(wd) project = store_read_project(wd)
apiurl = store_read_apiurl(wd) apiurl = store_read_apiurl(wd)
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, repo=opts.repo, arch=opts.arch)) 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, repo=opts.repo, arch=opts.arch, vertical=opts.vertical))
@cmdln.option('-q', '--hide-legend', action='store_true', @cmdln.option('-q', '--hide-legend', action='store_true',

View File

@ -3470,12 +3470,10 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
r.append(result_line_templ % rmap) r.append(result_line_templ % rmap)
return r return r
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None): def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None):
#print '----------------------------------------' #print '----------------------------------------'
r = [] r = []
#result_line_templ = '%(prj)-15s %(pac)-15s %(rep)-15s %(arch)-10s %(status)s'
result_line_templ = '%(rep)-15s %(arch)-10s %(status)s'
f = show_prj_results_meta(apiurl, prj) f = show_prj_results_meta(apiurl, prj)
root = ET.fromstring(''.join(f)) root = ET.fromstring(''.join(f))
@ -3550,18 +3548,48 @@ 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
# human readable output if not vertical:
max_pacs = 40 # human readable output
for startpac in range(0, len(pacs), max_pacs): max_pacs = 40
for startpac in range(0, len(pacs), max_pacs):
offset = 0
for pac in pacs[startpac:startpac+max_pacs]:
r.append(' |' * offset + ' ' + pac)
offset += 1
for tg in targets:
line = []
line.append(' ')
for pac in pacs[startpac:startpac+max_pacs]:
st = ''
if not status.has_key(pac) or not status[pac].has_key(tg):
# for newly added packages, status may be missing
st = '?'
else:
try:
st = buildstatus_symbols[status[pac][tg]]
except:
print 'osc: warn: unknown status \'%s\'...' % status[pac][tg]
print 'please edit osc/core.py, and extend the buildstatus_symbols dictionary.'
st = '?'
buildstatus_symbols[status[pac][tg]] = '?'
line.append(st)
line.append(' ')
line.append(' %s %s (%s)' % tg)
line = ''.join(line)
r.append(line)
r.append('')
else:
offset = 0 offset = 0
for pac in pacs[startpac:startpac+max_pacs]: for tg in targets:
r.append(' |' * offset + ' ' + pac) r.append('| ' * offset + '%s %s (%s)'%tg )
offset += 1 offset += 1
for tg in targets: for pac in pacs:
line = [] line = []
line.append(' ') for tg in targets:
for pac in pacs[startpac:startpac+max_pacs]:
st = '' st = ''
if not status.has_key(pac) or not status[pac].has_key(tg): if not status.has_key(pac) or not status[pac].has_key(tg):
# for newly added packages, status may be missing # for newly added packages, status may be missing
@ -3575,18 +3603,31 @@ def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=Non
st = '?' st = '?'
buildstatus_symbols[status[pac][tg]] = '?' buildstatus_symbols[status[pac][tg]] = '?'
line.append(st) line.append(st)
line.append(' ') line.append(' '+pac)
line.append(' %s %s (%s)' % tg) r.append(' '.join(line))
line = ''.join(line)
r.append(line)
line = []
for i in range(0, len(targets)):
line.append(str(i%10))
r.append(' '.join(line))
r.append('') r.append('')
if not hide_legend and len(pacs): if not hide_legend and len(pacs):
r.append(' Legend:') r.append(' Legend:')
legend = []
for i, j in buildstatus_symbols.items(): for i, j in buildstatus_symbols.items():
r.append(' %s %s' % (j, i)) legend.append('%3s %-20s' % (j, i))
if vertical:
for i in range(0, len(targets)):
s = '%1d %s %s (%s)' % (i%10, targets[i][0], targets[i][1], targets[i][2])
if i < len(legend):
legend[i] += s
else:
legend.append(' '*24 + s)
r += legend
return r return r