enormous cleanup in untested code

This commit is contained in:
Nikos Kouremenos 2005-11-22 10:56:25 +00:00
parent 8bc51f5360
commit 3e9b8d6bd2
2 changed files with 12 additions and 17 deletions

View File

@ -101,18 +101,14 @@ class OptionsParser:
pass
self.__tempfile = os.path.join(base_dir, '.' + filename)
try:
fd = open(self.__tempfile, 'w')
except:
#chances are we cannot write file in a directory
err_str = _('Unable to write file in %s') % base_dir
print err_str
return err_str
f = open(self.__tempfile, 'w')
except IOError, e:
return str(e)
try:
gajim.config.foreach(self.write_line, fd)
except IOError, e:
fd.close()
return e.errno
fd.close()
return str(e)
f.close()
if os.path.exists(self.__filename):
# win32 needs this
try:
@ -122,7 +118,7 @@ class OptionsParser:
try:
os.rename(self.__tempfile, self.__filename)
except IOError, e:
return e.errno
return str(e)
os.chmod(self.__filename, 0600)
def update_config(self, old_version, new_version):

View File

@ -1204,19 +1204,18 @@ class Interface:
gajim.mutex_events_for_ui.unlock()
time.sleep(0.01) # so threads in connection.py have time to run
return True # renew timeout (loop for ever)
except KeyboardInterrupt:
except KeyboardInterrupt: # FIXME: can this happen?? CTRL+C IS CATCHED BY SIGNAL
sys.exit()
return False
def save_config(self):
err_code = parser.write()
if err_code is not None:
strerr = os.strerror(err_code)
print strerr
err_str = parser.write()
if err_str is not None:
print >> sys.stderr, err_str
# it is good to notify the user
# in case he or she cannot see the output of the console
dialogs.ErrorDialog(_('Cannot save your preferences'),
strerr).get_response()
dialogs.ErrorDialog(_('Could not save your settings and preferences'),
err_str).get_response()
sys.exit(1)
def __init__(self):