mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- improve usage info on meta command
- if PUT on metadata fails with a 500, and http_debug is True, print out the body of the server reply - rename update_pacmeta() to update_local_pacmeta() for clarity - rename update_filesmeta() to update_local_filesmeta() for clarity
This commit is contained in:
parent
3aa108d32a
commit
4944828bf1
@ -146,12 +146,19 @@ class Osc(cmdln.Cmdln):
|
||||
packages, or users. The type of metadata is specified by the word after
|
||||
"meta", like e.g. "meta prj".
|
||||
|
||||
prj denotes metadata of a buildservice project.
|
||||
prjconf denotes the (build) configuration of a project.
|
||||
pkg denotes metadata of a buildservice package.
|
||||
user denotes the metadata of a user.
|
||||
|
||||
With the --edit switch, the metadata can be edited. Per default, osc
|
||||
opens the program specified by the environmental variable EDITOR with a
|
||||
temporary file. Alternatively, content to be saved can be supplied via
|
||||
the --file switch.
|
||||
|
||||
The --create switch is subject to discussion and not implemented.
|
||||
The --create switch is subject to discussion and not implemented. The
|
||||
current behaviour is to create a non-existing resource implicitely, if
|
||||
while it is edited.
|
||||
|
||||
usage:
|
||||
osc meta <prj|pkg|prjconf|user> [-e|--edit [-f|--file] [-c|--create]] ARGS...
|
||||
@ -184,7 +191,6 @@ class Osc(cmdln.Cmdln):
|
||||
if not opts.edit:
|
||||
sys.stdout.write(''.join(show_project_meta(conf.config['apiurl'], project)))
|
||||
else:
|
||||
print 'XXX editing prj'
|
||||
edit_meta(metatype='prj',
|
||||
path_args = quote_plus(project),
|
||||
template_args = (project, conf.config['user']))
|
||||
@ -195,7 +201,6 @@ class Osc(cmdln.Cmdln):
|
||||
if not opts.edit:
|
||||
sys.stdout.write(''.join(show_package_meta(conf.config['apiurl'], project, package)))
|
||||
else:
|
||||
print 'XXX editing pac'
|
||||
edit_meta(metatype='pkg',
|
||||
path_args = (quote_plus(project), quote_plus(package)),
|
||||
template_args = (package, conf.config['user']))
|
||||
@ -206,7 +211,6 @@ class Osc(cmdln.Cmdln):
|
||||
if not opts.edit:
|
||||
sys.stdout.write(''.join(show_project_conf(conf.config['apiurl'], project)))
|
||||
else:
|
||||
print 'XXX editing prj'
|
||||
edit_meta(metatype='prjconf',
|
||||
path_args = quote_plus(project),
|
||||
template_args = None)
|
||||
@ -219,7 +223,6 @@ class Osc(cmdln.Cmdln):
|
||||
if r:
|
||||
sys.stdout.write(''.join(r))
|
||||
else:
|
||||
print 'XXX editing user'
|
||||
edit_meta(metatype='user',
|
||||
path_args = (quote_plus(user)),
|
||||
template_args = (user, user))
|
||||
@ -441,7 +444,7 @@ class Osc(cmdln.Cmdln):
|
||||
for p in pacs:
|
||||
|
||||
p.read_meta_from_spec(specfile)
|
||||
p.update_pac_meta()
|
||||
p.update_package_meta()
|
||||
|
||||
|
||||
@cmdln.alias('di')
|
||||
@ -849,7 +852,7 @@ class Osc(cmdln.Cmdln):
|
||||
print
|
||||
print 'Committed revision %s.' % p.rev
|
||||
|
||||
p.update_filesmeta()
|
||||
p.update_local_filesmeta()
|
||||
p.write_deletelist()
|
||||
|
||||
|
||||
@ -915,7 +918,7 @@ class Osc(cmdln.Cmdln):
|
||||
saved_modifiedfiles = [ f for f in p.filenamelist if p.status(f) == 'M' ]
|
||||
|
||||
oldp = p
|
||||
p.update_filesmeta(rev)
|
||||
p.update_local_filesmeta(rev)
|
||||
p = Package(p.dir)
|
||||
|
||||
# which files do no longer exist upstream?
|
||||
@ -953,7 +956,7 @@ class Osc(cmdln.Cmdln):
|
||||
pass
|
||||
|
||||
|
||||
p.update_pacmeta()
|
||||
p.update_local_pacmeta()
|
||||
|
||||
#print ljust(p.name, 45), 'At revision %s.' % p.rev
|
||||
print 'At revision %s.' % p.rev
|
||||
|
38
osc/core.py
38
osc/core.py
@ -400,13 +400,21 @@ class Package:
|
||||
|
||||
|
||||
|
||||
def update_filesmeta(self, revision=None):
|
||||
def update_local_filesmeta(self, revision=None):
|
||||
"""
|
||||
Update the local _files file in the store.
|
||||
It is replaced with the version pulled from upstream.
|
||||
"""
|
||||
meta = ''.join(show_files_meta(self.apiurl, self.prjname, self.name, revision))
|
||||
f = open(os.path.join(self.storedir, '_files'), 'w')
|
||||
f.write(meta)
|
||||
f.close()
|
||||
|
||||
def update_pacmeta(self):
|
||||
def update_local_pacmeta(self):
|
||||
"""
|
||||
Update the local _meta file in the store.
|
||||
It is replaced with the version pulled from upstream.
|
||||
"""
|
||||
meta = ''.join(show_package_meta(self.apiurl, self.prjname, self.name))
|
||||
f = open(os.path.join(self.storedir, '_meta'), 'w')
|
||||
f.write(meta)
|
||||
@ -552,25 +560,18 @@ rev: %s
|
||||
self.descr = descr
|
||||
|
||||
|
||||
def update_pac_meta(self, template=new_package_templ): # n.b.: not the same as Package.update_pacmeta
|
||||
import tempfile
|
||||
def update_package_meta(self):
|
||||
"""
|
||||
for the updatepacmetafromspec subcommand
|
||||
"""
|
||||
|
||||
import tempfile
|
||||
(fd, filename) = tempfile.mkstemp(prefix = 'osc_editmeta.', suffix = '.xml', dir = '/tmp')
|
||||
|
||||
try:
|
||||
u = makeurl(self.apiurl, ['source', self.prjname, self.name, '_meta'])
|
||||
m = http_GET(u).readlines()
|
||||
except urllib2.HTTPError, e:
|
||||
if e.code == 404:
|
||||
print 'package does not exist yet... creating it'
|
||||
m = template % (pac, conf.config['user'])
|
||||
else:
|
||||
print >>sys.stderr, 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac)
|
||||
print >>sys.stderr, e
|
||||
sys.exit(1)
|
||||
m = ''.join(show_package_meta(self.apiurl, self.prjname, self.name))
|
||||
|
||||
f = os.fdopen(fd, 'w')
|
||||
f.write(''.join(m))
|
||||
f.write(m)
|
||||
f.close()
|
||||
|
||||
tree = ET.parse(filename)
|
||||
@ -580,7 +581,7 @@ rev: %s
|
||||
|
||||
# FIXME: escape stuff for xml
|
||||
print '*' * 36, 'old', '*' * 36
|
||||
print ''.join(m)
|
||||
print m
|
||||
print '*' * 36, 'new', '*' * 36
|
||||
tree.write(sys.stdout)
|
||||
print '*' * 72
|
||||
@ -952,7 +953,8 @@ class metafile:
|
||||
# this may be unhelpful... because it may just print a big blob of uninteresting
|
||||
# ichain html and javascript... however it could potentially be useful if the orign
|
||||
# server returns an information body
|
||||
#print >>sys.stderr, e.read()
|
||||
if conf.config['http_debug']:
|
||||
print >>sys.stderr, e.read()
|
||||
return False
|
||||
else:
|
||||
print >> sys.stderr, 'cannot save meta data - an unexpected error occured'
|
||||
|
Loading…
Reference in New Issue
Block a user