From e8c6d7a8db6f6ea922caed021b9ef046b7768942 Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Sat, 29 Apr 2006 20:44:09 +0000 Subject: [PATCH] make 'results' show build results in tabular form; add 'results_meta' to show raw xml --- osc.py | 22 +++++++++++++++++++--- osclib.py | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/osc.py b/osc.py index 411f5b37..f2c3b9e6 100755 --- a/osc.py +++ b/osc.py @@ -321,16 +321,32 @@ def main(): - elif cmd == 'results': + elif cmd == 'results_meta': wd = os.curdir package = store_read_package(wd) project = store_read_project(wd) if len(sys.argv) > 2: platform = sys.argv[2] - print ''.join(get_results(project, package, platform)) + print ''.join(show_results_meta(project, package, platform)) else: for platform in get_platforms_of_project(project): - print ''.join(get_results(project, package, platform)) + print ''.join(show_results_meta(project, package, platform)) + + elif cmd == 'results': + if len(sys.argv) > 3: + print 'getting results for more than one package is not supported' + print sys.exit(1) + + if len(sys.argv) == 3: + wd = sys.argv[2] + else: + wd = os.curdir + package = store_read_package(wd) + project = store_read_project(wd) + + for platform in get_platforms_of_project(project): + print ''.join(get_results(project, package, platform)) + elif cmd == 'log': wd = os.curdir diff --git a/osclib.py b/osclib.py index 195d449e..d84cfec6 100755 --- a/osclib.py +++ b/osclib.py @@ -399,11 +399,47 @@ def get_platforms_of_project(prj): r.append(entry.attrs[('', 'name')]) return r -def get_results(prj, package, platform): +def show_results_meta(prj, package, platform): u = makeurl(['result', prj, platform, package, 'result']) f = urllib2.urlopen(u) return f.readlines() +def get_results(prj, package, platform): + #print '----------------------------------------' + f = show_results_meta(prj, package, platform) + + reader = Sax2.Reader() + doc = reader.fromString(''.join(f)) + + r = [] + #result_line_templ = '%(prj)-15s %(pac)-15s %(rep)-15s %(arch)-10s %(status)s' + result_line_templ = '%(rep)-15s %(arch)-10s %(status)s %(hint)s' + + for i in doc.getElementsByTagName('packageresult'): + rmap = {} + rmap['hint'] = '' + rmap['prj'] = i.getAttribute('project') + rmap['pac'] = i.getAttribute('package') + rmap['rep'] = i.getAttribute('repository') + + for ii in i.getElementsByTagName('archresult'): + rmap['arch'] = ii.getAttribute('arch') + + for iii in ii.getElementsByTagName('status'): + rmap['status'] = iii.getAttribute('code') + if rmap['status'] == 'expansion error': + for iiii in iii.getElementsByTagName('summary'): + rmap['status'] += ':' + rmap['hint'] = iiii.childNodes[0].data + if rmap['status'] == 'failed': + rmap['status'] += ':' + rmap['hint'] = '\'osc log %(rep)s %(arch)s\' -> ' % rmap + \ + '(%s://%s' % (scheme, netloc) + \ + '/result/%(prj)s/%(rep)s/%(pac)s/%(arch)s/log)' % rmap + + r.append(result_line_templ % rmap) + return r + def get_log(prj, package, platform, arch): u = makeurl(['result', prj, platform, package, arch, 'log']) f = urllib2.urlopen(u)