when IOError occurs during saving preferences

now print os.strerror of the error code
This commit is contained in:
Dimitur Kirov 2005-08-09 11:17:32 +00:00
parent 07fecda486
commit cdf6e034b8
2 changed files with 9 additions and 15 deletions

View file

@ -79,14 +79,8 @@ class OptionsParser:
try: try:
gajim.config.foreach(self.write_line, fd) gajim.config.foreach(self.write_line, fd)
except IOError, e: except IOError, e:
print e, dir(e), e.errno
if e.errno == 28:
err_str = _('No space left on device')
else:
err_str = e
print err_str
fd.close() fd.close()
return err_str return e.errno
fd.close() fd.close()
if os.path.exists(self.__filename): if os.path.exists(self.__filename):
# win32 needs this # win32 needs this
@ -96,8 +90,7 @@ class OptionsParser:
pass pass
try: try:
os.rename(self.__tempfile, self.__filename) os.rename(self.__tempfile, self.__filename)
except: except IOError, e:
err_str = _('Unable to open %s for writing\n') % (self.__filename) return e.errno
return err_str
return None return None

View file

@ -1020,11 +1020,12 @@ class Interface:
return False return False
def save_config(self): def save_config(self):
err_str = parser.write() err_code = parser.write()
if err_str is not None: if err_code is not None:
dialogs.ErrorDialog(_('Cannot save your preferences'), os.strerror(err_code)
err_str).get_response() # it is good to notify the user, in case he cannot see the output of the console
sys.exit(2) dialogs.ErrorDialog(_('Cannot save your preferences')).get_response()
sys.exit(1)
def enable_dbus(self): def enable_dbus(self):
if 'remote_control' not in globals(): if 'remote_control' not in globals():