parent
b00bff7f14
commit
d57c420112
|
@ -18,6 +18,13 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from common import gajim
|
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:
|
class OptionsParser:
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
@ -45,7 +52,7 @@ class OptionsParser:
|
||||||
fd = open(self.__filename)
|
fd = open(self.__filename)
|
||||||
except:
|
except:
|
||||||
if os.path.exists(self.__filename):
|
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
|
return
|
||||||
|
|
||||||
for line in fd.readlines():
|
for line in fd.readlines():
|
||||||
|
@ -66,10 +73,30 @@ class OptionsParser:
|
||||||
fd.write(s + " = " + str(value[1]) + "\n")
|
fd.write(s + " = " + str(value[1]) + "\n")
|
||||||
|
|
||||||
def write(self):
|
def write(self):
|
||||||
|
(base_dir, filename) = os.path.split(self.__filename)
|
||||||
|
self.__tempfile = os.path.join(base_dir, '.'+filename)
|
||||||
try:
|
try:
|
||||||
fd = open(self.__filename, 'w')
|
fd = open(self.__tempfile, 'w')
|
||||||
except:
|
except:
|
||||||
print 'error: cannot open %s for writing\n' % (self.__filename)
|
err_str = _('Unable to write file in %s\n') % (base_dir)
|
||||||
return
|
print err_str
|
||||||
|
return err_str
|
||||||
|
try:
|
||||||
gajim.config.foreach(self.write_line, fd)
|
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()
|
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
|
||||||
|
|
||||||
|
|
|
@ -911,7 +911,11 @@ class Interface:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def save_config(self):
|
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):
|
def enable_dbus(self):
|
||||||
if 'remote_control' not in globals():
|
if 'remote_control' not in globals():
|
||||||
|
|
Loading…
Reference in New Issue