changeset 3c1a1ae44036 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=3c1a1ae44036 description: fix traceback handling fix struc and sha1 usage (use bytes instead of string)
diffstat:
plugins/dbus_plugin/plugin.py | 2 +- src/common/connection_handlers_events.py | 2 +- src/common/contacts.py | 2 +- src/common/ged.py | 4 +- src/common/helpers.py | 7 +- src/common/idle.py | 2 +- src/common/jingle_ft.py | 4 +- src/common/jingle_rtp.py | 4 +- src/common/logger.py | 16 +++--- src/common/optparser.py | 2 +- src/common/proxy65_manager.py | 8 +- src/common/socks5.py | 74 +++++++++++++++++-------------- src/common/zeroconf/client_zeroconf.py | 12 ++-- src/common/zeroconf/zeroconf_avahi.py | 2 +- src/common/zeroconf/zeroconf_bonjour.py | 4 +- src/config.py | 4 +- src/dialogs.py | 2 +- src/gajim.py | 2 +- src/gtkgui_helpers.py | 4 +- src/htmltextview.py | 2 +- src/plugins/pluginmanager.py | 22 ++++---- src/plugins/plugins_i18n.py | 2 +- src/remote_control.py | 2 +- test/unit/test_socks5.py | 23 ++++----- 24 files changed, 107 insertions(+), 101 deletions(-)
diffs (truncated from 756 to 300 lines):
diff -r a04906b5d788 -r 3c1a1ae44036 plugins/dbus_plugin/plugin.py --- a/plugins/dbus_plugin/plugin.py Fri Jan 04 23:11:07 2013 +0100 +++ b/plugins/dbus_plugin/plugin.py Sat Jan 05 00:03:36 2013 +0100 @@ -508,7 +508,7 @@ def prefs_store(self): try: gajim.interface.save_config() - except Exception as e: + except Exception: return DBUS_BOOLEAN(False) return DBUS_BOOLEAN(True)
diff -r a04906b5d788 -r 3c1a1ae44036 src/common/connection_handlers_events.py --- a/src/common/connection_handlers_events.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/connection_handlers_events.py Sat Jan 05 00:03:36 2013 +0100 @@ -218,7 +218,7 @@
try: t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ') - except ValueError as e: + except ValueError: try: t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%S.%fZ') diff -r a04906b5d788 -r 3c1a1ae44036 src/common/contacts.py --- a/src/common/contacts.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/contacts.py Sat Jan 05 00:03:36 2013 +0100 @@ -36,7 +36,7 @@ import common.gajim except ImportError as e: if __name__ != "__main__": - raise ImportError(e) + raise ImportError(str(e))
class XMPPEntity(object): """ diff -r a04906b5d788 -r 3c1a1ae44036 src/common/ged.py --- a/src/common/ged.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/ged.py Sat Jan 05 00:03:36 2013 +0100 @@ -79,7 +79,7 @@ if event_name in self.handlers: try: self.handlers[event_name].remove((priority, handler)) - except ValueError as error: + except ValueError: log.warn('''Function (%s) with priority "%s" never registered as handler of event "%s". Couldn't remove. Error: %s''' %(handler, priority, event_name, error)) @@ -94,7 +94,7 @@ return True except NodeProcessed: node_processed = True - except Exception as e: + except Exception: log.error('Error while running an even handler: %s' % \ handler) traceback.print_exc() diff -r a04906b5d788 -r 3c1a1ae44036 src/common/helpers.py --- a/src/common/helpers.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/helpers.py Sat Jan 05 00:03:36 2013 +0100 @@ -915,7 +915,8 @@ """ Return sha of sid + initiator + target used for proxy auth """ - return hashlib.sha1("%s%s%s" % (sid, initiator, target)).hexdigest() + return hashlib.sha1(("%s%s%s" % (sid, initiator, target)).encode('utf-8')).\ + hexdigest()
def remove_invalid_xml_chars(string): if string: @@ -1545,9 +1546,9 @@ alt = attrs.get('alt', '') if alt: alt += '\n' - if ex[0] == pycurl.E_FILESIZE_EXCEEDED: + if ex.errno == pycurl.E_FILESIZE_EXCEEDED: alt += _('Image is too big') - elif ex[0] == pycurl.E_OPERATION_TIMEOUTED: + elif ex.errno == pycurl.E_OPERATION_TIMEOUTED: alt += _('Timeout loading image') else: alt += _('Error loading image') diff -r a04906b5d788 -r 3c1a1ae44036 src/common/idle.py --- a/src/common/idle.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/idle.py Sat Jan 05 00:03:36 2013 +0100 @@ -68,7 +68,7 @@
rootwindow = libX11.XDefaultRootWindow(dpy_p) xss_available = True -except OSError as e: +except OSError: # Logging? xss_available = False
diff -r a04906b5d788 -r 3c1a1ae44036 src/common/jingle_ft.py --- a/src/common/jingle_ft.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/jingle_ft.py Sat Jan 05 00:03:36 2013 +0100 @@ -95,8 +95,8 @@ if gajim.contacts.is_gc_contact(session.connection.name, session.peerjid): roomjid = session.peerjid.split('/')[0] - dstaddr = hashlib.sha1('%s%s%s' % (self.file_props['sid'], - session.ourjid, roomjid)).hexdigest() + dstaddr = hashlib.sha1(('%s%s%s' % (self.file_props['sid'], + session.ourjid, roomjid)).encode('utf-8')).hexdigest() self.file_props.dstaddr = dstaddr self.state = STATE_NOT_STARTED self.states = {STATE_INITIALIZED : StateInitialized(self), diff -r a04906b5d788 -r 3c1a1ae44036 src/common/jingle_rtp.py --- a/src/common/jingle_rtp.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/jingle_rtp.py Sat Jan 05 00:03:36 2013 +0100 @@ -105,13 +105,13 @@ try: bin = gst.parse_bin_from_description(pipeline, True) return bin - except GError as error_str: + except GError as e: gajim.nec.push_incoming_event(InformationEvent(None, conn=self.session.connection, level='error', pri_txt=_('%s configuration error') % text.capitalize(), sec_txt=_("Couldn't setup %s. Check your configuration.\n\n" "Pipeline was:\n%s\n\nError was:\n%s") % (text, pipeline, - error_str))) + str(e)))) raise JingleContentSetupException
def add_remote_candidates(self, candidates): diff -r a04906b5d788 -r 3c1a1ae44036 src/common/logger.py --- a/src/common/logger.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/logger.py Sat Jan 05 00:03:36 2013 +0100 @@ -256,7 +256,7 @@ self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid, typ)) self.con.commit() - except sqlite.IntegrityError as e: + except sqlite.IntegrityError: # Jid already in DB, maybe added by another instance. re-read DB self.get_jids_already_in_db() return self.get_jid_id(jid, typestr) @@ -580,7 +580,7 @@ """ try: self.get_jid_id(jid) - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return [] where_sql, jid_tuple = self._build_contact_where(account, jid) @@ -624,7 +624,7 @@ """ try: self.get_jid_id(jid) - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return [] where_sql, jid_tuple = self._build_contact_where(account, jid) @@ -653,7 +653,7 @@ """ try: self.get_jid_id(jid) - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return []
@@ -694,7 +694,7 @@ """ try: self.get_jid_id(jid) - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return [] days_with_logs = [] @@ -736,7 +736,7 @@ else: try: jid_id = self.get_jid_id(jid, 'ROOM') - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return None where_sql = 'jid_id = ?' @@ -762,7 +762,7 @@ """ try: jid_id = self.get_jid_id(jid, 'ROOM') - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: # Error trying to create a new jid_id. This means there is no log return None where_sql = 'jid_id = %s' % jid_id @@ -802,7 +802,7 @@ for user in family: try: jid_id = self.get_jid_id(user['jid']) - except exceptions.PysqliteOperationalError as e: + except exceptions.PysqliteOperationalError: continue where_sql += 'jid_id = ?' jid_tuple += (jid_id,) diff -r a04906b5d788 -r 3c1a1ae44036 src/common/optparser.py --- a/src/common/optparser.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/optparser.py Sat Jan 05 00:03:36 2013 +0100 @@ -644,7 +644,7 @@ ''' ) con.commit() - except sqlite.OperationalError as e: + except sqlite.OperationalError: pass con.close() gajim.config.set('version', '0.11.4.4') diff -r a04906b5d788 -r 3c1a1ae44036 src/common/proxy65_manager.py --- a/src/common/proxy65_manager.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/proxy65_manager.py Sat Jan 05 00:03:36 2013 +0100 @@ -310,7 +310,7 @@ # read auth response if buff is None or len(buff) != 2: return None - version, method = struct.unpack('!BB', buff[:2]) + version, method = struct.unpack('!BB', buff[:2].encode('utf-8')) if version != 0x05 or method == 0xff: self.pollend() return @@ -334,7 +334,7 @@ self._send = self._sock.send self._recv = self._sock.recv except Exception as ee: - errnum = ee[0] + errnum = ee.errno # 56 is for freebsd if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK): # still trying to connect @@ -431,7 +431,7 @@ # read auth response if buff is None or len(buff) != 2: return None - version, method = struct.unpack('!BB', buff[:2]) + version, method = struct.unpack('!BB', buff[:2].encode('utf-8')) if version != 0x05 or method == 0xff: self.pollend() return @@ -443,7 +443,7 @@ # read connect response if buff is None or len(buff) < 2: return None - version, reply = struct.unpack('!BB', buff[:2]) + version, reply = struct.unpack('!BB', buff[:2].encode('utf-8')) if version != 0x05 or reply != 0x00: self.pollend() return diff -r a04906b5d788 -r 3c1a1ae44036 src/common/socks5.py --- a/src/common/socks5.py Fri Jan 04 23:11:07 2013 +0100 +++ b/src/common/socks5.py Sat Jan 05 00:03:36 2013 +0100 @@ -464,7 +464,7 @@ self._server = ai[4] break except socket.error as e: - if not isinstance(e, basestring) and e[0] == EINPROGRESS: + if e.errno == EINPROGRESS: break # for all other errors, we try other addresses continue @@ -482,7 +482,7 @@ self._send=self._sock.send self._recv=self._sock.recv except Exception as ee: - errnum = ee[0] + errnum = ee.errno self.connect_timeout += 1 if errnum == 111 or self.connect_timeout > 1000: self.queue._connection_refused(self.streamhost, self.file_props, @@ -581,7 +581,7 @@ """ received = '' try: - add = self._recv(64) + add = self._recv(64).decode('utf-8') except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError, OpenSSL.SSL.WantX509LookupError) as e: log.info('SSL rehandshake request : ' + repr(e)) @@ -603,7 +603,7 @@ OpenSSL.SSL.WantX509LookupError) as e: log.info('SSL rehandshake request :' + repr(e)) raise e - except Exception as e: + except Exception: self.disconnect() return len(raw_data)
@@ -614,7 +614,7 @@ else: try: self.open_file_for_reading() - except IOError as e: + except IOError: self.state = 8 # end connection self.disconnect()