Show
Ignore:
Timestamp:
08/30/07 01:27:32 (15 months ago)
Author:
roidelapluie
Message:

catch disk full errors. fixes #2937

Location:
branches/gajim_0.11.1/src/common
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.1/src/common/connection_handlers.py

    r8611 r8617  
    3535from common import gajim 
    3636from common import atom 
     37from common import exceptions 
    3738from common.commands import ConnectionCommands 
    3839from common.pubsub import ConnectionPubSub 
     
    870871                else: 
    871872                        path_to_file = path 
    872                 fil = open(path_to_file, 'w') 
    873                 fil.write(str(card)) 
    874                 fil.close() 
     873                try: 
     874                        fil = open(path_to_file, 'w') 
     875                        fil.write(str(card)) 
     876                        fil.close() 
     877                except IOError, e: 
     878                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    875879         
    876880        def get_cached_vcard(self, fjid, is_fake_jid = False): 
     
    14561460                                msgtxt = None 
    14571461                        if self.name not in no_log_for: 
    1458                                 gajim.logger.write('error', frm, error_msg, tim = tim, 
    1459                                         subject = subject) 
     1462                                try: 
     1463                                        gajim.logger.write('error', frm, error_msg, tim = tim, 
     1464                                                subject = subject) 
     1465                                except exceptions.PysqliteOperationalError, e: 
     1466                                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    14601467                        self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, 
    14611468                                tim)) 
     
    14761483                                if self.name not in no_log_for and not int(float(time.mktime(tim)))\ 
    14771484                                <= self.last_history_line[jid] and msgtxt: 
    1478                                         gajim.logger.write('gc_msg', frm, msgtxt, tim = tim) 
     1485                                        try: 
     1486                                                gajim.logger.write('gc_msg', frm, msgtxt, tim = tim) 
     1487                                        except exceptions.PysqliteOperationalError, e: 
     1488                                                self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    14791489                        return 
    14801490                elif mtype == 'chat': # it's type 'chat' 
     
    14831493                        if msg.getTag('body') and self.name not in no_log_for and jid not in\ 
    14841494                                no_log_for and msgtxt: 
    1485                                 msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim, 
    1486                                         subject = subject) 
     1495                                try: 
     1496                                        msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, 
     1497                                                tim = tim, subject = subject) 
     1498                                except exceptions.PysqliteOperationalError, e: 
     1499                                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    14871500                else: # it's single message 
    14881501                        if invite is not None: 
     
    14951508                                return 
    14961509                        if self.name not in no_log_for and jid not in no_log_for and msgtxt: 
    1497                                 gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim, 
    1498                                         subject = subject) 
     1510                                try: 
     1511                                        gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim, 
     1512                                                subject = subject) 
     1513                                except exceptions.PysqliteOperationalError, e: 
     1514                                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    14991515                        mtype = 'normal' 
    15001516                treat_as = gajim.config.get('treat_incoming_messages') 
     
    16481664                                                # we know real jid, save it in db 
    16491665                                                st += ' (%s)' % jid 
    1650                                         gajim.logger.write('gcstatus', who, st, show) 
     1666                                        try: 
     1667                                                gajim.logger.write('gcstatus', who, st, show) 
     1668                                        except exceptions.PysqliteOperationalError, e: 
     1669                                                self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    16511670                                if avatar_sha or avatar_sha == '': 
    16521671                                        if avatar_sha == '': 
     
    17561775                                self.request_vcard(jid_stripped) 
    17571776                if not ptype or ptype == 'unavailable': 
    1758                         if gajim.config.get('log_contact_status_changes') and self.name\ 
    1759                                 not in no_log_for and jid_stripped not in no_log_for: 
    1760                                 gajim.logger.write('status', jid_stripped, status, show) 
     1777                        if gajim.config.get('log_contact_status_changes') and self.name \ 
     1778                        not in no_log_for and jid_stripped not in no_log_for: 
     1779                                try: 
     1780                                        gajim.logger.write('status', jid_stripped, status, show) 
     1781                                except exceptions.PysqliteOperationalError, e: 
     1782                                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    17611783                        self.dispatch('NOTIFY', (jid_stripped, show, status, resource, prio, 
    17621784                                keyID, timestamp)) 
  • branches/gajim_0.11.1/src/common/connection.py

    r8608 r8617  
    3737from common import GnuPG 
    3838from common import passwords 
     39from common import exceptions 
    3940 
    4041from connection_handlers import * 
     
    782783                                else: 
    783784                                        kind = 'single_msg_sent' 
    784                                 gajim.logger.write(kind, jid, log_msg) 
     785                                try: 
     786                                        gajim.logger.write(kind, jid, log_msg) 
     787                                except exceptions.PysqliteOperationalError, e: 
     788                                        self.dispatch('ERROR', (_('Disk Write Error'), str(e))) 
    785789                self.dispatch('MSGSENT', (jid, msg, keyID)) 
    786790         
  • branches/gajim_0.11.1/src/common/exceptions.py

    r7130 r8617  
    2121        def __str__(self): 
    2222                return _('pysqlite2 (aka python-pysqlite2) dependency is missing. Exiting...') 
     23 
     24class PysqliteOperationalError(Exception): 
     25        '''sqlite2 raised pysqlite2.dbapi2.OperationalError''' 
     26        def __init__(self, text=''): 
     27                Exception.__init__(self) 
     28                self.text = text 
     29 
     30        def __str__(self): 
     31                return self.text 
    2332 
    2433class ServiceNotAvailable(Exception): 
  • branches/gajim_0.11.1/src/common/logger.py

    r8610 r8617  
    294294                #print 'saving', values 
    295295                sql = 'INSERT INTO logs (jid_id, contact_name, time, kind, show, message, subject) VALUES (?, ?, ?, ?, ?, ?, ?)' 
    296                 self.cur.execute(sql, values) 
     296                try: 
     297                        self.cur.execute(sql, values) 
     298                except sqlite.OperationalError, e: 
     299                        raise exceptions.PysqliteOperationalError(str(e)) 
    297300                message_id = None 
    298301                try: