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

View File

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