1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- change 'buildhistory' to display human-readable text

- add 'deleteprj' command and delete_project() method. Note: the API server
  doesn't seem to support it yet.
- add 'prjresults' command to display aggregated build status over the entire
  project
- 'rebuildpac': accept additional repo and arch argument. Note: the syntax has
  changed.
- 'log': print usage info if called with missing arguments
This commit is contained in:
Dr. Peter Poeml 2006-09-25 15:11:03 +00:00
parent a79f38bb54
commit 2321509096
3 changed files with 175 additions and 9 deletions

1
TODO
View File

@ -117,6 +117,7 @@ so those 3 are valid:
"http://api.opensuse.org/source/ruby/ruby?cmd=rebuild&arch=i586"
"http://api.opensuse.org/source/ruby/ruby?cmd=rebuild&repo=SUSE_Factory&arch=i586"
osc rebuildpac [project [package]] [arch=arch] [repos]
http://api.opensuse.org/result/Apache/SUSE_Linux_10.0/apache2/result

View File

@ -219,6 +219,28 @@ usage: osc deletepac <prj> <pac>
delete_package(project, package)
def deleteprj(args):
"""deleteprj: Delete a project on the server.
usage: osc deleteprj <prj>
As a safety measure, project must be empty (i.e., you first need to delete all
packages first).
"""
if not args or len(args) < 1:
print 'missing argument'
print
print deleteprj.func_doc
sys.exit(1)
project = args[0]
if meta_get_packagelist(project) != []:
sys.exit('project must be empty before deleting it.')
delete_project(project)
def updatepacmetafromspec(args):
"""Update package meta information from a specfile
@ -641,6 +663,30 @@ usage: 1. osc results # package = current dir
print '\n'.join(get_results(project, package, platform))
def prjresults(args):
"""Shows the aggregated build results of an entire project
usage: 1. osc prjresults # package = current dir
2. osc prjresults <packagedir>
"""
if args and len(args) > 1:
print 'getting results for more than one project is not supported'
print sys.exit(1)
if args:
wd = args[0]
else:
wd = os.curdir
try:
project = store_read_project(wd)
except:
sys.exit('\'%s\' is not an osc project directory' % wd)
print '\n'.join(get_prj_results(project))
def log(args):
"""log: Shows the log file from a package (you need to be inside a package directory)
@ -649,6 +695,13 @@ usage: osc log <platform> <arch>
To find out <platform> and <arch>, you can use 'osc results'
"""
if not args or len(args) != 2:
print 'missing argument'
print
print log.func_doc
sys.exit(1)
wd = os.curdir
package = store_read_package(wd)
project = store_read_project(wd)
@ -822,18 +875,30 @@ usage: osc buildhistory <platform> <arch>
platform = args[0]
arch = args[1]
print ''.join(get_buildhistory(project, package, platform, arch))
print '\n'.join(get_buildhistory(project, package, platform, arch))
def rebuildpac(args):
"""rebuildpac: Triggers a package rebuild for all repositories/architectures of the package
usage: osc rebuildpac <pacdir>
usage: osc rebuildpac <project> <package> [<repo> [<arch>]]
"""
args = parseargs(args)
pacs = findpacs(args)
for p in pacs:
print p.name + ':', cmd_rebuild(p.prjname, p.name)
if args is None or len(args) < 2:
print 'missing argument'
print
print rebuildpac.func_doc
sys.exit(1)
repo = arch = None
project = args[0]
package = args[1]
if len(args) > 2:
repo = args[2]
if len(args) > 3:
arch = args[3]
print package + ':', cmd_rebuild(project, package, repo, arch)
def help(args):
@ -879,6 +944,7 @@ cmd_dict = {
checkout: ['checkout', 'co'],
updatepacmetafromspec: ['updatepacmetafromspec'],
deletepac: ['deletepac'],
deleteprj: ['deleteprj'],
diff: ['diff'],
editmeta: ['editmeta'],
editpac: ['editpac', 'createpac'],
@ -898,6 +964,7 @@ cmd_dict = {
repourls: ['repourls'],
resolved: ['resolved'],
results: ['results'],
prjresults: ['prjresults'],
results_meta: ['results_meta'],
rebuildpac: ['rebuildpac'],
status: ['status', 'st'],

View File

@ -100,6 +100,17 @@ HERE
"""
buildstatus_symbols = {'succeeded': '.',
'disabled': ' ',
'expansion error': 'E',
'failed': 'F',
'broken': 'B',
'blocked': 'b',
'building': '%',
'scheduled': 's',
}
class File:
"""represent a file, including its metadata"""
def __init__(self, name, md5, size, mtime):
@ -1106,6 +1117,13 @@ def delete_package(prj, pac):
othermethods.delfile(u, pac, username, password)
def delete_project(prj):
import othermethods
u = makeurl(['source', prj])
othermethods.delfile(u, prj, username, password)
def get_platforms():
f = urlopen(makeurl(['platform']))
tree = ET.parse(f)
@ -1140,6 +1158,12 @@ def show_results_meta(prj, package, platform):
return f.readlines()
def show_prj_results_meta(prj):
u = makeurl(['result', prj, 'packstatus'])
f = urlopen(u)
return f.readlines()
def get_results(prj, package, platform):
#print '----------------------------------------'
@ -1174,6 +1198,58 @@ def get_results(prj, package, platform):
return r
def get_prj_results(prj):
#print '----------------------------------------'
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(prj)
tree = ET.parse(StringIO(''.join(f)))
root = tree.getroot()
pacs = []
for node in root.find('packstatuslist'):
pacs.append(node.get('name'))
offset = 0
for pac in pacs:
r.append(' |' * offset + ' ' + pac)
offset += 1
target = {}
for node in root.findall('packstatuslist'):
target['repo'] = node.get('repository')
target['arch'] = node.get('arch')
status = {}
for pacnode in node.findall('packstatus'):
try:
status[pacnode.get('name')] = buildstatus_symbols[pacnode.get('status')]
except:
print 'osc: warn: unknown status \'%s\'...' % pacnode.get('status')
print 'please edit osc/core.py, and extend the buildstatus_symbols dictionary.'
status[pacnode.get('name')] = '?'
line = []
line.append(' ')
for pac in pacs:
line.append(status[pac])
line.append(' ')
line.append(' %s %s' % (target['repo'], target['arch']))
line = ''.join(line)
r.append(line)
r.append('')
r.append(' Legend:')
for i, j in buildstatus_symbols.items():
r.append(' %s %s' % (j, i))
return r
def get_log(prj, package, platform, arch, offset):
u = makeurl(['result', prj, platform, package, arch, 'log?nostream=1&start=%s' % offset])
f = urlopen(u)
@ -1195,13 +1271,35 @@ def get_buildconfig(prj, package, platform, arch):
def get_buildhistory(prj, package, platform, arch):
import time
u = makeurl(['rpm', prj, platform, arch, package, 'history'])
f = urlopen(u)
return f.readlines()
root = ET.parse(f).getroot()
r = []
for node in root.findall('entry'):
rev = int(node.get('rev'))
srcmd5 = node.get('srcmd5')
versrel = node.get('versrel')
bcnt = int(node.get('bcnt'))
t = time.gmtime(int(node.get('time')))
t = time.strftime('%Y-%m-%d %H:%M:%S', t)
r.append('%s %s %6d %2d %s' % (t, srcmd5, rev, bcnt, versrel))
r.insert(0, 'time srcmd5 rev bcnt vers-rel')
return r
def cmd_rebuild(prj, package):
u = makeurl(['source', prj, package, '?cmd=rebuild'])
def cmd_rebuild(prj, package, repo, arch):
cmd = '?cmd=rebuild'
if repo:
cmd += '&repo=%s' % repo
if arch:
cmd += '&arch=%s' % arch
u = makeurl(['source', prj, package, cmd])
try:
# adding data to the request makes it a POST
f = urllib2.urlopen(u, data=' ')