From c526f4ee9a2cdbb243617a5542706db9a31a7360 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 20 Feb 2009 11:04:45 +0000 Subject: [PATCH] add osc jobhistory --- osc/commandline.py | 22 ++++++++++++++++++++++ osc/core.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/osc/commandline.py b/osc/commandline.py index 18d99d03..e26acc7d 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1993,6 +1993,28 @@ Please submit there instead, or use --nodevelproject to force direct submission. print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch)) + @cmdln.alias('jobhist') + def do_jobhistory(self, subcmd, opts, platform, arch): + """${cmd_name}: Shows the job history of a project + + The arguments PLATFORM and ARCH can be taken from first two columns + of the 'osc repos' output. + + ${cmd_usage} + ${cmd_option_list} + """ + + wd = os.curdir + project = store_read_project(wd) + package = None + try: + package = store_read_package(wd) + except: + pass + apiurl = store_read_apiurl(wd) + + print_jobhistory(apiurl, project, package, platform, arch) + @cmdln.option('-r', '--revision', metavar='rev', help='show log of the specified revision') diff --git a/osc/core.py b/osc/core.py index a6a590c3..c89bf0ca 100755 --- a/osc/core.py +++ b/osc/core.py @@ -2820,6 +2820,39 @@ def get_buildhistory(apiurl, prj, package, platform, arch): return r +def print_jobhistory(apiurl, prj, current_package, platform, arch): + import time + u = makeurl(apiurl, ['build', prj, platform, arch, '_jobhistory']) + f = http_GET(u) + root = ET.parse(f).getroot() + + print "time package reason code build time" + for node in root.findall('jobhist'): + package = node.get('package') + if current_package and package != current_package: + continue + reason = node.get('reason') + if not reason: + reason = "unknown" + bcnt = node.get('bcnt') + code = node.get('code') + rev = int(node.get('rev')) + srcmd5 = node.get('srcmd5') + rt = int(node.get('readytime')) + readyt = time.localtime(rt) + readyt = time.strftime('%Y-%m-%d %H:%M:%S', readyt) + st = int(node.get('starttime')) + et = int(node.get('endtime')) + endtime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(et)) + waitstart = time.strftime('%H:%M:%S', time.gmtime(st-rt)) + waittm = time.gmtime(et-st) + if waittm.tm_hour: + waitbuild = "%2dh %2dm %2ds" % (waittm.tm_hour, waittm.tm_min, waittm.tm_sec) + else: + waitbuild = " %2dm %2ds" % (waittm.tm_min, waittm.tm_sec) + + print '%s %-25s %-16s %-16s %s' % (endtime, package[0:24], reason[0:15], code[0:15], waitbuild) + def get_commitlog(apiurl, prj, package, revision): import time, locale