catch disk full errors. fixes #2937
This commit is contained in:
parent
8709cdcd07
commit
952e6d96e3
5 changed files with 63 additions and 19 deletions
|
@ -36,6 +36,7 @@ from common import helpers
|
|||
from common import gajim
|
||||
from common import GnuPG
|
||||
from common import passwords
|
||||
from common import exceptions
|
||||
|
||||
from connection_handlers import *
|
||||
USE_GPG = GnuPG.USE_GPG
|
||||
|
@ -902,7 +903,10 @@ class Connection(ConnectionHandlers):
|
|||
kind = 'chat_msg_sent'
|
||||
else:
|
||||
kind = 'single_msg_sent'
|
||||
gajim.logger.write(kind, jid, log_msg)
|
||||
try:
|
||||
gajim.logger.write(kind, jid, log_msg)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
self.dispatch('MSGSENT', (jid, msg, keyID))
|
||||
|
||||
def send_stanza(self, stanza):
|
||||
|
|
|
@ -34,6 +34,7 @@ from common import GnuPG
|
|||
from common import helpers
|
||||
from common import gajim
|
||||
from common import atom
|
||||
from common import exceptions
|
||||
from common.commands import ConnectionCommands
|
||||
from common.pubsub import ConnectionPubSub
|
||||
from common.caps import ConnectionCaps
|
||||
|
@ -885,9 +886,12 @@ class ConnectionVcard:
|
|||
path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick)
|
||||
else:
|
||||
path_to_file = path
|
||||
fil = open(path_to_file, 'w')
|
||||
fil.write(str(card))
|
||||
fil.close()
|
||||
try:
|
||||
fil = open(path_to_file, 'w')
|
||||
fil.write(str(card))
|
||||
fil.close()
|
||||
except IOError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
|
||||
def get_cached_vcard(self, fjid, is_fake_jid = False):
|
||||
'''return the vcard as a dict
|
||||
|
@ -1504,8 +1508,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
error_msg = msgtxt
|
||||
msgtxt = None
|
||||
if self.name not in no_log_for:
|
||||
gajim.logger.write('error', frm, error_msg, tim = tim,
|
||||
subject = subject)
|
||||
try:
|
||||
gajim.logger.write('error', frm, error_msg, tim = tim,
|
||||
subject = subject)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
|
||||
tim))
|
||||
return
|
||||
|
@ -1524,15 +1531,21 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
||||
if self.name not in no_log_for and not int(float(mktime(tim)))\
|
||||
<= self.last_history_line[jid] and msgtxt:
|
||||
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
||||
try:
|
||||
gajim.logger.write('gc_msg', frm, msgtxt, tim = tim)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
return
|
||||
elif mtype == 'chat': # it's type 'chat'
|
||||
if not msg.getTag('body') and chatstate is None: #no <body>
|
||||
return
|
||||
if msg.getTag('body') and self.name not in no_log_for and jid not in\
|
||||
no_log_for and msgtxt:
|
||||
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
|
||||
subject = subject)
|
||||
try:
|
||||
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt,
|
||||
tim = tim, subject = subject)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
else: # it's single message
|
||||
if invite is not None:
|
||||
item = invite.getTag('invite')
|
||||
|
@ -1543,8 +1556,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
self.dispatch('GC_INVITATION',(frm, jid_from, reason, password))
|
||||
return
|
||||
if self.name not in no_log_for and jid not in no_log_for and msgtxt:
|
||||
gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim,
|
||||
subject = subject)
|
||||
try:
|
||||
gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim,
|
||||
subject = subject)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
mtype = 'normal'
|
||||
treat_as = gajim.config.get('treat_incoming_messages')
|
||||
if treat_as:
|
||||
|
@ -1698,7 +1714,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
if jid:
|
||||
# we know real jid, save it in db
|
||||
st += ' (%s)' % jid
|
||||
gajim.logger.write('gcstatus', who, st, show)
|
||||
try:
|
||||
gajim.logger.write('gcstatus', who, st, show)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
if avatar_sha or avatar_sha == '':
|
||||
if avatar_sha == '':
|
||||
# contact has no avatar
|
||||
|
@ -1805,9 +1824,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
# avatar has been updated
|
||||
self.request_vcard(jid_stripped)
|
||||
if not ptype or ptype == 'unavailable':
|
||||
if gajim.config.get('log_contact_status_changes') and self.name\
|
||||
not in no_log_for and jid_stripped not in no_log_for:
|
||||
gajim.logger.write('status', jid_stripped, status, show)
|
||||
if gajim.config.get('log_contact_status_changes') and self.name \
|
||||
not in no_log_for and jid_stripped not in no_log_for:
|
||||
try:
|
||||
gajim.logger.write('status', jid_stripped, status, show)
|
||||
except exceptions.PysqliteOperationalError, e:
|
||||
self.dispatch('ERROR', (_('Disk Write Error'), str(e)))
|
||||
self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio,
|
||||
keyID, timestamp, contact_nickname))
|
||||
# END presenceCB
|
||||
|
|
|
@ -21,6 +21,15 @@ class PysqliteNotAvailable(Exception):
|
|||
def __str__(self):
|
||||
return _('pysqlite2 (aka python-pysqlite2) dependency is missing. Exiting...')
|
||||
|
||||
class PysqliteOperationalError(Exception):
|
||||
'''sqlite2 raised pysqlite2.dbapi2.OperationalError'''
|
||||
def __init__(self, text=''):
|
||||
Exception.__init__(self)
|
||||
self.text = text
|
||||
|
||||
def __str__(self):
|
||||
return self.text
|
||||
|
||||
class ServiceNotAvailable(Exception):
|
||||
'''This exception is raised when we cannot use Gajim remotely'''
|
||||
def __init__(self):
|
||||
|
|
|
@ -289,7 +289,10 @@ class Logger:
|
|||
def commit_to_db(self, values, write_unread = False):
|
||||
#print 'saving', values
|
||||
sql = 'INSERT INTO logs (jid_id, contact_name, time, kind, show, message, subject) VALUES (?, ?, ?, ?, ?, ?, ?)'
|
||||
self.cur.execute(sql, values)
|
||||
try:
|
||||
self.cur.execute(sql, values)
|
||||
except sqlite.OperationalError, e:
|
||||
raise exceptions.PysqliteOperationalError(str(e))
|
||||
message_id = None
|
||||
try:
|
||||
self.con.commit()
|
||||
|
|
12
src/gajim.py
12
src/gajim.py
|
@ -317,9 +317,15 @@ pid_dir = os.path.dirname(pid_filename)
|
|||
if not os.path.exists(pid_dir):
|
||||
check_paths.create_path(pid_dir)
|
||||
# Create pid file
|
||||
f = open(pid_filename, 'w')
|
||||
f.write(str(os.getpid()))
|
||||
f.close()
|
||||
try:
|
||||
f = open(pid_filename, 'w')
|
||||
f.write(str(os.getpid()))
|
||||
f.close()
|
||||
except IOError, e:
|
||||
dlg = dialogs.ErrorDialog(_('Disk Write Error'), str(e))
|
||||
dlg.run()
|
||||
dlg.destroy()
|
||||
sys.exit()
|
||||
del pid_dir
|
||||
del f
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue