mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-15 01:56:17 +01:00
- always remove tempfile
- cleaned up metafile() class
This commit is contained in:
parent
51768ba3c2
commit
a116d8f354
55
osc/core.py
55
osc/core.py
@ -2200,7 +2200,6 @@ class metafile:
|
|||||||
if self.change_is_required == True and hash == self.hash_orig:
|
if self.change_is_required == True and hash == self.hash_orig:
|
||||||
print 'File unchanged. Not saving.'
|
print 'File unchanged. Not saving.'
|
||||||
os.unlink(self.filename)
|
os.unlink(self.filename)
|
||||||
return True
|
|
||||||
|
|
||||||
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
|
# don't do any exception handling... it's up to the caller what to do in case
|
||||||
@ -2208,18 +2207,18 @@ class metafile:
|
|||||||
http_PUT(self.url, file=self.filename)
|
http_PUT(self.url, file=self.filename)
|
||||||
os.unlink(self.filename)
|
os.unlink(self.filename)
|
||||||
print 'Done.'
|
print 'Done.'
|
||||||
return True
|
|
||||||
|
|
||||||
def edit(self):
|
def edit(self):
|
||||||
if sys.platform[:3] != 'win':
|
if sys.platform[:3] != 'win':
|
||||||
editor = os.getenv('EDITOR', default='vim')
|
editor = os.getenv('EDITOR', default='vim')
|
||||||
else:
|
else:
|
||||||
editor = os.getenv('EDITOR', default='notepad')
|
editor = os.getenv('EDITOR', default='notepad')
|
||||||
while 1:
|
try:
|
||||||
subprocess.call('%s %s' % (editor, self.filename), shell=True)
|
while 1:
|
||||||
if self.change_is_required == True:
|
subprocess.call('%s %s' % (editor, self.filename), shell=True)
|
||||||
try:
|
try:
|
||||||
self.sync()
|
self.sync()
|
||||||
|
break
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
error_help = "%d" % e.code
|
error_help = "%d" % e.code
|
||||||
if e.headers.get('X-Opensuse-Errorcode'):
|
if e.headers.get('X-Opensuse-Errorcode'):
|
||||||
@ -2232,21 +2231,15 @@ class metafile:
|
|||||||
if '<summary>' in data:
|
if '<summary>' in data:
|
||||||
print >>sys.stderr, data.split('<summary>')[1].split('</summary>')[0]
|
print >>sys.stderr, data.split('<summary>')[1].split('</summary>')[0]
|
||||||
input = raw_input('Try again? ([y/N]): ')
|
input = raw_input('Try again? ([y/N]): ')
|
||||||
if input != 'y' and input != 'Y':
|
if input not in ['y', 'Y']:
|
||||||
break
|
break
|
||||||
else:
|
finally:
|
||||||
break
|
self.discard()
|
||||||
else:
|
|
||||||
self.sync()
|
|
||||||
break
|
|
||||||
self.discard()
|
|
||||||
return self
|
|
||||||
|
|
||||||
def discard(self):
|
def discard(self):
|
||||||
if os.path.exists(self.filename):
|
if os.path.exists(self.filename):
|
||||||
print 'discarding', self.filename
|
print 'discarding %s' % self.filename
|
||||||
os.unlink(self.filename)
|
os.unlink(self.filename)
|
||||||
return self
|
|
||||||
|
|
||||||
|
|
||||||
# different types of metadata
|
# different types of metadata
|
||||||
@ -2453,24 +2446,24 @@ def edit_message(footer='', template=''):
|
|||||||
editor = os.getenv('EDITOR', default='vim')
|
editor = os.getenv('EDITOR', default='vim')
|
||||||
else:
|
else:
|
||||||
editor = os.getenv('EDITOR', default='notepad')
|
editor = os.getenv('EDITOR', default='notepad')
|
||||||
while 1:
|
try:
|
||||||
subprocess.call('%s %s' % (editor, filename), shell=True)
|
while 1:
|
||||||
msg = open(filename).read().split(delim)[0].rstrip()
|
subprocess.call('%s %s' % (editor, filename), shell=True)
|
||||||
|
msg = open(filename).read().split(delim)[0].rstrip()
|
||||||
|
|
||||||
if len(msg):
|
if len(msg):
|
||||||
break
|
|
||||||
else:
|
|
||||||
input = raw_input('Log message not specified\n'
|
|
||||||
'a)bort, c)ontinue, e)dit: ')
|
|
||||||
if input in 'aA':
|
|
||||||
os.unlink(filename)
|
|
||||||
raise oscerr.UserAbort
|
|
||||||
elif input in 'cC':
|
|
||||||
break
|
break
|
||||||
elif input in 'eE':
|
else:
|
||||||
pass
|
input = raw_input('Log message not specified\n'
|
||||||
|
'a)bort, c)ontinue, e)dit: ')
|
||||||
os.unlink(filename)
|
if input in 'aA':
|
||||||
|
raise oscerr.UserAbort()
|
||||||
|
elif input in 'cC':
|
||||||
|
break
|
||||||
|
elif input in 'eE':
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
os.unlink(filename)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user