changeset e479aa48ab71 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=e479aa48ab71
description: fix exception handling
diffstat:
plugins/dbus_plugin/plugin.py | 2 +-
src/command_system/framework.py | 2 +-
src/command_system/implementation/middleware.py | 4 +-
src/common/check_paths.py | 2 +-
src/common/configpaths.py | 2 +-
src/common/connection.py | 2 +-
src/common/connection_handlers.py | 6 +-
src/common/connection_handlers_events.py | 6 +-
src/common/contacts.py | 2 +-
src/common/dbus_support.py | 2 +-
src/common/ged.py | 4 +-
src/common/helpers.py | 10 ++--
src/common/idle.py | 2 +-
src/common/jingle_rtp.py | 6 +-
src/common/jingle_xtls.py | 4 +-
src/common/logger.py | 44 ++++++++++++------------
src/common/optparser.py | 8 ++--
src/common/passwords.py | 2 +-
src/common/proxy65_manager.py | 4 +-
src/common/rst_xhtml_generator.py | 2 +-
src/common/socks5.py | 38 ++++++++++----------
src/common/zeroconf/client_zeroconf.py | 8 ++--
src/common/zeroconf/zeroconf_avahi.py | 12 +++---
src/common/zeroconf/zeroconf_bonjour.py | 8 ++--
src/config.py | 12 +++---
src/conversation_textview.py | 2 +-
src/dataforms_widget.py | 2 +-
src/dialogs.py | 6 +-
src/disco.py | 4 +-
src/gtkgui_helpers.py | 10 ++--
src/gui_interface.py | 6 +-
src/history_manager.py | 2 +-
src/history_window.py | 2 +-
src/htmltextview.py | 4 +-
src/notify.py | 10 ++--
src/plugins/gui.py | 6 +-
src/plugins/pluginmanager.py | 24 ++++++------
src/plugins/plugins_i18n.py | 2 +-
src/profile_window.py | 2 +-
src/remote_control.py | 2 +-
src/roster_window.py | 2 +-
src/session.py | 14 +++---
test/integration/test_xmpp_transports_nb.py | 2 +-
test/runtests.py | 2 +-
44 files changed, 149 insertions(+), 149 deletions(-)
diffs (truncated from 1388 to 300 lines):
diff -r aacbaf27ca98 -r e479aa48ab71 plugins/dbus_plugin/plugin.py
--- a/plugins/dbus_plugin/plugin.py Tue Jan 01 21:06:16 2013 +0100
+++ b/plugins/dbus_plugin/plugin.py Tue Jan 01 23:18:36 2013 +0100
@@ -508,7 +508,7 @@
def prefs_store(self):
try:
gajim.interface.save_config()
- except Exception, e:
+ except Exception as e:
return DBUS_BOOLEAN(False)
return DBUS_BOOLEAN(True)
diff -r aacbaf27ca98 -r e479aa48ab71 src/command_system/framework.py
--- a/src/command_system/framework.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/command_system/framework.py Tue Jan 01 23:18:36 2013 +0100
@@ -165,7 +165,7 @@
# command or name attributes set. They will be set to a
# corresponding values right here in case if they was not set by
# the one who raised an exception.
- except CommandError, error:
+ except CommandError as error:
if not error.command and not error.name:
raise CommandError(error.message, self)
raise
diff -r aacbaf27ca98 -r e479aa48ab71
src/command_system/implementation/middleware.py
--- a/src/command_system/implementation/middleware.py Tue Jan 01 21:06:16
2013 +0100
+++ b/src/command_system/implementation/middleware.py Tue Jan 01 23:18:36
2013 +0100
@@ -62,13 +62,13 @@
try:
parents = super(ChatCommandProcessor, self)
parents.execute_command(name, arguments)
- except NoCommandError, error:
+ except NoCommandError as error:
details = dict(name=error.name, message=error.message)
message = "%(name)s: %(message)s\n" % details
message += "Try using the //%(name)s or /say /%(name)s " % details
message += "construct if you intended to send it as a text."
self.echo_error(message)
- except CommandError, error:
+ except CommandError as error:
self.echo_error("%s: %s" % (error.name, error.message))
except Exception:
self.echo_error(_("Error during command execution!"))
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/check_paths.py
--- a/src/common/check_paths.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/check_paths.py Tue Jan 01 23:18:36 2013 +0100
@@ -161,7 +161,7 @@
con.commit()
cur.executescript('DROP TABLE %s;' % table)
con.commit()
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
print('error moving table %s to cache.db: %s' % (table, str(e)),
file=sys.stderr)
con.close()
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/configpaths.py
--- a/src/common/configpaths.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/configpaths.py Tue Jan 01 23:18:36 2013 +0100
@@ -161,7 +161,7 @@
windowsify('plugins')))
try:
self.add('TMP', None, fse(tempfile.gettempdir()))
- except IOError, e:
+ except IOError as e:
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
os.path.expanduser('~')), file=sys.stderr)
self.add('TMP', None, fse(os.path.expanduser('~')))
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/connection.py
--- a/src/common/connection.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/connection.py Tue Jan 01 23:18:36 2013 +0100
@@ -455,7 +455,7 @@
log_msg = '<body xmlns="%s">%s</body>' % (
nbxmpp.NS_XHTML, xhtml)
gajim.logger.write(kind, jid, log_msg)
- except exceptions.PysqliteOperationalError, e:
+ except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/connection_handlers.py Tue Jan 01 23:18:36 2013 +0100
@@ -331,7 +331,7 @@
fil = open(path_to_file, 'w')
fil.write(str(card))
fil.close()
- except IOError, e:
+ except IOError as e:
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e)))
@@ -947,7 +947,7 @@
gajim.config.should_log(self.name, obj.jid):
try:
gajim.logger.write('status', obj.jid, obj.status, obj.show)
- except exceptions.PysqliteOperationalError, e:
+ except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
@@ -1069,7 +1069,7 @@
try:
gajim.logger.write('error', frm, error_msg, tim=tim,
subject=subject)
- except exceptions.PysqliteOperationalError, e:
+ except exceptions.PysqliteOperationalError as e:
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
except exceptions.DatabaseMalformed:
pritext = _('Database Error')
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/connection_handlers_events.py Tue Jan 01 23:18:36 2013 +0100
@@ -220,11 +220,11 @@
try:
t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ')
- except ValueError, e:
+ except ValueError as e:
try:
t = datetime.datetime.strptime(utc_time,
'%Y-%m-%dT%H:%M:%S.%fZ')
- except ValueError, e:
+ except ValueError as e:
log.info('Wrong time format: %s' % str(e))
return
@@ -905,7 +905,7 @@
try:
gajim.logger.write('gcstatus', self.fjid, st,
self.show)
- except exceptions.PysqliteOperationalError, e:
+ except exceptions.PysqliteOperationalError as e:
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
str(e)))
except exceptions.DatabaseMalformed:
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/contacts.py
--- a/src/common/contacts.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/contacts.py Tue Jan 01 23:18:36 2013 +0100
@@ -32,7 +32,7 @@
from common import caps_cache
from common.account import Account
import common.gajim
-except ImportError, e:
+except ImportError as e:
if __name__ != "__main__":
raise ImportError(e)
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/dbus_support.py
--- a/src/common/dbus_support.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/dbus_support.py Tue Jan 01 23:18:36 2013 +0100
@@ -154,7 +154,7 @@
return None
obj = bus.get_object(interface, path)
return dbus.Interface(obj, interface)
- except Exception, e:
+ except Exception as e:
gajim.log.debug(str(e))
return None
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/ged.py
--- a/src/common/ged.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/ged.py Tue Jan 01 23:18:36 2013 +0100
@@ -79,7 +79,7 @@
if event_name in self.handlers:
try:
self.handlers[event_name].remove((priority, handler))
- except ValueError, error:
+ except ValueError as error:
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, e:
+ except Exception as e:
log.error('Error while running an even handler: %s' % \
handler)
traceback.print_exc()
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/helpers.py
--- a/src/common/helpers.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/helpers.py Tue Jan 01 23:18:36 2013 +0100
@@ -207,7 +207,7 @@
while True:
try:
return func(*args, **kwargs)
- except (os.error, IOError, select.error), ex:
+ except (os.error, IOError, select.error) as ex:
if ex.errno == errno.EINTR:
continue
else:
@@ -1465,7 +1465,7 @@
req = urllib2.Request(attrs['src'])
req.add_header('User-Agent', 'Gajim ' + gajim.version)
f = urllib2.urlopen(req)
- except Exception, ex:
+ except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
@@ -1488,7 +1488,7 @@
break
try:
temp = f.read(100)
- except socket.timeout, ex:
+ except socket.timeout as ex:
log.debug('Timeout loading image %s ' % attrs['src'] + str(ex))
alt = attrs.get('alt', '')
if alt:
@@ -1540,7 +1540,7 @@
c.close()
t = b.getvalue()
return (t, attrs.get('alt', ''))
- except pycurl.error, ex:
+ except pycurl.error as ex:
alt = attrs.get('alt', '')
if alt:
alt += '\n'
@@ -1550,7 +1550,7 @@
alt += _('Timeout loading image')
else:
alt += _('Error loading image')
- except Exception, ex:
+ except Exception as ex:
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
pixbuf = None
alt = attrs.get('alt', 'Broken image')
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/idle.py
--- a/src/common/idle.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/idle.py Tue Jan 01 23:18:36 2013 +0100
@@ -68,7 +68,7 @@
rootwindow = libX11.XDefaultRootWindow(dpy_p)
xss_available = True
-except OSError, e:
+except OSError as e:
# Logging?
xss_available = False
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/jingle_rtp.py
--- a/src/common/jingle_rtp.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/jingle_rtp.py Tue Jan 01 23:18:36 2013 +0100
@@ -86,8 +86,8 @@
try:
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
socket.SOCK_STREAM)[0][4][0]
- except socket.gaierror, (errnum, errstr):
- log.warn('Lookup of stun ip failed: %s' % errstr)
+ except socket.gaierror as e:
+ log.warn('Lookup of stun ip failed: %s' % str(e))
else:
params['stun-ip'] = ip
@@ -104,7 +104,7 @@
try:
bin = gst.parse_bin_from_description(pipeline, True)
return bin
- except GError, error_str:
+ except GError as error_str:
gajim.nec.push_incoming_event(InformationEvent(None,
conn=self.session.connection, level='error',
pri_txt=_('%s configuration error') % text.capitalize(),
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/jingle_xtls.py
--- a/src/common/jingle_xtls.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/jingle_xtls.py Tue Jan 01 23:18:36 2013 +0100
@@ -63,7 +63,7 @@
return
try:
f = open(cert_path)
- except IOError, e:
+ except IOError as e:
log.warning('Unable to open certificate file %s: %s' % (cert_path,
str(e)))
return
@@ -79,7 +79,7 @@
x509cert = OpenSSL.crypto.load_certificate(
OpenSSL.crypto.FILETYPE_PEM, cert)
cert_store.add_cert(x509cert)
- except OpenSSL.crypto.Error, exception_obj:
+ except OpenSSL.crypto.Error as exception_obj:
log.warning('Unable to load a certificate from file %s: %s' %\
(cert_path, exception_obj.args[0][0][2]))
except:
diff -r aacbaf27ca98 -r e479aa48ab71 src/common/logger.py
--- a/src/common/logger.py Tue Jan 01 21:06:16 2013 +0100
+++ b/src/common/logger.py Tue Jan 01 23:18:36 2013 +0100
@@ -149,7 +149,7 @@
def attach_cache_database(self):
try:
self.cur.execute("ATTACH DATABASE '%s' AS cache" % CACHE_DB_PATH)
- except sqlite.Error, e:
+ except sqlite.Error as e:
log.debug("Failed to attach cache database: %s" % str(e))
def set_synchronous(self, sync):
@@ -158,7 +158,7 @@
self.cur.execute("PRAGMA synchronous = NORMAL")
else:
self.cur.execute("PRAGMA synchronous = OFF")
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits