1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 18:26:15 +01:00

- don't do any exception handling in the sync() method of the metafile() class. It's up to the caller what to do in case of an exception

- edit_meta(): raise an exception instead of printing an "useless" error message.
- make "osc meta prjconf <project> -e" work again (probably r3702 caused the problem)
This commit is contained in:
Marcus Hüwe 2008-05-20 16:03:08 +00:00
parent 4d1612fb34
commit 3c5a25f1a5

View File

@ -1586,31 +1586,13 @@ class metafile:
os.unlink(self.filename) os.unlink(self.filename)
return True return True
try: print 'Sending meta data...'
print 'Sending meta data...' # don't do any exception handling... it's up to the caller what to do in case
http_PUT(self.url, file=self.filename) # of an exception
os.unlink(self.filename) http_PUT(self.url, file=self.filename)
print 'Done.' os.unlink(self.filename)
return True print 'Done.'
except urllib2.HTTPError, e: return True
# internal server error (probably the xml file is incorrect)
if e.code == 400:
print >>sys.stderr, 'Cannot save meta data.'
print >>sys.stderr, e
print >>sys.stderr, e.read()
return False
if e.code == 500:
print >>sys.stderr, 'Cannot save meta data. Unknown error.'
print >>sys.stderr, e
# 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
if conf.config['http_debug']:
print >>sys.stderr, e.read()
return False
else:
print >> sys.stderr, 'cannot save meta data - an unexpected error occured'
return False
# different types of metadata # different types of metadata
@ -1642,21 +1624,18 @@ def meta_exists(metatype,
create_new=True, create_new=True,
apiurl=None): apiurl=None):
data = None
if not apiurl: if not apiurl:
apiurl = conf.config['apiurl'] apiurl = conf.config['apiurl']
url = make_meta_url(metatype, path_args, apiurl) url = make_meta_url(metatype, path_args, apiurl)
try: try:
data = http_GET(url).readlines() data = http_GET(url).readlines()
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
if e.code == 404: if e.code == 404 and create_new:
if create_new: data = metatypes[metatype]['template']
data = metatypes[metatype]['template'] if template_args:
if template_args: data = data % template_args
data = data % template_args
else: else:
print >>sys.stderr, 'error getting metadata for type \'%s\' at URL \'%s\':' \ raise e
% (metatype, url)
return data return data
def make_meta_url(metatype, path_args=None, apiurl=None): def make_meta_url(metatype, path_args=None, apiurl=None):
@ -1688,9 +1667,6 @@ def edit_meta(metatype,
template_args, template_args,
create_new=True, create_new=True,
apiurl=apiurl) apiurl=apiurl)
if not data:
# meta_exists encountered an error
sys.exit(1)
if edit: if edit:
change_is_required = True change_is_required = True
@ -1703,7 +1679,10 @@ def edit_meta(metatype,
while 1: while 1:
os.system('%s %s' % (editor, f.filename)) os.system('%s %s' % (editor, f.filename))
if change_is_required == True: if change_is_required == True:
if not f.sync(): try:
f.sync()
except urllib2.HTTPError, e:
print e
input = raw_input('Try again? (yY = Yes - nN = No): ') input = raw_input('Try again? (yY = Yes - nN = No): ')
if input != 'y' and input != 'Y': if input != 'y' and input != 'Y':
break break