1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 01:06:17 +02:00

new jobhistory/buildhistory output format (CSV)

This commit is contained in:
Michal Cihar 2009-05-13 09:04:27 +00:00
parent 208c0f7f44
commit 0f3c3d8eaf
3 changed files with 30 additions and 9 deletions

1
NEWS
View File

@ -15,6 +15,7 @@
- osc can now store credentials in Gnome keyring if it is available
- new support for osc linkpac to specify cicount attribute
- new log/rlog output formats (CSV and XML)
- new jobhistory/buildhistory output format (CSV)
0.117:
- support checkout of single package via "osc co PACKAGE" when local dir is project

View File

@ -2167,6 +2167,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('', '--csv', action='store_true',
help='generate output in CSV (separated by |)')
@cmdln.alias('buildhist')
def do_buildhistory(self, subcmd, opts, platform, arch):
"""${cmd_name}: Shows the build history of a package
@ -2183,8 +2185,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch))
format = 'text'
if opts.csv:
format = 'csv'
print '\n'.join(get_buildhistory(apiurl, project, package, platform, arch, format))
@cmdln.option('', '--csv', action='store_true',
help='generate output in CSV (separated by |)')
@cmdln.alias('jobhist')
def do_jobhistory(self, subcmd, opts, platform, arch):
"""${cmd_name}: Shows the job history of a project
@ -2205,7 +2213,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
pass
apiurl = store_read_apiurl(wd)
print_jobhistory(apiurl, project, package, platform, arch)
format = 'text'
if opts.csv:
format = 'csv'
print_jobhistory(apiurl, project, package, platform, arch, format)
@cmdln.option('-r', '--revision', metavar='rev',

View File

@ -2908,7 +2908,7 @@ def get_buildconfig(apiurl, prj, package, platform, arch):
return f.read()
def get_buildhistory(apiurl, prj, package, platform, arch):
def get_buildhistory(apiurl, prj, package, platform, arch, format = 'text'):
import time
u = makeurl(apiurl, ['build', prj, platform, arch, package, '_history'])
f = http_GET(u)
@ -2923,13 +2923,17 @@ def get_buildhistory(apiurl, prj, package, platform, arch):
t = time.localtime(int(node.get('time')))
t = time.strftime('%Y-%m-%d %H:%M:%S', t)
r.append('%s %s %6d %s.%d' % (t, srcmd5, rev, versrel, bcnt))
if format == 'csv':
r.append('%s|%s|%d|%s.%d' % (t, srcmd5, rev, versrel, bcnt))
else:
r.append('%s %s %6d %s.%d' % (t, srcmd5, rev, versrel, bcnt))
r.insert(0, 'time srcmd5 rev vers-rel.bcnt')
if format == 'text':
r.insert(0, 'time srcmd5 rev vers-rel.bcnt')
return r
def print_jobhistory(apiurl, prj, current_package, platform, arch):
def print_jobhistory(apiurl, prj, current_package, platform, arch, format = 'text'):
import time
if current_package:
u = makeurl(apiurl, ['build', prj, platform, arch, '_jobhistory'], "package=%s" % (current_package))
@ -2938,7 +2942,8 @@ def print_jobhistory(apiurl, prj, current_package, platform, arch):
f = http_GET(u)
root = ET.parse(f).getroot()
print "time package reason code build time"
if format == 'text':
print "time package reason code build time"
for node in root.findall('jobhist'):
package = node.get('package')
reason = node.get('reason')
@ -2960,8 +2965,11 @@ def print_jobhistory(apiurl, prj, current_package, platform, arch):
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 %-50s %-16s %-16s %s' % (endtime, package[0:49], reason[0:15], code[0:15], waitbuild)
if format == 'csv':
print '%s|%s|%s|%s|%s' % (endtime, package, reason, code, waitbuild)
else:
print '%s %-50s %-16s %-16s %s' % (endtime, package[0:49], reason[0:15], code[0:15], waitbuild)
def get_commitlog(apiurl, prj, package, revision, format = 'text'):