diff options
author | Ed Bartosh <eduard.bartosh@intel.com> | 2015-02-03 20:55:30 +0200 |
---|---|---|
committer | Ed Bartosh <eduard.bartosh@intel.com> | 2015-02-05 22:53:13 +0200 |
commit | 39bd775a0c6739ce76529d1351f254a2dc6f37f6 (patch) | |
tree | a4e2ad39decdf0d2eca804427042849bd48207ea | |
parent | 5f8cbd38fe90433bc6419484d19befe9eadecaf2 (diff) | |
download | repa-39bd775a0c6739ce76529d1351f254a2dc6f37f6.tar.gz repa-39bd775a0c6739ce76529d1351f254a2dc6f37f6.tar.bz2 repa-39bd775a0c6739ce76529d1351f254a2dc6f37f6.zip |
repa list: Add build time
Added optional configuration and command line option to
show build time for the submissions in 'ready' status.
Fixes: #2325
Change-Id: Ieec61217aedec9a254e7b7695ff085eab5709b81
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r-- | repa.1 | 20 | ||||
-rwxr-xr-x | repa/list.py | 32 | ||||
-rw-r--r-- | repa/obs.py | 11 |
3 files changed, 52 insertions, 11 deletions
@@ -102,7 +102,7 @@ Turn on colorized output .\" .\" The "list" command description .\" -.SS \fBlist\fR [\-\-help] [\-\-processes <processes>] [\-\-showurls] [\-\-ignore <regexp>] [\-\-base <project>] +.SS \fBlist\fR [\-\-help] [\-\-processes <processes>] [\-\-showurls] [\-\-ignore <regexp>] [\-\-base <project>] [\-\-showtime] .RS 2 List submissions in the following format: @@ -119,9 +119,9 @@ submit/tizen/20140327.055105 package building libav zlib .RS 0 submit/tizen/20140327.080733 image building bluez .RS 0 -submit/tizen/20140328.063916 ready connman +submit/tizen/20140328.063916 ready 01:20:14 connman .RS 0 -submit/tizen/20140328.080409 ready sdbd +submit/tizen/20140328.080409 ready 00:14:30 sdbd .RS 0 .RE @@ -167,6 +167,14 @@ Note, that this parameter can also be specified in \fIrepa\fR configuration file .RE .PP +.B \-\-showtime +.RS 2 +Show submission build time for the submissions in 'ready' status. It's switched off by default. +Note, that this parameter can also be specified in \fIrepa\fR configuration file. +.RE + + +.PP .\" .\" The "show" command description .\" @@ -531,6 +539,10 @@ ignore = arm-.*/armv7./.*_aggregate$ .RS 2 noaggregate = mic-bootstrap-x86-arm.rpm|mic-bootstrap.rpm|mic-bootstrap-debugsource.rpm|qemu-accel-armv7l.rpm|qemu-accel-armv7l-cross-arm.rpm|qemu-linux-user-cross-arm.rpm .RE +.RS 2 +showtime = off +.RE + .RS 2 @@ -538,7 +550,7 @@ Mandatory options: apiurl, apiuser, apipasswd, jenkins_url, jenkins_user, jenkin .RE .RS 2 -Some options (project, processes, colorize, showurls, ignore, noaggregate, base) can be overridden by commandline options (--project, --processes, --colorize, --showurls, --ignore, --noaggregate, --base) +Some options (project, processes, colorize, showurls, ignore, noaggregate, base, showtime) can be overridden by commandline options (--project, --processes, --colorize, --showurls, --ignore, --noaggregate, --base, --showtime) .RE .SH BUGS diff --git a/repa/list.py b/repa/list.py index 0d19d96..0e0251b 100755 --- a/repa/list.py +++ b/repa/list.py @@ -38,7 +38,8 @@ from repa.common import (OBS_PROJECT_PREFIX, Colorizer, from repa.obs import OBS from repa.main import sub_main -def get_status(meta, colorizer, build_results=None, ignore=''): +def get_status(meta, colorizer, build_results=None, ignore='', + obs=None, showtime=False): """Get overall status by analyzing package and image build status.""" if build_results: codes = set() @@ -71,7 +72,19 @@ def get_status(meta, colorizer, build_results=None, ignore=''): else: return colorizer.blue('waiting for images') - return colorizer.green('ready') + status = 'ready' + if obs and showtime: + # Add build time to the status + project = get_prerelease(meta['git_tag'], meta['obs_target_prj']) + btime = 0 + for (repo, arch), target in build_results.iteritems(): + btime = max(btime, obs.get_build_time(str(project), str(repo), + str(arch))) + minutes, seconds = divmod(btime, 60) + hours, minutes = divmod(minutes, 60) + status += " %02d:%02d:%02d" % (hours, minutes, seconds) + + return colorizer.green(status) def show_urls(meta): @@ -93,7 +106,7 @@ def get_sr(obs, project, package, tag, status): return sreq[0] def list_submissions(obs, target, processes, base, is_colorize=False, - showurls=False, ignore=''): + showurls=False, ignore='', showtime=False): """List submissions and groups.""" colorizer = Colorizer(is_colorize) # submissions @@ -123,15 +136,16 @@ def list_submissions(obs, target, processes, base, is_colorize=False, rsr = get_sr(obs, base, projects[0], tag, 'revoked') if rsr: base_status = colorizer.red('rejected. SR %s' % rsr) - print '%-37s %-37s %-37s %s' % \ (meta['git_tag'], - get_status(meta, colorizer, build_results, ignore), + get_status(meta, colorizer, build_results, + ignore, obs, showtime), base_status, ','.join(projects)) else: print '%-37s %-37s %s' % \ (meta['git_tag'], \ - get_status(meta, colorizer, build_results, ignore), + get_status(meta, colorizer, build_results, + ignore, obs, showtime), ','.join(projects)) if showurls: show_urls(meta) @@ -168,13 +182,17 @@ class List(object): help='ignore package failures by regexp') parser.add_argument('--base', default=config.get('base', ''), help='Show submission status in base project') + parser.add_argument('--showtime', action='store_true', + help='show build time', + default=config.get('showtime', '').lower() == 'on') @staticmethod def run(argv): """Command line entry point. Called from [sub_]main""" obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd) return list_submissions(obs, argv.project, argv.processes, argv.base, - argv.colorize, argv.showurls, argv.ignore) + argv.colorize, argv.showurls, argv.ignore, + argv.showtime) if __name__ == '__main__': diff --git a/repa/obs.py b/repa/obs.py index 572a639..d25017f 100644 --- a/repa/obs.py +++ b/repa/obs.py @@ -144,6 +144,17 @@ class OBS(OSC): return buildres + @retry((OSCError, HTTPError)) + def get_build_time(self, prj, repo, arch): + """Get build time for the project/repo/arch.""" + url = core.makeurl(self.apiurl, + ['build', prj, repo, arch, '_jobhistory']) + history = self.core_http(core.http_GET, url) + history_root = ET.parse(history).getroot() + seconds = 0 + for node in history_root.findall('jobhist'): + seconds += int(node.get('endtime')) - int(node.get('starttime')) + return seconds def get_source_packages(self, prj): """Get list of binary packages in the project.""" |