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 gajim
|
||||||
from common import GnuPG
|
from common import GnuPG
|
||||||
from common import passwords
|
from common import passwords
|
||||||
|
from common import exceptions
|
||||||
|
|
||||||
from connection_handlers import *
|
from connection_handlers import *
|
||||||
USE_GPG = GnuPG.USE_GPG
|
USE_GPG = GnuPG.USE_GPG
|
||||||
|
@ -902,7 +903,10 @@ class Connection(ConnectionHandlers):
|
||||||
kind = 'chat_msg_sent'
|
kind = 'chat_msg_sent'
|
||||||
else:
|
else:
|
||||||
kind = 'single_msg_sent'
|
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))
|
self.dispatch('MSGSENT', (jid, msg, keyID))
|
||||||
|
|
||||||
def send_stanza(self, stanza):
|
def send_stanza(self, stanza):
|
||||||
|
|
|
@ -34,6 +34,7 @@ from common import GnuPG
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import atom
|
from common import atom
|
||||||
|
from common import exceptions
|
||||||
from common.commands import ConnectionCommands
|
from common.commands import ConnectionCommands
|
||||||
from common.pubsub import ConnectionPubSub
|
from common.pubsub import ConnectionPubSub
|
||||||
from common.caps import ConnectionCaps
|
from common.caps import ConnectionCaps
|
||||||
|
@ -885,9 +886,12 @@ class ConnectionVcard:
|
||||||
path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick)
|
path_to_file = os.path.join(gajim.VCARD_PATH, puny_jid, puny_nick)
|
||||||
else:
|
else:
|
||||||
path_to_file = path
|
path_to_file = path
|
||||||
fil = open(path_to_file, 'w')
|
try:
|
||||||
fil.write(str(card))
|
fil = open(path_to_file, 'w')
|
||||||
fil.close()
|
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):
|
def get_cached_vcard(self, fjid, is_fake_jid = False):
|
||||||
'''return the vcard as a dict
|
'''return the vcard as a dict
|
||||||
|
@ -1504,8 +1508,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
error_msg = msgtxt
|
error_msg = msgtxt
|
||||||
msgtxt = None
|
msgtxt = None
|
||||||
if self.name not in no_log_for:
|
if self.name not in no_log_for:
|
||||||
gajim.logger.write('error', frm, error_msg, tim = tim,
|
try:
|
||||||
subject = subject)
|
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,
|
self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt,
|
||||||
tim))
|
tim))
|
||||||
return
|
return
|
||||||
|
@ -1524,15 +1531,21 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
self.dispatch('GC_MSG', (frm, msgtxt, tim, has_timestamp, msghtml))
|
||||||
if self.name not in no_log_for and not int(float(mktime(tim)))\
|
if self.name not in no_log_for and not int(float(mktime(tim)))\
|
||||||
<= self.last_history_line[jid] and msgtxt:
|
<= 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
|
return
|
||||||
elif mtype == 'chat': # it's type 'chat'
|
elif mtype == 'chat': # it's type 'chat'
|
||||||
if not msg.getTag('body') and chatstate is None: #no <body>
|
if not msg.getTag('body') and chatstate is None: #no <body>
|
||||||
return
|
return
|
||||||
if msg.getTag('body') and self.name not in no_log_for and jid not in\
|
if msg.getTag('body') and self.name not in no_log_for and jid not in\
|
||||||
no_log_for and msgtxt:
|
no_log_for and msgtxt:
|
||||||
msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim,
|
try:
|
||||||
subject = subject)
|
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
|
else: # it's single message
|
||||||
if invite is not None:
|
if invite is not None:
|
||||||
item = invite.getTag('invite')
|
item = invite.getTag('invite')
|
||||||
|
@ -1543,8 +1556,11 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
self.dispatch('GC_INVITATION',(frm, jid_from, reason, password))
|
self.dispatch('GC_INVITATION',(frm, jid_from, reason, password))
|
||||||
return
|
return
|
||||||
if self.name not in no_log_for and jid not in no_log_for and msgtxt:
|
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,
|
try:
|
||||||
subject = subject)
|
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'
|
mtype = 'normal'
|
||||||
treat_as = gajim.config.get('treat_incoming_messages')
|
treat_as = gajim.config.get('treat_incoming_messages')
|
||||||
if treat_as:
|
if treat_as:
|
||||||
|
@ -1698,7 +1714,10 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if jid:
|
if jid:
|
||||||
# we know real jid, save it in db
|
# we know real jid, save it in db
|
||||||
st += ' (%s)' % jid
|
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 or avatar_sha == '':
|
||||||
if avatar_sha == '':
|
if avatar_sha == '':
|
||||||
# contact has no avatar
|
# contact has no avatar
|
||||||
|
@ -1805,9 +1824,12 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
# avatar has been updated
|
# avatar has been updated
|
||||||
self.request_vcard(jid_stripped)
|
self.request_vcard(jid_stripped)
|
||||||
if not ptype or ptype == 'unavailable':
|
if not ptype or ptype == 'unavailable':
|
||||||
if gajim.config.get('log_contact_status_changes') and self.name\
|
if gajim.config.get('log_contact_status_changes') and self.name \
|
||||||
not in no_log_for and jid_stripped not in no_log_for:
|
not in no_log_for and jid_stripped not in no_log_for:
|
||||||
gajim.logger.write('status', jid_stripped, status, show)
|
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,
|
self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio,
|
||||||
keyID, timestamp, contact_nickname))
|
keyID, timestamp, contact_nickname))
|
||||||
# END presenceCB
|
# END presenceCB
|
||||||
|
|
|
@ -21,6 +21,15 @@ class PysqliteNotAvailable(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _('pysqlite2 (aka python-pysqlite2) dependency is missing. Exiting...')
|
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):
|
class ServiceNotAvailable(Exception):
|
||||||
'''This exception is raised when we cannot use Gajim remotely'''
|
'''This exception is raised when we cannot use Gajim remotely'''
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -289,7 +289,10 @@ class Logger:
|
||||||
def commit_to_db(self, values, write_unread = False):
|
def commit_to_db(self, values, write_unread = False):
|
||||||
#print 'saving', values
|
#print 'saving', values
|
||||||
sql = 'INSERT INTO logs (jid_id, contact_name, time, kind, show, message, subject) 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
|
message_id = None
|
||||||
try:
|
try:
|
||||||
self.con.commit()
|
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):
|
if not os.path.exists(pid_dir):
|
||||||
check_paths.create_path(pid_dir)
|
check_paths.create_path(pid_dir)
|
||||||
# Create pid file
|
# Create pid file
|
||||||
f = open(pid_filename, 'w')
|
try:
|
||||||
f.write(str(os.getpid()))
|
f = open(pid_filename, 'w')
|
||||||
f.close()
|
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 pid_dir
|
||||||
del f
|
del f
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue