show notification if there is no space on the

device
This commit is contained in:
Dimitur Kirov 2005-08-01 09:37:41 +00:00
parent b00bff7f14
commit d57c420112
2 changed files with 38 additions and 7 deletions

View File

@ -18,6 +18,13 @@
import os
from common import gajim
from common import i18n
from gtk import glade
i18n.init()
_ = i18n._
APP = i18n.APP
glade.bindtextdomain(APP, i18n.DIR)
glade.textdomain(APP)
class OptionsParser:
def __init__(self, filename):
@ -45,7 +52,7 @@ class OptionsParser:
fd = open(self.__filename)
except:
if os.path.exists(self.__filename):
print 'error: cannot open %s for reading\n' % (self.__filename)
print _('error: cannot open %s for reading\n') % (self.__filename)
return
for line in fd.readlines():
@ -66,10 +73,30 @@ class OptionsParser:
fd.write(s + " = " + str(value[1]) + "\n")
def write(self):
(base_dir, filename) = os.path.split(self.__filename)
self.__tempfile = os.path.join(base_dir, '.'+filename)
try:
fd = open(self.__filename, 'w')
fd = open(self.__tempfile, 'w')
except:
print 'error: cannot open %s for writing\n' % (self.__filename)
return
err_str = _('Unable to write file in %s\n') % (base_dir)
print err_str
return err_str
try:
gajim.config.foreach(self.write_line, fd)
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()
return err_str
fd.close()
try:
os.rename(self.__tempfile, self.__filename)
except:
err_str = _('Unable to open %s for writing\n') % (self.__filename)
return err_str
return None

View File

@ -911,7 +911,11 @@ class Interface:
return False
def save_config(self):
parser.write()
err_str = parser.write()
if err_str is not None:
dialogs.ErrorDialog(_('Cannot save your preferences'),
err_str).get_response()
sys.exit(2)
def enable_dbus(self):
if 'remote_control' not in globals():