summaryrefslogtreecommitdiff
path: root/src/tabs.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-04-05 23:57:53 +0200
committermathieui <mathieui@mathieui.net>2013-04-05 23:57:53 +0200
commit91b960b797bbf17f6c4b33279f2d406c5a2c93b2 (patch)
tree91cbb61f2618d448416f4a41043ef2327793a53b /src/tabs.py
parent16268ba96460c0947be7208cba60ad95270a4da7 (diff)
downloadpoezio-91b960b797bbf17f6c4b33279f2d406c5a2c93b2.tar.gz
poezio-91b960b797bbf17f6c4b33279f2d406c5a2c93b2.tar.bz2
poezio-91b960b797bbf17f6c4b33279f2d406c5a2c93b2.tar.xz
poezio-91b960b797bbf17f6c4b33279f2d406c5a2c93b2.zip
Handle I/O errors better
- Do not crash because of low disk space - Notify the user whenever it happens - A few functions now return a boolean instead of nothing - Config.silent_set is Config.set_and_save without toggle and returning strings. It is used whenever we don’t need set_and_save - Config.set_and_save now returns a tuple (that can be passed directly to core.information()) TODO: display the precise error to the user (instead of “unable to…”)
Diffstat (limited to 'src/tabs.py')
-rw-r--r--src/tabs.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tabs.py b/src/tabs.py
index bbae6e3d..ef31da67 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -481,7 +481,8 @@ class ChatTab(Tab):
"""
Log the messages in the archives.
"""
- logger.log_message(self.name, nickname, txt, date=time)
+ if not logger.log_message(self.name, nickname, txt, date=time):
+ self.core.information(_('Unable to write in the log file'), 'Error')
def add_message(self, txt, time=None, nickname=None, forced_user=None, nick_color=None, identifier=None):
self._text_buffer.add_message(txt, time=time,
@@ -1696,7 +1697,8 @@ class MucTab(ChatTab):
to be
"""
if time is None and self.joined: # don't log the history messages
- logger.log_message(self.name, nickname, txt)
+ if not logger.log_message(self.name, nickname, txt):
+ self.core.information(_('Unable to write in the log file'), 'Error')
def do_highlight(self, txt, time, nickname):
"""
@@ -1844,7 +1846,8 @@ class PrivateTab(ChatTab):
msg = self.core.xmpp.make_message(self.get_name())
msg['type'] = 'chat'
msg['body'] = line
- logger.log_message(self.get_name().replace('/', '\\'), self.own_nick, line)
+ if not logger.log_message(self.get_name().replace('/', '\\'), self.own_nick, line):
+ self.core.information(_('Unable to write in the log file'), 'Error')
# trigger the event BEFORE looking for colors.
# This lets a plugin insert \x19xxx} colors, that will
# be converted in xhtml.
@@ -2722,9 +2725,11 @@ class RosterInfoTab(Tab):
"""
option = 'roster_show_offline'
if config.get(option, 'false') == 'false':
- config.set_and_save(option, 'true')
+ success = config.silent_set(option, 'true')
else:
- config.set_and_save(option, 'false')
+ success = config.silent_set(option, 'false')
+ if not success:
+ self.information(_('Unable to write in the config file'), 'Error')
return True
def on_slash(self):
@@ -3036,7 +3041,8 @@ class ConversationTab(ChatTab):
self.core.events.trigger('conversation_say_after', msg, self)
self.last_sent_message = msg
msg.send()
- logger.log_message(safeJID(self.get_dest_jid()).bare, self.core.own_nick, line)
+ if not logger.log_message(safeJID(self.get_dest_jid()).bare, self.core.own_nick, line):
+ self.core.information(_('Unable to write in the log file'), 'Error')
self.cancel_paused_delay()
self.text_win.refresh()
self.input.refresh()