Changeset 9477
- Timestamp:
- 04/16/08 15:46:44 (7 months ago)
- Files:
-
- 1 modified
-
trunk/src/common/logger.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/common/logger.py
r9462 r9477 136 136 self.get_jids_already_in_db() 137 137 138 def simple_commit(self, sql_to_commit): 139 '''helper to commit''' 140 self.cur.execute(sql_to_commit) 141 try: 142 self.con.commit() 143 except sqlite.OperationalError, e: 144 print >> sys.stderr, str(e) 145 138 146 def get_jids_already_in_db(self): 139 147 try: … … 145 153 for row in rows: 146 154 # row[0] is first item of row (the only result here, the jid) 147 self.jids_already_in.append(row[0]) 155 if row[0] == '': 156 # malformed jid, ignore line 157 pass 158 else: 159 self.jids_already_in.append(row[0]) 148 160 149 161 def get_jids_in_db(self): … … 332 344 ''' add unread message with id: message_id''' 333 345 sql = 'INSERT INTO unread_messages VALUES (%d, %d)' % (message_id, jid_id) 334 self.cur.execute(sql) 335 try: 336 self.con.commit() 337 except sqlite.OperationalError, e: 338 print >> sys.stderr, str(e) 346 self.simple_commit(sql) 339 347 340 348 def set_read_messages(self, message_ids): … … 342 350 ids = ','.join([str(i) for i in message_ids]) 343 351 sql = 'DELETE FROM unread_messages WHERE message_id IN (%s)' % ids 344 self.cur.execute(sql) 345 try: 346 self.con.commit() 347 except sqlite.OperationalError, e: 348 print >> sys.stderr, str(e) 352 self.simple_commit(sql) 349 353 350 354 def get_unread_msgs(self): … … 626 630 sql = 'REPLACE INTO rooms_last_message_time VALUES (%d, %d)' % \ 627 631 (jid_id, time) 628 self.cur.execute(sql) 629 try: 630 self.con.commit() 631 except sqlite.OperationalError, e: 632 print >> sys.stderr, str(e) 632 self.simple_commit(sql) 633 633 634 634 def _build_contact_where(self, account, jid): … … 663 663 if result == type_id: 664 664 return 665 self.cur.execute( 666 'UPDATE transports_cache SET type = %d WHERE transport = "%s"' % ( 667 type_id, jid)) 668 try: 669 self.con.commit() 670 except sqlite.OperationalError, e: 671 print >> sys.stderr, str(e) 665 sql = 'UPDATE transports_cache SET type = %d WHERE transport = "%s"' %\ 666 (type_id, jid) 667 self.simple_commit(sql) 672 668 return 673 self.cur.execute( 674 'INSERT INTO transports_cache VALUES ("%s", %d)' % (jid, type_id)) 675 try: 676 self.con.commit() 677 except sqlite.OperationalError, e: 678 print >> sys.stderr, str(e) 669 sql = 'INSERT INTO transports_cache VALUES ("%s", %d)' % (jid, type_id) 670 self.simple_commit(sql) 679 671 680 672 def get_transports_type(self): … … 757 749 gzip.close() 758 750 data = string.getvalue() 759 s elf.cur.execute('''751 sql = ''' 760 752 INSERT INTO caps_cache ( node, ver, ext, data ) 761 753 VALUES (?, ?, ?, ?); 762 ''', (node, ver, ext, buffer(data))) # (1) -- note above 763 try: 764 self.con.commit() 765 except sqlite.OperationalError, e: 766 print >> sys.stderr, str(e) 754 ''', (node, ver, ext, buffer(data)) # (1) -- note above 755 self.simple_commit(sql)
