fix exception handling
This commit is contained in:
parent
069bddbbcb
commit
d27591076f
|
@ -508,7 +508,7 @@ if dbus_support.supported:
|
||||||
def prefs_store(self):
|
def prefs_store(self):
|
||||||
try:
|
try:
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return DBUS_BOOLEAN(False)
|
return DBUS_BOOLEAN(False)
|
||||||
return DBUS_BOOLEAN(True)
|
return DBUS_BOOLEAN(True)
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ class Command(object):
|
||||||
# command or name attributes set. They will be set to a
|
# command or name attributes set. They will be set to a
|
||||||
# corresponding values right here in case if they was not set by
|
# corresponding values right here in case if they was not set by
|
||||||
# the one who raised an exception.
|
# the one who raised an exception.
|
||||||
except CommandError, error:
|
except CommandError as error:
|
||||||
if not error.command and not error.name:
|
if not error.command and not error.name:
|
||||||
raise CommandError(error.message, self)
|
raise CommandError(error.message, self)
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -62,13 +62,13 @@ class ChatCommandProcessor(CommandProcessor):
|
||||||
try:
|
try:
|
||||||
parents = super(ChatCommandProcessor, self)
|
parents = super(ChatCommandProcessor, self)
|
||||||
parents.execute_command(name, arguments)
|
parents.execute_command(name, arguments)
|
||||||
except NoCommandError, error:
|
except NoCommandError as error:
|
||||||
details = dict(name=error.name, message=error.message)
|
details = dict(name=error.name, message=error.message)
|
||||||
message = "%(name)s: %(message)s\n" % details
|
message = "%(name)s: %(message)s\n" % details
|
||||||
message += "Try using the //%(name)s or /say /%(name)s " % details
|
message += "Try using the //%(name)s or /say /%(name)s " % details
|
||||||
message += "construct if you intended to send it as a text."
|
message += "construct if you intended to send it as a text."
|
||||||
self.echo_error(message)
|
self.echo_error(message)
|
||||||
except CommandError, error:
|
except CommandError as error:
|
||||||
self.echo_error("%s: %s" % (error.name, error.message))
|
self.echo_error("%s: %s" % (error.name, error.message))
|
||||||
except Exception:
|
except Exception:
|
||||||
self.echo_error(_("Error during command execution!"))
|
self.echo_error(_("Error during command execution!"))
|
||||||
|
|
|
@ -161,7 +161,7 @@ def split_db():
|
||||||
con.commit()
|
con.commit()
|
||||||
cur.executescript('DROP TABLE %s;' % table)
|
cur.executescript('DROP TABLE %s;' % table)
|
||||||
con.commit()
|
con.commit()
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
print('error moving table %s to cache.db: %s' % (table, str(e)),
|
print('error moving table %s to cache.db: %s' % (table, str(e)),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
con.close()
|
con.close()
|
||||||
|
|
|
@ -161,7 +161,7 @@ class ConfigPaths:
|
||||||
windowsify('plugins')))
|
windowsify('plugins')))
|
||||||
try:
|
try:
|
||||||
self.add('TMP', None, fse(tempfile.gettempdir()))
|
self.add('TMP', None, fse(tempfile.gettempdir()))
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
|
print('Error opening tmp folder: %s\nUsing %s' % (str(e),
|
||||||
os.path.expanduser('~')), file=sys.stderr)
|
os.path.expanduser('~')), file=sys.stderr)
|
||||||
self.add('TMP', None, fse(os.path.expanduser('~')))
|
self.add('TMP', None, fse(os.path.expanduser('~')))
|
||||||
|
|
|
@ -455,7 +455,7 @@ class CommonConnection:
|
||||||
log_msg = '<body xmlns="%s">%s</body>' % (
|
log_msg = '<body xmlns="%s">%s</body>' % (
|
||||||
nbxmpp.NS_XHTML, xhtml)
|
nbxmpp.NS_XHTML, xhtml)
|
||||||
gajim.logger.write(kind, jid, log_msg)
|
gajim.logger.write(kind, jid, log_msg)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
self.dispatch('DB_ERROR', (_('Disk Write Error'),
|
||||||
str(e)))
|
str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
|
|
|
@ -331,7 +331,7 @@ class ConnectionVcard:
|
||||||
fil = open(path_to_file, 'w')
|
fil = open(path_to_file, 'w')
|
||||||
fil.write(str(card))
|
fil.write(str(card))
|
||||||
fil.close()
|
fil.close()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
gajim.nec.push_incoming_event(InformationEvent(None, conn=self,
|
||||||
level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e)))
|
level='error', pri_txt=_('Disk Write Error'), sec_txt=str(e)))
|
||||||
|
|
||||||
|
@ -947,7 +947,7 @@ class ConnectionHandlersBase:
|
||||||
gajim.config.should_log(self.name, obj.jid):
|
gajim.config.should_log(self.name, obj.jid):
|
||||||
try:
|
try:
|
||||||
gajim.logger.write('status', obj.jid, obj.status, obj.show)
|
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)))
|
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
pritext = _('Database Error')
|
pritext = _('Database Error')
|
||||||
|
@ -1069,7 +1069,7 @@ class ConnectionHandlersBase:
|
||||||
try:
|
try:
|
||||||
gajim.logger.write('error', frm, error_msg, tim=tim,
|
gajim.logger.write('error', frm, error_msg, tim=tim,
|
||||||
subject=subject)
|
subject=subject)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
pritext = _('Database Error')
|
pritext = _('Database Error')
|
||||||
|
|
|
@ -220,11 +220,11 @@ class TimeResultReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ')
|
t = datetime.datetime.strptime(utc_time, '%Y-%m-%dT%H:%M:%SZ')
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
try:
|
try:
|
||||||
t = datetime.datetime.strptime(utc_time,
|
t = datetime.datetime.strptime(utc_time,
|
||||||
'%Y-%m-%dT%H:%M:%S.%fZ')
|
'%Y-%m-%dT%H:%M:%S.%fZ')
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
log.info('Wrong time format: %s' % str(e))
|
log.info('Wrong time format: %s' % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -905,7 +905,7 @@ class GcPresenceReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
|
||||||
try:
|
try:
|
||||||
gajim.logger.write('gcstatus', self.fjid, st,
|
gajim.logger.write('gcstatus', self.fjid, st,
|
||||||
self.show)
|
self.show)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
|
self.conn.dispatch('DB_ERROR', (_('Disk Write Error'),
|
||||||
str(e)))
|
str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
|
|
|
@ -32,7 +32,7 @@ try:
|
||||||
from common import caps_cache
|
from common import caps_cache
|
||||||
from common.account import Account
|
from common.account import Account
|
||||||
import common.gajim
|
import common.gajim
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
if __name__ != "__main__":
|
if __name__ != "__main__":
|
||||||
raise ImportError(e)
|
raise ImportError(e)
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ def get_interface(interface, path, start_service=True):
|
||||||
return None
|
return None
|
||||||
obj = bus.get_object(interface, path)
|
obj = bus.get_object(interface, path)
|
||||||
return dbus.Interface(obj, interface)
|
return dbus.Interface(obj, interface)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class GlobalEventsDispatcher(object):
|
||||||
if event_name in self.handlers:
|
if event_name in self.handlers:
|
||||||
try:
|
try:
|
||||||
self.handlers[event_name].remove((priority, handler))
|
self.handlers[event_name].remove((priority, handler))
|
||||||
except ValueError, error:
|
except ValueError as error:
|
||||||
log.warn('''Function (%s) with priority "%s" never registered
|
log.warn('''Function (%s) with priority "%s" never registered
|
||||||
as handler of event "%s". Couldn\'t remove. Error: %s'''
|
as handler of event "%s". Couldn\'t remove. Error: %s'''
|
||||||
%(handler, priority, event_name, error))
|
%(handler, priority, event_name, error))
|
||||||
|
@ -94,7 +94,7 @@ class GlobalEventsDispatcher(object):
|
||||||
return True
|
return True
|
||||||
except NodeProcessed:
|
except NodeProcessed:
|
||||||
node_processed = True
|
node_processed = True
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Error while running an even handler: %s' % \
|
log.error('Error while running an even handler: %s' % \
|
||||||
handler)
|
handler)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
|
@ -207,7 +207,7 @@ def temp_failure_retry(func, *args, **kwargs):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except (os.error, IOError, select.error), ex:
|
except (os.error, IOError, select.error) as ex:
|
||||||
if ex.errno == errno.EINTR:
|
if ex.errno == errno.EINTR:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
@ -1465,7 +1465,7 @@ def _get_img_direct(attrs):
|
||||||
req = urllib2.Request(attrs['src'])
|
req = urllib2.Request(attrs['src'])
|
||||||
req.add_header('User-Agent', 'Gajim ' + gajim.version)
|
req.add_header('User-Agent', 'Gajim ' + gajim.version)
|
||||||
f = urllib2.urlopen(req)
|
f = urllib2.urlopen(req)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
|
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
alt = attrs.get('alt', 'Broken image')
|
alt = attrs.get('alt', 'Broken image')
|
||||||
|
@ -1488,7 +1488,7 @@ def _get_img_direct(attrs):
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
temp = f.read(100)
|
temp = f.read(100)
|
||||||
except socket.timeout, ex:
|
except socket.timeout as ex:
|
||||||
log.debug('Timeout loading image %s ' % attrs['src'] + str(ex))
|
log.debug('Timeout loading image %s ' % attrs['src'] + str(ex))
|
||||||
alt = attrs.get('alt', '')
|
alt = attrs.get('alt', '')
|
||||||
if alt:
|
if alt:
|
||||||
|
@ -1540,7 +1540,7 @@ def _get_img_proxy(attrs, proxy):
|
||||||
c.close()
|
c.close()
|
||||||
t = b.getvalue()
|
t = b.getvalue()
|
||||||
return (t, attrs.get('alt', ''))
|
return (t, attrs.get('alt', ''))
|
||||||
except pycurl.error, ex:
|
except pycurl.error as ex:
|
||||||
alt = attrs.get('alt', '')
|
alt = attrs.get('alt', '')
|
||||||
if alt:
|
if alt:
|
||||||
alt += '\n'
|
alt += '\n'
|
||||||
|
@ -1550,7 +1550,7 @@ def _get_img_proxy(attrs, proxy):
|
||||||
alt += _('Timeout loading image')
|
alt += _('Timeout loading image')
|
||||||
else:
|
else:
|
||||||
alt += _('Error loading image')
|
alt += _('Error loading image')
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
|
log.debug('Error loading image %s ' % attrs['src'] + str(ex))
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
alt = attrs.get('alt', 'Broken image')
|
alt = attrs.get('alt', 'Broken image')
|
||||||
|
|
|
@ -68,7 +68,7 @@ try:
|
||||||
|
|
||||||
rootwindow = libX11.XDefaultRootWindow(dpy_p)
|
rootwindow = libX11.XDefaultRootWindow(dpy_p)
|
||||||
xss_available = True
|
xss_available = True
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
# Logging?
|
# Logging?
|
||||||
xss_available = False
|
xss_available = False
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,8 @@ class JingleRTPContent(JingleContent):
|
||||||
try:
|
try:
|
||||||
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
|
ip = socket.getaddrinfo(stun_server, 0, socket.AF_UNSPEC,
|
||||||
socket.SOCK_STREAM)[0][4][0]
|
socket.SOCK_STREAM)[0][4][0]
|
||||||
except socket.gaierror, (errnum, errstr):
|
except socket.gaierror as e:
|
||||||
log.warn('Lookup of stun ip failed: %s' % errstr)
|
log.warn('Lookup of stun ip failed: %s' % str(e))
|
||||||
else:
|
else:
|
||||||
params['stun-ip'] = ip
|
params['stun-ip'] = ip
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class JingleRTPContent(JingleContent):
|
||||||
try:
|
try:
|
||||||
bin = gst.parse_bin_from_description(pipeline, True)
|
bin = gst.parse_bin_from_description(pipeline, True)
|
||||||
return bin
|
return bin
|
||||||
except GError, error_str:
|
except GError as error_str:
|
||||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||||
conn=self.session.connection, level='error',
|
conn=self.session.connection, level='error',
|
||||||
pri_txt=_('%s configuration error') % text.capitalize(),
|
pri_txt=_('%s configuration error') % text.capitalize(),
|
||||||
|
|
|
@ -63,7 +63,7 @@ def load_cert_file(cert_path, cert_store):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
f = open(cert_path)
|
f = open(cert_path)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
log.warning('Unable to open certificate file %s: %s' % (cert_path,
|
log.warning('Unable to open certificate file %s: %s' % (cert_path,
|
||||||
str(e)))
|
str(e)))
|
||||||
return
|
return
|
||||||
|
@ -79,7 +79,7 @@ def load_cert_file(cert_path, cert_store):
|
||||||
x509cert = OpenSSL.crypto.load_certificate(
|
x509cert = OpenSSL.crypto.load_certificate(
|
||||||
OpenSSL.crypto.FILETYPE_PEM, cert)
|
OpenSSL.crypto.FILETYPE_PEM, cert)
|
||||||
cert_store.add_cert(x509cert)
|
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' %\
|
log.warning('Unable to load a certificate from file %s: %s' %\
|
||||||
(cert_path, exception_obj.args[0][0][2]))
|
(cert_path, exception_obj.args[0][0][2]))
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Logger:
|
||||||
def attach_cache_database(self):
|
def attach_cache_database(self):
|
||||||
try:
|
try:
|
||||||
self.cur.execute("ATTACH DATABASE '%s' AS cache" % CACHE_DB_PATH)
|
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))
|
log.debug("Failed to attach cache database: %s" % str(e))
|
||||||
|
|
||||||
def set_synchronous(self, sync):
|
def set_synchronous(self, sync):
|
||||||
|
@ -158,7 +158,7 @@ class Logger:
|
||||||
self.cur.execute("PRAGMA synchronous = NORMAL")
|
self.cur.execute("PRAGMA synchronous = NORMAL")
|
||||||
else:
|
else:
|
||||||
self.cur.execute("PRAGMA synchronous = OFF")
|
self.cur.execute("PRAGMA synchronous = OFF")
|
||||||
except sqlite.Error, e:
|
except sqlite.Error as e:
|
||||||
log.debug("Failed to set_synchronous(%s): %s" % (sync, str(e)))
|
log.debug("Failed to set_synchronous(%s): %s" % (sync, str(e)))
|
||||||
|
|
||||||
def init_vars(self):
|
def init_vars(self):
|
||||||
|
@ -168,7 +168,7 @@ class Logger:
|
||||||
def _really_commit(self):
|
def _really_commit(self):
|
||||||
try:
|
try:
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
print(str(e), file=sys.stderr)
|
print(str(e), file=sys.stderr)
|
||||||
self.commit_timout_id = None
|
self.commit_timout_id = None
|
||||||
return False
|
return False
|
||||||
|
@ -256,11 +256,11 @@ class Logger:
|
||||||
self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid,
|
self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid,
|
||||||
typ))
|
typ))
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
except sqlite.IntegrityError, e:
|
except sqlite.IntegrityError as e:
|
||||||
# Jid already in DB, maybe added by another instance. re-read DB
|
# Jid already in DB, maybe added by another instance. re-read DB
|
||||||
self.get_jids_already_in_db()
|
self.get_jids_already_in_db()
|
||||||
return self.get_jid_id(jid, typestr)
|
return self.get_jid_id(jid, typestr)
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
jid_id = self.cur.lastrowid
|
jid_id = self.cur.lastrowid
|
||||||
self.jids_already_in.append(jid)
|
self.jids_already_in.append(jid)
|
||||||
|
@ -407,14 +407,14 @@ class Logger:
|
||||||
self.cur.execute(sql, values)
|
self.cur.execute(sql, values)
|
||||||
except sqlite.DatabaseError:
|
except sqlite.DatabaseError:
|
||||||
raise exceptions.DatabaseMalformed
|
raise exceptions.DatabaseMalformed
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
message_id = None
|
message_id = None
|
||||||
if write_unread:
|
if write_unread:
|
||||||
try:
|
try:
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
message_id = self.cur.lastrowid
|
message_id = self.cur.lastrowid
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
print(str(e), file=sys.stderr)
|
print(str(e), file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
self._timeout_commit()
|
self._timeout_commit()
|
||||||
|
@ -522,7 +522,7 @@ class Logger:
|
||||||
# status for roster items
|
# status for roster items
|
||||||
try:
|
try:
|
||||||
jid_id = self.get_jid_id(jid)
|
jid_id = self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
if show is None: # show is None (xmpp), but we say that 'online'
|
if show is None: # show is None (xmpp), but we say that 'online'
|
||||||
show_col = constants.SHOW_ONLINE
|
show_col = constants.SHOW_ONLINE
|
||||||
|
@ -535,7 +535,7 @@ class Logger:
|
||||||
try:
|
try:
|
||||||
# re-get jid_id for the new jid
|
# re-get jid_id for the new jid
|
||||||
jid_id = self.get_jid_id(jid, 'ROOM')
|
jid_id = self.get_jid_id(jid, 'ROOM')
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
contact_name_col = nick
|
contact_name_col = nick
|
||||||
|
|
||||||
|
@ -549,13 +549,13 @@ class Logger:
|
||||||
try:
|
try:
|
||||||
# re-get jid_id for the new jid
|
# re-get jid_id for the new jid
|
||||||
jid_id = self.get_jid_id(jid, 'ROOM')
|
jid_id = self.get_jid_id(jid, 'ROOM')
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
contact_name_col = nick
|
contact_name_col = nick
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
jid_id = self.get_jid_id(jid)
|
jid_id = self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
if kind == 'chat_msg_recv':
|
if kind == 'chat_msg_recv':
|
||||||
if not self.jid_is_from_pm(jid):
|
if not self.jid_is_from_pm(jid):
|
||||||
|
@ -580,7 +580,7 @@ class Logger:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.get_jid_id(jid)
|
self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return []
|
return []
|
||||||
where_sql, jid_tuple = self._build_contact_where(account, jid)
|
where_sql, jid_tuple = self._build_contact_where(account, jid)
|
||||||
|
@ -624,7 +624,7 @@ class Logger:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.get_jid_id(jid)
|
self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return []
|
return []
|
||||||
where_sql, jid_tuple = self._build_contact_where(account, jid)
|
where_sql, jid_tuple = self._build_contact_where(account, jid)
|
||||||
|
@ -653,14 +653,14 @@ class Logger:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.get_jid_id(jid)
|
self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if False: # query.startswith('SELECT '): # it's SQL query (FIXME)
|
if False: # query.startswith('SELECT '): # it's SQL query (FIXME)
|
||||||
try:
|
try:
|
||||||
self.cur.execute(query)
|
self.cur.execute(query)
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
results = [('', '', '', '', str(e))]
|
results = [('', '', '', '', str(e))]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ class Logger:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
self.get_jid_id(jid)
|
self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return []
|
return []
|
||||||
days_with_logs = []
|
days_with_logs = []
|
||||||
|
@ -736,7 +736,7 @@ class Logger:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
jid_id = self.get_jid_id(jid, 'ROOM')
|
jid_id = self.get_jid_id(jid, 'ROOM')
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return None
|
return None
|
||||||
where_sql = 'jid_id = ?'
|
where_sql = 'jid_id = ?'
|
||||||
|
@ -762,7 +762,7 @@ class Logger:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
jid_id = self.get_jid_id(jid, 'ROOM')
|
jid_id = self.get_jid_id(jid, 'ROOM')
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
# Error trying to create a new jid_id. This means there is no log
|
# Error trying to create a new jid_id. This means there is no log
|
||||||
return None
|
return None
|
||||||
where_sql = 'jid_id = %s' % jid_id
|
where_sql = 'jid_id = %s' % jid_id
|
||||||
|
@ -802,7 +802,7 @@ class Logger:
|
||||||
for user in family:
|
for user in family:
|
||||||
try:
|
try:
|
||||||
jid_id = self.get_jid_id(user['jid'])
|
jid_id = self.get_jid_id(user['jid'])
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
continue
|
continue
|
||||||
where_sql += 'jid_id = ?'
|
where_sql += 'jid_id = ?'
|
||||||
jid_tuple += (jid_id,)
|
jid_tuple += (jid_id,)
|
||||||
|
@ -988,7 +988,7 @@ class Logger:
|
||||||
try:
|
try:
|
||||||
account_jid_id = self.get_jid_id(account_jid)
|
account_jid_id = self.get_jid_id(account_jid)
|
||||||
jid_id = self.get_jid_id(jid)
|
jid_id = self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
self.cur.execute(
|
self.cur.execute(
|
||||||
'DELETE FROM roster_group WHERE account_jid_id=? AND jid_id=?',
|
'DELETE FROM roster_group WHERE account_jid_id=? AND jid_id=?',
|
||||||
|
@ -1010,7 +1010,7 @@ class Logger:
|
||||||
try:
|
try:
|
||||||
account_jid_id = self.get_jid_id(account_jid)
|
account_jid_id = self.get_jid_id(account_jid)
|
||||||
jid_id = self.get_jid_id(jid)
|
jid_id = self.get_jid_id(jid)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
|
|
||||||
# Update groups information
|
# Update groups information
|
||||||
|
@ -1150,7 +1150,7 @@ class Logger:
|
||||||
# when we quit this muc
|
# when we quit this muc
|
||||||
obj.conn.last_history_time[obj.jid] = tim_f
|
obj.conn.last_history_time[obj.jid] = tim_f
|
||||||
|
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
obj.conn.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
obj.conn.dispatch('DB_ERROR', (_('Disk Write Error'), str(e)))
|
||||||
except exceptions.DatabaseMalformed:
|
except exceptions.DatabaseMalformed:
|
||||||
pritext = _('Database Error')
|
pritext = _('Database Error')
|
||||||
|
|
|
@ -102,11 +102,11 @@ class OptionsParser:
|
||||||
self.__tempfile = os.path.join(base_dir, '.' + filename)
|
self.__tempfile = os.path.join(base_dir, '.' + filename)
|
||||||
try:
|
try:
|
||||||
f = open(self.__tempfile, 'w')
|
f = open(self.__tempfile, 'w')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
try:
|
try:
|
||||||
gajim.config.foreach(self.write_line, f)
|
gajim.config.foreach(self.write_line, f)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
f.flush()
|
f.flush()
|
||||||
os.fsync(f.fileno())
|
os.fsync(f.fileno())
|
||||||
|
@ -120,7 +120,7 @@ class OptionsParser:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
os.rename(self.__tempfile, self.__filename)
|
os.rename(self.__tempfile, self.__filename)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
return str(e)
|
return str(e)
|
||||||
os.chmod(self.__filename, 0600)
|
os.chmod(self.__filename, 0600)
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ class OptionsParser:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
con.commit()
|
con.commit()
|
||||||
except sqlite.OperationalError, e:
|
except sqlite.OperationalError as e:
|
||||||
pass
|
pass
|
||||||
con.close()
|
con.close()
|
||||||
gajim.config.set('version', '0.11.4.4')
|
gajim.config.set('version', '0.11.4.4')
|
||||||
|
|
|
@ -81,7 +81,7 @@ class GnomePasswordStorage(PasswordStorage):
|
||||||
## migrate the password over to keyring
|
## migrate the password over to keyring
|
||||||
try:
|
try:
|
||||||
self.save_password(account_name, password, update=False)
|
self.save_password(account_name, password, update=False)
|
||||||
except GnomeKeyringError, e:
|
except GnomeKeyringError as e:
|
||||||
if e.error == GnomeKeyring.Result.NO_KEYRING_DAEMON:
|
if e.error == GnomeKeyring.Result.NO_KEYRING_DAEMON:
|
||||||
## no keyring daemon: in the future, stop using it
|
## no keyring daemon: in the future, stop using it
|
||||||
set_storage(SimplePasswordStorage())
|
set_storage(SimplePasswordStorage())
|
||||||
|
|
|
@ -333,7 +333,7 @@ class HostTester(Socks5, IdleObject):
|
||||||
log.debug('Host Connecting to %s:%s' % (self.host, self.port))
|
log.debug('Host Connecting to %s:%s' % (self.host, self.port))
|
||||||
self._send = self._sock.send
|
self._send = self._sock.send
|
||||||
self._recv = self._sock.recv
|
self._recv = self._sock.recv
|
||||||
except Exception, ee:
|
except Exception as ee:
|
||||||
errnum = ee[0]
|
errnum = ee[0]
|
||||||
# 56 is for freebsd
|
# 56 is for freebsd
|
||||||
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
|
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
|
||||||
|
@ -461,7 +461,7 @@ class ReceiverTester(Socks5, IdleObject):
|
||||||
log.debug('Receiver Connecting to %s:%s' % (self.host, self.port))
|
log.debug('Receiver Connecting to %s:%s' % (self.host, self.port))
|
||||||
self._send = self._sock.send
|
self._send = self._sock.send
|
||||||
self._recv = self._sock.recv
|
self._recv = self._sock.recv
|
||||||
except Exception, ee:
|
except Exception as ee:
|
||||||
errnum = ee[0]
|
errnum = ee[0]
|
||||||
# 56 is for freebsd
|
# 56 is for freebsd
|
||||||
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
|
if errnum in (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK):
|
||||||
|
|
|
@ -65,7 +65,7 @@ else:
|
||||||
options={}, content=[]):
|
options={}, content=[]):
|
||||||
try:
|
try:
|
||||||
valid_text = validator(text)
|
valid_text = validator(text)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
msg = inliner.reporter.error( e.message % dict(text=text), line=lineno)
|
msg = inliner.reporter.error( e.message % dict(text=text), line=lineno)
|
||||||
prb = inliner.problematic(rawtext, rawtext, msg)
|
prb = inliner.problematic(rawtext, rawtext, msg)
|
||||||
return [prb], [msg]
|
return [prb], [msg]
|
||||||
|
|
|
@ -463,7 +463,7 @@ class Socks5:
|
||||||
self._sock.setblocking(False)
|
self._sock.setblocking(False)
|
||||||
self._server = ai[4]
|
self._server = ai[4]
|
||||||
break
|
break
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if not isinstance(e, basestring) and e[0] == EINPROGRESS:
|
if not isinstance(e, basestring) and e[0] == EINPROGRESS:
|
||||||
break
|
break
|
||||||
# for all other errors, we try other addresses
|
# for all other errors, we try other addresses
|
||||||
|
@ -481,7 +481,7 @@ class Socks5:
|
||||||
self._sock.setblocking(False)
|
self._sock.setblocking(False)
|
||||||
self._send=self._sock.send
|
self._send=self._sock.send
|
||||||
self._recv=self._sock.recv
|
self._recv=self._sock.recv
|
||||||
except Exception, ee:
|
except Exception as ee:
|
||||||
errnum = ee[0]
|
errnum = ee[0]
|
||||||
self.connect_timeout += 1
|
self.connect_timeout += 1
|
||||||
if errnum == 111 or self.connect_timeout > 1000:
|
if errnum == 111 or self.connect_timeout > 1000:
|
||||||
|
@ -533,7 +533,7 @@ class Socks5:
|
||||||
self.size = self.file_props.offset
|
self.size = self.file_props.offset
|
||||||
self.file.seek(self.size)
|
self.file.seek(self.size)
|
||||||
self.file_props.received_len = self.size
|
self.file_props.received_len = self.size
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.close_file()
|
self.close_file()
|
||||||
raise IOError, e
|
raise IOError, e
|
||||||
|
|
||||||
|
@ -583,7 +583,7 @@ class Socks5:
|
||||||
try:
|
try:
|
||||||
add = self._recv(64)
|
add = self._recv(64)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('SSL rehandshake request : ' + repr(e))
|
log.info('SSL rehandshake request : ' + repr(e))
|
||||||
raise e
|
raise e
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -600,10 +600,10 @@ class Socks5:
|
||||||
try:
|
try:
|
||||||
self._send(raw_data)
|
self._send(raw_data)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('SSL rehandshake request :' + repr(e))
|
log.info('SSL rehandshake request :' + repr(e))
|
||||||
raise e
|
raise e
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
return len(raw_data)
|
return len(raw_data)
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ class Socks5:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.open_file_for_reading()
|
self.open_file_for_reading()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.state = 8 # end connection
|
self.state = 8 # end connection
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.file_props.error = -7 # unable to read from file
|
self.file_props.error = -7 # unable to read from file
|
||||||
|
@ -625,10 +625,10 @@ class Socks5:
|
||||||
try:
|
try:
|
||||||
lenn = self._send(buff)
|
lenn = self._send(buff)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('SSL rehandshake request :' + repr(e))
|
log.info('SSL rehandshake request :' + repr(e))
|
||||||
raise e
|
raise e
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if e.args[0] not in (EINTR, ENOBUFS, EWOULDBLOCK):
|
if e.args[0] not in (EINTR, ENOBUFS, EWOULDBLOCK):
|
||||||
# peer stopped reading
|
# peer stopped reading
|
||||||
self.state = 8 # end connection
|
self.state = 8 # end connection
|
||||||
|
@ -671,7 +671,7 @@ class Socks5:
|
||||||
if self.remaining_buff != '':
|
if self.remaining_buff != '':
|
||||||
try:
|
try:
|
||||||
fd = self.get_fd()
|
fd = self.get_fd()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.disconnect(False)
|
self.disconnect(False)
|
||||||
self.file_props.error = -6 # file system error
|
self.file_props.error = -6 # file system error
|
||||||
return 0
|
return 0
|
||||||
|
@ -692,14 +692,14 @@ class Socks5:
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
fd = self.get_fd()
|
fd = self.get_fd()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.disconnect(False)
|
self.disconnect(False)
|
||||||
self.file_props.error = -6 # file system error
|
self.file_props.error = -6 # file system error
|
||||||
return 0
|
return 0
|
||||||
try:
|
try:
|
||||||
buff = self._recv(MAX_BUFF_LEN)
|
buff = self._recv(MAX_BUFF_LEN)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('SSL rehandshake request :' + repr(e))
|
log.info('SSL rehandshake request :' + repr(e))
|
||||||
raise e
|
raise e
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -718,7 +718,7 @@ class Socks5:
|
||||||
return 0
|
return 0
|
||||||
try:
|
try:
|
||||||
fd.write(buff)
|
fd.write(buff)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.rem_fd(fd)
|
self.rem_fd(fd)
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
self.file_props.error = -6 # file system error
|
self.file_props.error = -6 # file system error
|
||||||
|
@ -842,7 +842,7 @@ class Socks5:
|
||||||
try:
|
try:
|
||||||
buff = self._recv()
|
buff = self._recv()
|
||||||
except (SSL.WantReadError, SSL.WantWriteError,
|
except (SSL.WantReadError, SSL.WantWriteError,
|
||||||
SSL.WantX509LookupError), e:
|
SSL.WantX509LookupError) as e:
|
||||||
log.info("SSL rehandshake request : " + repr(e))
|
log.info("SSL rehandshake request : " + repr(e))
|
||||||
raise e
|
raise e
|
||||||
try:
|
try:
|
||||||
|
@ -1085,7 +1085,7 @@ class Socks5Server(Socks5):
|
||||||
result = self.start_transfer() # send
|
result = self.start_transfer() # send
|
||||||
self.queue.process_result(result, self)
|
self.queue.process_result(result, self)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('caught SSL exception, ignored')
|
log.info('caught SSL exception, ignored')
|
||||||
else:
|
else:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
@ -1123,7 +1123,7 @@ class Socks5Server(Socks5):
|
||||||
else:
|
else:
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('caught SSL exception, ignored')
|
log.info('caught SSL exception, ignored')
|
||||||
return
|
return
|
||||||
if self.state < 5:
|
if self.state < 5:
|
||||||
|
@ -1229,7 +1229,7 @@ class Socks5Client(Socks5):
|
||||||
result = self.start_transfer() # receive
|
result = self.start_transfer() # receive
|
||||||
self.queue.process_result(result, self)
|
self.queue.process_result(result, self)
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('caught SSL exception, ignored')
|
log.info('caught SSL exception, ignored')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
@ -1253,7 +1253,7 @@ class Socks5Client(Socks5):
|
||||||
self.queue.process_result(result, self)
|
self.queue.process_result(result, self)
|
||||||
return
|
return
|
||||||
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
except (OpenSSL.SSL.WantReadError, OpenSSL.SSL.WantWriteError,
|
||||||
OpenSSL.SSL.WantX509LookupError), e:
|
OpenSSL.SSL.WantX509LookupError) as e:
|
||||||
log.info('caught SSL exception, ignored')
|
log.info('caught SSL exception, ignored')
|
||||||
return
|
return
|
||||||
self.state += 1
|
self.state += 1
|
||||||
|
@ -1346,7 +1346,7 @@ class Socks5Listener(IdleObject):
|
||||||
if self.fingerprint is not None:
|
if self.fingerprint is not None:
|
||||||
self._serv = OpenSSL.SSL.Connection(
|
self._serv = OpenSSL.SSL.Connection(
|
||||||
jingle_xtls.get_context('server'), self._serv)
|
jingle_xtls.get_context('server'), self._serv)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e.args[0] == EAFNOSUPPORT:
|
if e.args[0] == EAFNOSUPPORT:
|
||||||
self.ai = None
|
self.ai = None
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -356,7 +356,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
try:
|
try:
|
||||||
self.ais = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
|
self.ais = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
|
||||||
socket.SOCK_STREAM)
|
socket.SOCK_STREAM)
|
||||||
except socket.gaierror, e:
|
except socket.gaierror as e:
|
||||||
log.info('Lookup failure for %s: %s[%s]', host, e[1],
|
log.info('Lookup failure for %s: %s[%s]', host, e[1],
|
||||||
repr(e[0]), exc_info=True)
|
repr(e[0]), exc_info=True)
|
||||||
else:
|
else:
|
||||||
|
@ -448,7 +448,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
try:
|
try:
|
||||||
self._sock.connect(self._server)
|
self._sock.connect(self._server)
|
||||||
self._sock.setblocking(False)
|
self._sock.setblocking(False)
|
||||||
except Exception, ee:
|
except Exception as ee:
|
||||||
(errnum, errstr) = ee
|
(errnum, errstr) = ee
|
||||||
errors = (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK)
|
errors = (errno.EINPROGRESS, errno.EALREADY, errno.EWOULDBLOCK)
|
||||||
if 'WSAEINVAL' in errno.__dict__:
|
if 'WSAEINVAL' in errno.__dict__:
|
||||||
|
@ -488,7 +488,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
try:
|
try:
|
||||||
# get as many bites, as possible, but not more than RECV_BUFSIZE
|
# get as many bites, as possible, but not more than RECV_BUFSIZE
|
||||||
received = self._sock.recv(MAX_BUFF_LEN)
|
received = self._sock.recv(MAX_BUFF_LEN)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if len(e.args) > 0 and isinstance(e.args[0], int):
|
if len(e.args) > 0 and isinstance(e.args[0], int):
|
||||||
errnum = e[0]
|
errnum = e[0]
|
||||||
# "received" will be empty anyhow
|
# "received" will be empty anyhow
|
||||||
|
@ -559,7 +559,7 @@ class P2PConnection(IdleObject, PlugIn):
|
||||||
self._plug_idle()
|
self._plug_idle()
|
||||||
self._on_send()
|
self._on_send()
|
||||||
|
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
if e[0] == socket.SSL_ERROR_WANT_WRITE:
|
if e[0] == socket.SSL_ERROR_WANT_WRITE:
|
||||||
return True
|
return True
|
||||||
if self.state < 0:
|
if self.state < 0:
|
||||||
|
|
|
@ -22,7 +22,7 @@ log = logging.getLogger('gajim.c.z.zeroconf_avahi')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dbus.exceptions
|
import dbus.exceptions
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from common.zeroconf.zeroconf import C_BARE_NAME, C_INTERFACE, C_PROTOCOL, C_DOMAIN
|
from common.zeroconf.zeroconf import C_BARE_NAME, C_INTERFACE, C_PROTOCOL, C_DOMAIN
|
||||||
|
@ -267,7 +267,7 @@ class Zeroconf:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException as e:
|
||||||
log.debug(str(e))
|
log.debug(str(e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ class Zeroconf:
|
||||||
self.bus.add_signal_receiver(self.avahi_dbus_connect_cb,
|
self.bus.add_signal_receiver(self.avahi_dbus_connect_cb,
|
||||||
'NameOwnerChanged', 'org.freedesktop.DBus',
|
'NameOwnerChanged', 'org.freedesktop.DBus',
|
||||||
arg0='org.freedesktop.Avahi')
|
arg0='org.freedesktop.Avahi')
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# System bus is not present
|
# System bus is not present
|
||||||
self.bus = None
|
self.bus = None
|
||||||
log.debug(str(e))
|
log.debug(str(e))
|
||||||
|
@ -354,7 +354,7 @@ class Zeroconf:
|
||||||
self.avahi.DBUS_PATH_SERVER), self.avahi.DBUS_INTERFACE_SERVER)
|
self.avahi.DBUS_PATH_SERVER), self.avahi.DBUS_INTERFACE_SERVER)
|
||||||
self.server.connect_to_signal('StateChanged',
|
self.server.connect_to_signal('StateChanged',
|
||||||
self.server_state_changed_callback)
|
self.server_state_changed_callback)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Avahi service is not present
|
# Avahi service is not present
|
||||||
self.server = None
|
self.server = None
|
||||||
log.debug(str(e))
|
log.debug(str(e))
|
||||||
|
@ -395,14 +395,14 @@ class Zeroconf:
|
||||||
if self.service_browser:
|
if self.service_browser:
|
||||||
try:
|
try:
|
||||||
self.service_browser.Free()
|
self.service_browser.Free()
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException as e:
|
||||||
log.debug(str(e))
|
log.debug(str(e))
|
||||||
self.service_browser._obj._bus = None
|
self.service_browser._obj._bus = None
|
||||||
self.service_browser._obj = None
|
self.service_browser._obj = None
|
||||||
if self.domain_browser:
|
if self.domain_browser:
|
||||||
try:
|
try:
|
||||||
self.domain_browser.Free()
|
self.domain_browser.Free()
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException as e:
|
||||||
log.debug(str(e))
|
log.debug(str(e))
|
||||||
self.domain_browser._obj._bus = None
|
self.domain_browser._obj._bus = None
|
||||||
self.domain_browser._obj = None
|
self.domain_browser._obj = None
|
||||||
|
|
|
@ -24,7 +24,7 @@ from common.zeroconf.zeroconf import C_BARE_NAME, C_DOMAIN
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pybonjour
|
import pybonjour
|
||||||
except ImportError, e:
|
except ImportError as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class Zeroconf:
|
||||||
regtype = self.stype, port = self.port, txtRecord = self.txt,
|
regtype = self.stype, port = self.port, txtRecord = self.txt,
|
||||||
callBack = self.service_added_callback)
|
callBack = self.service_added_callback)
|
||||||
self.service_sdRef = sdRef
|
self.service_sdRef = sdRef
|
||||||
except pybonjour.BonjourError, e:
|
except pybonjour.BonjourError as e:
|
||||||
self.service_add_fail_callback(e)
|
self.service_add_fail_callback(e)
|
||||||
else:
|
else:
|
||||||
gajim.log.debug('Publishing service %s of type %s' % (self.name, self.stype))
|
gajim.log.debug('Publishing service %s of type %s' % (self.name, self.stype))
|
||||||
|
@ -248,7 +248,7 @@ class Zeroconf:
|
||||||
self.service_sdRef.close()
|
self.service_sdRef.close()
|
||||||
self.announced = False
|
self.announced = False
|
||||||
return True
|
return True
|
||||||
except pybonjour.BonjourError, e:
|
except pybonjour.BonjourError as e:
|
||||||
gajim.log.debug(e)
|
gajim.log.debug(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ class Zeroconf:
|
||||||
gajim.log.debug('starting to browse')
|
gajim.log.debug('starting to browse')
|
||||||
try:
|
try:
|
||||||
self.browse_sdRef = pybonjour.DNSServiceBrowse(regtype=self.stype, domain=domain, callBack=self.browse_callback)
|
self.browse_sdRef = pybonjour.DNSServiceBrowse(regtype=self.stype, domain=domain, callBack=self.browse_callback)
|
||||||
except pybonjour.BonjourError, e:
|
except pybonjour.BonjourError as e:
|
||||||
self.error_CB("Error while browsing: %s" % e)
|
self.error_CB("Error while browsing: %s" % e)
|
||||||
|
|
||||||
def browse_loop(self):
|
def browse_loop(self):
|
||||||
|
|
|
@ -2161,7 +2161,7 @@ class AccountsWindow:
|
||||||
# check if jid is conform to RFC and stringprep it
|
# check if jid is conform to RFC and stringprep it
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
if not widget.is_focus():
|
if not widget.is_focus():
|
||||||
pritext = _('Invalid Jabber ID')
|
pritext = _('Invalid Jabber ID')
|
||||||
dialogs.ErrorDialog(pritext, str(s))
|
dialogs.ErrorDialog(pritext, str(s))
|
||||||
|
@ -2238,7 +2238,7 @@ class AccountsWindow:
|
||||||
'utf-8')
|
'utf-8')
|
||||||
try:
|
try:
|
||||||
resource = helpers.parse_resource(resource)
|
resource = helpers.parse_resource(resource)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
if not widget.is_focus():
|
if not widget.is_focus():
|
||||||
pritext = _('Invalid Jabber ID')
|
pritext = _('Invalid Jabber ID')
|
||||||
dialogs.ErrorDialog(pritext, str(s))
|
dialogs.ErrorDialog(pritext, str(s))
|
||||||
|
@ -3385,7 +3385,7 @@ class ManageBookmarksWindow:
|
||||||
nick = self.nick_entry.get_text()
|
nick = self.nick_entry.get_text()
|
||||||
try:
|
try:
|
||||||
nick = helpers.parse_resource(nick)
|
nick = helpers.parse_resource(nick)
|
||||||
except helpers.InvalidFormat, e:
|
except helpers.InvalidFormat as e:
|
||||||
dialogs.ErrorDialog(_('Invalid nickname'),
|
dialogs.ErrorDialog(_('Invalid nickname'),
|
||||||
_('Character not allowed'))
|
_('Character not allowed'))
|
||||||
self.nick_entry.set_text(model[iter_][6])
|
self.nick_entry.set_text(model[iter_][6])
|
||||||
|
@ -3405,7 +3405,7 @@ class ManageBookmarksWindow:
|
||||||
server.strip()
|
server.strip()
|
||||||
try:
|
try:
|
||||||
room_jid = helpers.parse_resource(room_jid)
|
room_jid = helpers.parse_resource(room_jid)
|
||||||
except helpers.InvalidFormat, e:
|
except helpers.InvalidFormat as e:
|
||||||
dialogs.ErrorDialog(_('Invalid server'),
|
dialogs.ErrorDialog(_('Invalid server'),
|
||||||
_('Character not allowed'))
|
_('Character not allowed'))
|
||||||
self.server_entry.set_text(model[iter_][2].split('@')[1])
|
self.server_entry.set_text(model[iter_][2].split('@')[1])
|
||||||
|
@ -3424,7 +3424,7 @@ class ManageBookmarksWindow:
|
||||||
self.server_entry.get_text().strip()
|
self.server_entry.get_text().strip()
|
||||||
try:
|
try:
|
||||||
room_jid = helpers.parse_resource(room_jid)
|
room_jid = helpers.parse_resource(room_jid)
|
||||||
except helpers.InvalidFormat, e:
|
except helpers.InvalidFormat as e:
|
||||||
dialogs.ErrorDialog(_('Invalid room'),
|
dialogs.ErrorDialog(_('Invalid room'),
|
||||||
_('Character not allowed'))
|
_('Character not allowed'))
|
||||||
self.room_entry.set_text(model[iter_][2].split('@')[0])
|
self.room_entry.set_text(model[iter_][2].split('@')[0])
|
||||||
|
@ -3644,7 +3644,7 @@ class AccountCreationWizardWindow:
|
||||||
# check if jid is conform to RFC and stringprep it
|
# check if jid is conform to RFC and stringprep it
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
pritext = _('Invalid Jabber ID')
|
pritext = _('Invalid Jabber ID')
|
||||||
dialogs.ErrorDialog(pritext, str(s))
|
dialogs.ErrorDialog(pritext, str(s))
|
||||||
return
|
return
|
||||||
|
|
|
@ -1366,7 +1366,7 @@ class ConversationTextview(GObject.GObject):
|
||||||
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
|
xhtml = xhtml.replace('/me', '<i>* %s</i>' % (name,), 1)
|
||||||
self.tv.display_html(xhtml.encode('utf-8'), self)
|
self.tv.display_html(xhtml.encode('utf-8'), self)
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
gajim.log.debug('Error processing xhtml' + str(e))
|
gajim.log.debug('Error processing xhtml' + str(e))
|
||||||
gajim.log.debug('with |' + xhtml + '|')
|
gajim.log.debug('with |' + xhtml + '|')
|
||||||
|
|
||||||
|
|
|
@ -629,7 +629,7 @@ class SingleForm(Gtk.Table, object):
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
newtext = helpers.parse_jid(newtext)
|
newtext = helpers.parse_jid(newtext)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s))
|
dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s))
|
||||||
return
|
return
|
||||||
if newtext in field.values:
|
if newtext in field.values:
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ class AddNewContactWindow:
|
||||||
# check if jid is conform to RFC and stringprep it
|
# check if jid is conform to RFC and stringprep it
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
pritext = _('Invalid User ID')
|
pritext = _('Invalid User ID')
|
||||||
ErrorDialog(pritext, str(s))
|
ErrorDialog(pritext, str(s))
|
||||||
return
|
return
|
||||||
|
@ -2740,7 +2740,7 @@ class NewChatDialog(InputDialog):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, e:
|
except helpers.InvalidFormat as e:
|
||||||
ErrorDialog(_('Invalid JID'), e[0])
|
ErrorDialog(_('Invalid JID'), e[0])
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
|
@ -3672,7 +3672,7 @@ class ItemArchivingPreferencesWindow:
|
||||||
if self.item != 'Default':
|
if self.item != 'Default':
|
||||||
try:
|
try:
|
||||||
item = helpers.parse_jid(item)
|
item = helpers.parse_jid(item)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
pritext = _('Invalid User ID')
|
pritext = _('Invalid User ID')
|
||||||
ErrorDialog(pritext, str(s))
|
ErrorDialog(pritext, str(s))
|
||||||
return
|
return
|
||||||
|
|
|
@ -803,7 +803,7 @@ _('This type of service does not contain any items to browse.'))
|
||||||
jid = self.address_comboboxentry.get_child().get_text()
|
jid = self.address_comboboxentry.get_child().get_text()
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
pritext = _('Invalid Server Name')
|
pritext = _('Invalid Server Name')
|
||||||
dialogs.ErrorDialog(pritext, str(s))
|
dialogs.ErrorDialog(pritext, str(s))
|
||||||
return
|
return
|
||||||
|
@ -813,7 +813,7 @@ _('This type of service does not contain any items to browse.'))
|
||||||
jid = self.address_comboboxentry.get_child().get_text()
|
jid = self.address_comboboxentry.get_child().get_text()
|
||||||
try:
|
try:
|
||||||
jid = helpers.parse_jid(jid)
|
jid = helpers.parse_jid(jid)
|
||||||
except helpers.InvalidFormat, s:
|
except helpers.InvalidFormat as s:
|
||||||
pritext = _('Invalid Server Name')
|
pritext = _('Invalid Server Name')
|
||||||
dialogs.ErrorDialog(pritext, str(s))
|
dialogs.ErrorDialog(pritext, str(s))
|
||||||
return
|
return
|
||||||
|
|
|
@ -48,7 +48,7 @@ gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
|
||||||
def get_icon_pixmap(icon_name, size=16):
|
def get_icon_pixmap(icon_name, size=16):
|
||||||
try:
|
try:
|
||||||
return gtk_icon_theme.load_icon(icon_name, size, 0)
|
return gtk_icon_theme.load_icon(icon_name, size, 0)
|
||||||
except GObject.GError, e:
|
except GObject.GError as e:
|
||||||
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
|
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
|
||||||
|
|
||||||
def get_icon_path(icon_name, size=16):
|
def get_icon_path(icon_name, size=16):
|
||||||
|
@ -59,7 +59,7 @@ def get_icon_path(icon_name, size=16):
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
return icon_info.get_filename()
|
return icon_info.get_filename()
|
||||||
except GObject.GError, e:
|
except GObject.GError as e:
|
||||||
log.error("Unable to find icon %s: %s" % (icon_name, str(e)))
|
log.error("Unable to find icon %s: %s" % (icon_name, str(e)))
|
||||||
|
|
||||||
import vcard
|
import vcard
|
||||||
|
@ -342,10 +342,10 @@ def parse_server_xml(path_to_file):
|
||||||
xml.sax.parse(path_to_file, handler)
|
xml.sax.parse(path_to_file, handler)
|
||||||
return handler.servers
|
return handler.servers
|
||||||
# handle exception if unable to open file
|
# handle exception if unable to open file
|
||||||
except IOError, message:
|
except IOError as message:
|
||||||
print(_('Error reading file:') + message, file=sys.stderr)
|
print(_('Error reading file:') + message, file=sys.stderr)
|
||||||
# handle exception parsing file
|
# handle exception parsing file
|
||||||
except xml.sax.SAXParseException, message:
|
except xml.sax.SAXParseException as message:
|
||||||
print(_('Error parsing file:') + message, file=sys.stderr)
|
print(_('Error parsing file:') + message, file=sys.stderr)
|
||||||
|
|
||||||
def set_unset_urgency_hint(window, unread_messages_no):
|
def set_unset_urgency_hint(window, unread_messages_no):
|
||||||
|
@ -829,7 +829,7 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''):
|
||||||
# Save image
|
# Save image
|
||||||
try:
|
try:
|
||||||
pixbuf.savev(file_path, image_format, [], [])
|
pixbuf.savev(file_path, image_format, [], [])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.debug('Error saving avatar: %s' % str(e))
|
log.debug('Error saving avatar: %s' % str(e))
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
|
@ -2490,7 +2490,7 @@ class Interface:
|
||||||
path_to_original_file = path_to_file + extension
|
path_to_original_file = path_to_file + extension
|
||||||
try:
|
try:
|
||||||
pixbuf.savev(path_to_original_file, typ, [], [])
|
pixbuf.savev(path_to_original_file, typ, [], [])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Error writing avatar file %s: %s' % (
|
log.error('Error writing avatar file %s: %s' % (
|
||||||
path_to_original_file, str(e)))
|
path_to_original_file, str(e)))
|
||||||
# Generate and save the resized, color avatar
|
# Generate and save the resized, color avatar
|
||||||
|
@ -2500,7 +2500,7 @@ class Interface:
|
||||||
extension
|
extension
|
||||||
try:
|
try:
|
||||||
pixbuf.savev(path_to_normal_file, 'png', [], [])
|
pixbuf.savev(path_to_normal_file, 'png', [], [])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Error writing avatar file %s: %s' % \
|
log.error('Error writing avatar file %s: %s' % \
|
||||||
(path_to_original_file, str(e)))
|
(path_to_original_file, str(e)))
|
||||||
# Generate and save the resized, black and white avatar
|
# Generate and save the resized, black and white avatar
|
||||||
|
@ -2510,7 +2510,7 @@ class Interface:
|
||||||
path_to_bw_file = path_to_file + '_notif_size_bw' + extension
|
path_to_bw_file = path_to_file + '_notif_size_bw' + extension
|
||||||
try:
|
try:
|
||||||
bwbuf.savev(path_to_bw_file, 'png', [], [])
|
bwbuf.savev(path_to_bw_file, 'png', [], [])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.error('Error writing avatar file %s: %s' % \
|
log.error('Error writing avatar file %s: %s' % \
|
||||||
(path_to_original_file, str(e)))
|
(path_to_original_file, str(e)))
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ def parseOpts():
|
||||||
shortargs = 'hc:'
|
shortargs = 'hc:'
|
||||||
longargs = 'help config_path='
|
longargs = 'help config_path='
|
||||||
opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
|
opts = getopt.getopt(sys.argv[1:], shortargs, longargs.split())[0]
|
||||||
except getopt.error, msg:
|
except getopt.error as msg:
|
||||||
print(str(msg))
|
print(str(msg))
|
||||||
print('for help use --help')
|
print('for help use --help')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
|
@ -352,7 +352,7 @@ class HistoryWindow:
|
||||||
try:
|
try:
|
||||||
log_days = gajim.logger.get_days_with_logs(self.jid, year, month,
|
log_days = gajim.logger.get_days_with_logs(self.jid, year, month,
|
||||||
days_in_this_month, self.account)
|
days_in_this_month, self.account)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
dialogs.ErrorDialog(_('Disk Error'), str(e))
|
dialogs.ErrorDialog(_('Disk Error'), str(e))
|
||||||
return
|
return
|
||||||
for day in log_days:
|
for day in log_days:
|
||||||
|
|
|
@ -587,7 +587,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
self.textbuf.delete_mark(tmpmark)
|
self.textbuf.delete_mark(tmpmark)
|
||||||
else:
|
else:
|
||||||
self._insert_text('[IMG: %s]' % alt, working_iter)
|
self._insert_text('[IMG: %s]' % alt, working_iter)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
log.error('Error loading image ' + str(ex))
|
log.error('Error loading image ' + str(ex))
|
||||||
pixbuf = None
|
pixbuf = None
|
||||||
alt = attrs.get('alt', 'Broken image')
|
alt = attrs.get('alt', 'Broken image')
|
||||||
|
@ -764,7 +764,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
||||||
self.textview.focus_out_line_pixbuf)
|
self.textview.focus_out_line_pixbuf)
|
||||||
#self._insert_text('\u2550'*40)
|
#self._insert_text('\u2550'*40)
|
||||||
self._jump_line()
|
self._jump_line()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
log.debug(str('Error in hr'+e))
|
log.debug(str('Error in hr'+e))
|
||||||
elif name in LIST_ELEMS:
|
elif name in LIST_ELEMS:
|
||||||
self.list_counters.pop()
|
self.list_counters.pop()
|
||||||
|
|
|
@ -91,10 +91,10 @@ text=None, timeout=-1):
|
||||||
DesktopNotification(event_type, jid, account, msg_type,
|
DesktopNotification(event_type, jid, account, msg_type,
|
||||||
path_to_image, title, GObject.markup_escape_text(text), timeout)
|
path_to_image, title, GObject.markup_escape_text(text), timeout)
|
||||||
return # sucessfully did D-Bus Notification procedure!
|
return # sucessfully did D-Bus Notification procedure!
|
||||||
except dbus.DBusException, e:
|
except dbus.DBusException as e:
|
||||||
# Connection to D-Bus failed
|
# Connection to D-Bus failed
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
except TypeError, e:
|
except TypeError as e:
|
||||||
# This means that we sent the message incorrectly
|
# This means that we sent the message incorrectly
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ text=None, timeout=-1):
|
||||||
try:
|
try:
|
||||||
notification.show()
|
notification.show()
|
||||||
return
|
return
|
||||||
except GObject.GError, e:
|
except GObject.GError as e:
|
||||||
# Connection to notification-daemon failed, see #2893
|
# Connection to notification-daemon failed, see #2893
|
||||||
gajim.log.debug(str(e))
|
gajim.log.debug(str(e))
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ class DesktopNotification:
|
||||||
dbus.UInt32(self.timeout*1000),
|
dbus.UInt32(self.timeout*1000),
|
||||||
reply_handler=self.attach_by_id,
|
reply_handler=self.attach_by_id,
|
||||||
error_handler=self.notify_another_way)
|
error_handler=self.notify_another_way)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.notify_another_way(e)
|
self.notify_another_way(e)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -412,7 +412,7 @@ class DesktopNotification:
|
||||||
dbus.UInt32(self.timeout*1000),
|
dbus.UInt32(self.timeout*1000),
|
||||||
reply_handler=self.attach_by_id,
|
reply_handler=self.attach_by_id,
|
||||||
error_handler=self.notify_another_way)
|
error_handler=self.notify_another_way)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.notify_another_way(e)
|
self.notify_another_way(e)
|
||||||
|
|
||||||
def attach_by_id(self, id_):
|
def attach_by_id(self, id_):
|
||||||
|
|
|
@ -196,7 +196,7 @@ class PluginsWindow(object):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
gajim.plugin_manager.activate_plugin(plugin)
|
gajim.plugin_manager.activate_plugin(plugin)
|
||||||
except GajimPluginActivateException, e:
|
except GajimPluginActivateException as e:
|
||||||
WarningDialog(_('Plugin failed'), str(e),
|
WarningDialog(_('Plugin failed'), str(e),
|
||||||
transient_for=self.window)
|
transient_for=self.window)
|
||||||
return
|
return
|
||||||
|
@ -241,7 +241,7 @@ class PluginsWindow(object):
|
||||||
is_active = model.get_value(iter, ACTIVE)
|
is_active = model.get_value(iter, ACTIVE)
|
||||||
try:
|
try:
|
||||||
gajim.plugin_manager.remove_plugin(plugin)
|
gajim.plugin_manager.remove_plugin(plugin)
|
||||||
except PluginsystemError, e:
|
except PluginsystemError as e:
|
||||||
WarningDialog(_('Unable to properly remove the plugin'),
|
WarningDialog(_('Unable to properly remove the plugin'),
|
||||||
str(e), self.window)
|
str(e), self.window)
|
||||||
return
|
return
|
||||||
|
@ -280,7 +280,7 @@ class PluginsWindow(object):
|
||||||
def _try_install(zip_filename):
|
def _try_install(zip_filename):
|
||||||
try:
|
try:
|
||||||
plugin = gajim.plugin_manager.install_from_zip(zip_filename)
|
plugin = gajim.plugin_manager.install_from_zip(zip_filename)
|
||||||
except PluginsystemError, er_type:
|
except PluginsystemError as er_type:
|
||||||
error_text = str(er_type)
|
error_text = str(er_type)
|
||||||
if error_text == _('Plugin already exists'):
|
if error_text == _('Plugin already exists'):
|
||||||
_on_plugin_exists(zip_filename)
|
_on_plugin_exists(zip_filename)
|
||||||
|
|
|
@ -302,7 +302,7 @@ class PluginManager(object):
|
||||||
self.active_plugins.append(plugin)
|
self.active_plugins.append(plugin)
|
||||||
try:
|
try:
|
||||||
plugin.activate()
|
plugin.activate()
|
||||||
except GajimPluginException, e:
|
except GajimPluginException as e:
|
||||||
self.deactivate_plugin(plugin)
|
self.deactivate_plugin(plugin)
|
||||||
raise GajimPluginActivateException(str(e))
|
raise GajimPluginActivateException(str(e))
|
||||||
self._set_plugin_active_in_global_config(plugin)
|
self._set_plugin_active_in_global_config(plugin)
|
||||||
|
@ -426,9 +426,9 @@ class PluginManager(object):
|
||||||
module_name = os.path.splitext(elem_name)[0]
|
module_name = os.path.splitext(elem_name)[0]
|
||||||
try:
|
try:
|
||||||
module = __import__(module_name)
|
module = __import__(module_name)
|
||||||
except ValueError, value_error:
|
except ValueError as value_error:
|
||||||
log.debug(value_error)
|
log.debug(value_error)
|
||||||
except ImportError, import_error:
|
except ImportError as import_error:
|
||||||
log.debug(import_error)
|
log.debug(import_error)
|
||||||
|
|
||||||
elif os.path.isdir(file_path) and scan_dirs:
|
elif os.path.isdir(file_path) and scan_dirs:
|
||||||
|
@ -439,9 +439,9 @@ class PluginManager(object):
|
||||||
file_path += os.path.sep
|
file_path += os.path.sep
|
||||||
try:
|
try:
|
||||||
module = __import__(module_name)
|
module = __import__(module_name)
|
||||||
except ValueError, value_error:
|
except ValueError as value_error:
|
||||||
log.debug(value_error)
|
log.debug(value_error)
|
||||||
except ImportError, import_error:
|
except ImportError as import_error:
|
||||||
log.debug(import_error)
|
log.debug(import_error)
|
||||||
|
|
||||||
|
|
||||||
|
@ -477,21 +477,21 @@ class PluginManager(object):
|
||||||
|
|
||||||
plugins_found.append(module_attr)
|
plugins_found.append(module_attr)
|
||||||
|
|
||||||
except TypeError, type_error:
|
except TypeError as type_error:
|
||||||
# set plugin localization
|
# set plugin localization
|
||||||
try:
|
try:
|
||||||
module_attr._ = _
|
module_attr._ = _
|
||||||
except AttributeError, type_error:
|
except AttributeError as type_error:
|
||||||
pass
|
pass
|
||||||
except ConfigParser.NoOptionError, type_error:
|
except ConfigParser.NoOptionError as type_error:
|
||||||
# all fields are required
|
# all fields are required
|
||||||
log.debug('%s : %s' % (module_attr_name,
|
log.debug('%s : %s' % (module_attr_name,
|
||||||
'wrong manifest file. all fields are required!'))
|
'wrong manifest file. all fields are required!'))
|
||||||
except ConfigParser.NoSectionError, type_error:
|
except ConfigParser.NoSectionError as type_error:
|
||||||
# info section are required
|
# info section are required
|
||||||
log.debug('%s : %s' % (module_attr_name,
|
log.debug('%s : %s' % (module_attr_name,
|
||||||
'wrong manifest file. info section are required!'))
|
'wrong manifest file. info section are required!'))
|
||||||
except ConfigParser.MissingSectionHeaderError, type_error:
|
except ConfigParser.MissingSectionHeaderError as type_error:
|
||||||
# info section are required
|
# info section are required
|
||||||
log.debug('%s : %s' % (module_attr_name,
|
log.debug('%s : %s' % (module_attr_name,
|
||||||
'wrong manifest file. section are required!'))
|
'wrong manifest file. section are required!'))
|
||||||
|
@ -504,10 +504,10 @@ class PluginManager(object):
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
zip_file = zipfile.ZipFile(zip_filename)
|
zip_file = zipfile.ZipFile(zip_filename)
|
||||||
except zipfile.BadZipfile, e:
|
except zipfile.BadZipfile as e:
|
||||||
# it is not zip file
|
# it is not zip file
|
||||||
raise PluginsystemError(_('Archive corrupted'))
|
raise PluginsystemError(_('Archive corrupted'))
|
||||||
except IOError,e:
|
except IOError as e:
|
||||||
raise PluginsystemError(_('Archive empty'))
|
raise PluginsystemError(_('Archive empty'))
|
||||||
|
|
||||||
if zip_file.testzip():
|
if zip_file.testzip():
|
||||||
|
|
|
@ -36,6 +36,6 @@ if os.name != 'nt':
|
||||||
try:
|
try:
|
||||||
t = gettext.translation(APP, plugins_locale_dir)
|
t = gettext.translation(APP, plugins_locale_dir)
|
||||||
_ = t.gettext
|
_ = t.gettext
|
||||||
except IOError, msg:
|
except IOError as msg:
|
||||||
from common import i18n
|
from common import i18n
|
||||||
_ = gettext.gettext
|
_ = gettext.gettext
|
||||||
|
|
|
@ -139,7 +139,7 @@ class ProfileWindow:
|
||||||
# and hope that user did not specify in ACE crazy size
|
# and hope that user did not specify in ACE crazy size
|
||||||
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
|
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf,
|
||||||
'tooltip')
|
'tooltip')
|
||||||
except GObject.GError, msg: # unknown format
|
except GObject.GError as msg: # unknown format
|
||||||
# msg should be string, not object instance
|
# msg should be string, not object instance
|
||||||
msg = str(msg)
|
msg = str(msg)
|
||||||
invalid_file = True
|
invalid_file = True
|
||||||
|
|
|
@ -743,7 +743,7 @@ class SignalObject(dbus.service.Object):
|
||||||
def prefs_store(self):
|
def prefs_store(self):
|
||||||
try:
|
try:
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return DBUS_BOOLEAN(False)
|
return DBUS_BOOLEAN(False)
|
||||||
return DBUS_BOOLEAN(True)
|
return DBUS_BOOLEAN(True)
|
||||||
|
|
||||||
|
|
|
@ -3282,7 +3282,7 @@ class RosterWindow:
|
||||||
# get the image at 'tooltip size'
|
# get the image at 'tooltip size'
|
||||||
# and hope that user did not specify in ACE crazy size
|
# and hope that user did not specify in ACE crazy size
|
||||||
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip')
|
pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'tooltip')
|
||||||
except GObject.GError, msg: # unknown format
|
except GObject.GError as msg: # unknown format
|
||||||
# msg should be string, not object instance
|
# msg should be string, not object instance
|
||||||
msg = str(msg)
|
msg = str(msg)
|
||||||
dialogs.ErrorDialog(_('Could not load image'), msg)
|
dialogs.ErrorDialog(_('Could not load image'), msg)
|
||||||
|
|
|
@ -90,7 +90,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
msg_to_log = obj.msgtxt
|
msg_to_log = obj.msgtxt
|
||||||
obj.msg_id = gajim.logger.write(log_type, obj.fjid,
|
obj.msg_id = gajim.logger.write(log_type, obj.fjid,
|
||||||
msg_to_log, tim=obj.timestamp, subject=obj.subject)
|
msg_to_log, tim=obj.timestamp, subject=obj.subject)
|
||||||
except exceptions.PysqliteOperationalError, e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
gajim.nec.push_incoming_event(InformationEvent(None,
|
gajim.nec.push_incoming_event(InformationEvent(None,
|
||||||
conn=self.conn, level='error', pri_txt=_('Disk Write Error'),
|
conn=self.conn, level='error', pri_txt=_('Disk Write Error'),
|
||||||
sec_txt=str(e)))
|
sec_txt=str(e)))
|
||||||
|
@ -423,7 +423,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
'submit':
|
'submit':
|
||||||
try:
|
try:
|
||||||
self.archiving_accepted(form)
|
self.archiving_accepted(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -452,7 +452,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.accept_e2e_alice(form, negotiated)
|
self.accept_e2e_alice(form, negotiated)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
def reject_nondefault_options():
|
def reject_nondefault_options():
|
||||||
|
@ -476,7 +476,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.accept_e2e_alice(form, negotiated)
|
self.accept_e2e_alice(form, negotiated)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -484,21 +484,21 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
||||||
'result':
|
'result':
|
||||||
try:
|
try:
|
||||||
self.we_accept_archiving(form)
|
self.we_accept_archiving(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
elif self.status == 'responded-e2e' and form.getType() == 'result':
|
elif self.status == 'responded-e2e' and form.getType() == 'result':
|
||||||
try:
|
try:
|
||||||
self.accept_e2e_bob(form)
|
self.accept_e2e_bob(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
elif self.status == 'identified-alice' and form.getType() == 'result':
|
elif self.status == 'identified-alice' and form.getType() == 'result':
|
||||||
try:
|
try:
|
||||||
self.final_steps_alice(form)
|
self.final_steps_alice(form)
|
||||||
except exceptions.NegotiationError, details:
|
except exceptions.NegotiationError as details:
|
||||||
self.fail_bad_negotiation(details)
|
self.fail_bad_negotiation(details)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
|
@ -72,7 +72,7 @@ class TestNonBlockingTCP(AbstractTransportTest):
|
||||||
ips = socket.getaddrinfo('gajim.org', 5222,
|
ips = socket.getaddrinfo('gajim.org', 5222,
|
||||||
socket.AF_UNSPEC, socket.SOCK_STREAM)
|
socket.AF_UNSPEC, socket.SOCK_STREAM)
|
||||||
ip = ips[0]
|
ip = ips[0]
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
self.testcase.fail(msg=str(e))
|
self.testcase.fail(msg=str(e))
|
||||||
|
|
||||||
self.socket = transports_nb.NonBlockingTCP(
|
self.socket = transports_nb.NonBlockingTCP(
|
||||||
|
|
|
@ -17,7 +17,7 @@ try:
|
||||||
shortargs = 'hnv:'
|
shortargs = 'hnv:'
|
||||||
longargs = 'help no-x verbose='
|
longargs = 'help no-x verbose='
|
||||||
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
|
opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs.split())
|
||||||
except getopt.error, msg:
|
except getopt.error as msg:
|
||||||
print(msg)
|
print(msg)
|
||||||
print('for help use --help')
|
print('for help use --help')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
Loading…
Reference in New Issue