diff --git a/setup_osx.py b/setup_osx.py index cb0df022126a8180e697492935c06a25c567c9ba..aa2bf30f1981d4d0154d55ac631c904e8ef13829 100644 --- a/setup_osx.py +++ b/setup_osx.py @@ -82,7 +82,7 @@ def check(ret): def force(func): try: func() - except: + except Exception: pass return diff --git a/src/chat_control.py b/src/chat_control.py index 86a3c1e1265c084342ef999c67b39d95e1e9c24b..323dd6ea1daf0e47bcbedb13da2f1543cc770629 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -56,7 +56,7 @@ from common.xmpp.protocol import NS_ESESSION try: import gtkspell HAS_GTK_SPELL = True -except: +except Exception: HAS_GTK_SPELL = False HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0) @@ -281,7 +281,7 @@ class ChatControlBase(MessageControl): for lang in dict(langs): try: spell.set_language(langs[lang]) - except: + except Exception: del langs[lang] # now set the one the user selected per_type = 'contacts' diff --git a/src/common/atom.py b/src/common/atom.py index d8a5847cf600e9880cc1f59653d8b52dfd20bdf7..ff0f04793eae70ef4bc4ab96e4f31d8271851ba0 100644 --- a/src/common/atom.py +++ b/src/common/atom.py @@ -107,7 +107,7 @@ class OldEntry(xmpp.Node, object): ''' Get source link ''' try: return self.getTag('feed').getTags('link',{'rel':'alternate'})[1].getData() - except: + except Exception: return None feed_link = property(get_feed_link, None, None, diff --git a/src/common/commands.py b/src/common/commands.py index c40431dfa8923238515dfa8a0ea04f0af49dcce1..1d238aa0ca704cdb700890ca075c507dbcbf8e7e 100644 --- a/src/common/commands.py +++ b/src/common/commands.py @@ -121,7 +121,7 @@ class ChangeStatusCommand(AdHocCommand): try: form = dataforms.SimpleDataForm(extend = request.getTag('command').\ getTag('x')) - except: + except Exception: self.badRequest(request) return False @@ -131,14 +131,14 @@ class ChangeStatusCommand(AdHocCommand): ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'): self.badRequest(request) return False - except: # KeyError if there's no presence-type field in form or + except Exception: # KeyError if there's no presence-type field in form or # AttributeError if that field is of wrong type self.badRequest(request) return False try: presencedesc = form['presence-desc'].value - except: # same exceptions as in last comment + except Exception: # same exceptions as in last comment presencedesc = u'' response, cmd = self.buildResponse(request, status = 'completed') @@ -219,13 +219,13 @@ class LeaveGroupchatsCommand(AdHocCommand): try: form = dataforms.SimpleDataForm(extend = request.getTag('command').\ getTag('x')) - except: + except Exception: self.badRequest(request) return False try: gc = form['groupchats'].values - except: # KeyError if there's no groupchats in form + except Exception: # KeyError if there's no groupchats in form self.badRequest(request) return False account = self.connection.name @@ -240,7 +240,7 @@ class LeaveGroupchatsCommand(AdHocCommand): gajim.interface.roster.remove_groupchat(room_jid, account) continue gc_control.parent_win.remove_tab(gc_control, None, force = True) - except: # KeyError if there's no such room opened + except Exception: # KeyError if there's no such room opened self.badRequest(request) return False response, cmd = self.buildResponse(request, status = 'completed') diff --git a/src/common/config.py b/src/common/config.py index 0001090d919c7e1738e01df5a1cfcf511f676bd7..82816805949c82889f47a4f2c08cc978e98c329c 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -481,7 +481,7 @@ class Config: def is_valid_int(self, val): try: ival = int(val) - except: + except Exception: return None return ival diff --git a/src/common/connection.py b/src/common/connection.py index c3d2d0e61ff92bbc4a769dc4d3a16a7c4b22992a..40c1d013d01eecda9c379aa34d1e92a6ca832765 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -41,7 +41,7 @@ import locale try: randomsource = random.SystemRandom() -except: +except Exception: randomsource = random.Random() randomsource.seed() @@ -447,7 +447,7 @@ class Connection(ConnectionHandlers): try: try: env_http_proxy = os.environ['HTTP_PROXY'] - except: + except Exception: env_http_proxy = os.environ['http_proxy'] env_http_proxy = env_http_proxy.strip('"') # Dispose of the http:// prefix @@ -474,7 +474,7 @@ class Connection(ConnectionHandlers): else: proxy['password'] = u'' - except: + except Exception: proxy = None else: proxy = None diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 044e42cc3c0d52931e8898a7b13ae4c46693a2e3..a837a9efb6d0a44b987229596f4a9c34cfc9c9d7 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -67,7 +67,7 @@ PEP_CONFIG = 'pep_config' HAS_IDLE = True try: import idle -except: +except Exception: gajim.log.debug(_('Unable to load idle module')) HAS_IDLE = False @@ -461,7 +461,7 @@ class ConnectionBytestream: try: streamhost = query.getTag('streamhost-used') - except: # this bytestream result is not what we need + except Exception: # this bytestream result is not what we need pass id = real_id[3:] if id in self.files_props: @@ -944,7 +944,7 @@ class ConnectionVcard: f.close() try: card = common.xmpp.Node(node = c) - except: + except Exception: # We are unable to parse it. Remove it os.remove(path_to_file) return None @@ -1107,7 +1107,7 @@ class ConnectionVcard: order = meta.getAttr('order') try: order = int(order) - except: + except Exception: order = 0 if order is not None: data['order'] = order @@ -1174,7 +1174,7 @@ class ConnectionVcard: try: photo_decoded = base64.decodestring(photo) avatar_sha = sha.sha(photo_decoded).hexdigest() - except: + except Exception: avatar_sha = '' else: avatar_sha = '' @@ -1388,7 +1388,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, try: idle.init() - except: + except Exception: HAS_IDLE = False self.gmail_last_tid = None @@ -1532,7 +1532,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, status = qp.getData() try: seconds = int(seconds) - except: + except Exception: return id = iq_obj.getID() if id in self.groupchat_jids: @@ -1771,7 +1771,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, try: msg = session.decrypt_stanza(msg) msgtxt = msg.getBody() - except: + except Exception: self.dispatch('FAILED_DECRYPT', (frm, tim, session)) # Receipt requested @@ -1938,7 +1938,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, gajim.log.debug('PresenceCB: %s' % ptype) try: who = helpers.get_full_jid_from_iq(prs) - except: + except Exception: if prs.getTag('error').getTag('jid-malformed'): # wrong jid, we probably tried to change our nick in a room to a non # valid one @@ -2000,7 +2000,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco, prio = prs.getPriority() try: prio = int(prio) - except: + except Exception: prio = 0 keyID = '' if sigTag and self.USE_GPG and ptype != 'error': diff --git a/src/common/helpers.py b/src/common/helpers.py index d9648281e40ad1a2dc2b3c2178268090fcfc9191..d5605c18a5de25a0ea24fad740821cf58602509e 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -69,7 +69,7 @@ try: import winsound # windows-only built-in module for playing wav import win32api import win32con -except: +except Exception: pass special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats')) @@ -447,7 +447,7 @@ def launch_browser_mailer(kind, uri): if os.name == 'nt': try: os.startfile(uri) # if pywin32 is installed we open - except: + except Exception: pass else: @@ -474,14 +474,14 @@ def launch_browser_mailer(kind, uri): command = build_command(command, uri) try: exec_command(command) - except: + except Exception: pass def launch_file_manager(path_to_open): if os.name == 'nt': try: os.startfile(path_to_open) # if pywin32 is installed we open - except: + except Exception: pass else: if gajim.config.get('openwith') == 'gnome-open': @@ -500,7 +500,7 @@ def launch_file_manager(path_to_open): command = build_command(command, path_to_open) try: exec_command(command) - except: + except Exception: pass def play_sound(event): @@ -524,7 +524,7 @@ def play_sound_file(path_to_soundfile): try: winsound.PlaySound(path_to_soundfile, winsound.SND_FILENAME|winsound.SND_ASYNC) - except: + except Exception: pass elif os.name == 'posix': if gajim.config.get('soundplayer') == '': @@ -660,7 +660,7 @@ def ensure_utf8_string(string): '''make sure string is in UTF-8''' try: string = decode_string(string).encode('utf-8') - except: + except Exception: pass return string @@ -702,7 +702,7 @@ r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders') try: val = str(win32api.RegQueryValueEx(rkey, varname)[0]) val = win32api.ExpandEnvironmentStrings(val) # expand using environ - except: + except Exception: pass finally: win32api.RegCloseKey(rkey) diff --git a/src/common/logger.py b/src/common/logger.py index 358fb3b3f76b5d39ebcce393627e7291000a7e3d..c9e610f2db64e813d8fc40d40258757faf0f0d9e 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -369,7 +369,7 @@ class Logger: self.cur.execute( 'SELECT message_id from unread_messages') results = self.cur.fetchall() - except: + except Exception: pass for message in results: msg_id = message[0] diff --git a/src/common/nslookup.py b/src/common/nslookup.py index df629f9dac370fb5558fd353f32c9499dbebc94d..0c0ec9bc960d305081789b330ab92552a9de3c31 100644 --- a/src/common/nslookup.py +++ b/src/common/nslookup.py @@ -257,7 +257,7 @@ class IdleCommand(IdleObject): self.idlequeue.unplug_idle(self.fd) try: self.pipe.close() - except: + except Exception: pass def pollend(self): @@ -337,7 +337,7 @@ if __name__ == '__main__': def process(): try: idlequeue.process() - except: + except Exception: # Otherwise, an exception will stop our loop gobject.timeout_add(200, process) raise diff --git a/src/common/optparser.py b/src/common/optparser.py index 86098d0b8b53978613b8f3a4013c869feb29ac3a..5c4f05da2ff82385e7be274650348d662d0b4128 100644 --- a/src/common/optparser.py +++ b/src/common/optparser.py @@ -67,7 +67,7 @@ class OptionsParser: def read(self): try: fd = open(self.__filename) - except: + except Exception: if os.path.exists(self.__filename): #we talk about a file print _('error: cannot open %s for reading') % self.__filename @@ -128,7 +128,7 @@ class OptionsParser: # win32 needs this try: os.remove(self.__filename) - except: + except Exception: pass try: os.rename(self.__tempfile, self.__filename) @@ -360,7 +360,7 @@ class OptionsParser: ) con.commit() - except: + except Exception: pass con.close() gajim.config.set('version', '0.10.1.4') diff --git a/src/common/pubsub.py b/src/common/pubsub.py index dad29d18797701e3a1dce03f385eb5773c3124ff..deb35469f4e7bddf6dfa9b71f5a22145e103bc16 100644 --- a/src/common/pubsub.py +++ b/src/common/pubsub.py @@ -116,7 +116,7 @@ class ConnectionPubSub: try: cb, args, kwargs = self.__callbacks.pop(stanza.getID()) cb(conn, stanza, *args, **kwargs) - except: + except Exception: pass def request_pb_configuration(self, jid, node): diff --git a/src/common/sleepy.py b/src/common/sleepy.py index 0073908fd5d0c68772b2cea2033809805be22e03..94c8d517476443a77624c5653712eb84a83b1b7b 100644 --- a/src/common/sleepy.py +++ b/src/common/sleepy.py @@ -48,7 +48,7 @@ try: import osx.idle as idle else: # unix import idle -except: +except Exception: gajim.log.debug('Unable to load idle module') SUPPORTED = False @@ -92,7 +92,7 @@ class SleepyUnix: self.state = STATE_AWAKE # assume we are awake try: idle.init() - except: + except Exception: SUPPORTED = False self.state = STATE_UNKNOWN diff --git a/src/common/socks5.py b/src/common/socks5.py index c2af094c484f0e4f25528bca70127d0669493a9d..773886cc5776b5f3aca0a821a8145bbe45ef85a5 100644 --- a/src/common/socks5.py +++ b/src/common/socks5.py @@ -382,7 +382,7 @@ class Socks5: if not self.file.closed: try: self.file.close() - except: + except Exception: pass self.file = None @@ -410,7 +410,7 @@ class Socks5: del(self.file_props['fd']) try: fd.close() - except: + except Exception: pass @@ -559,7 +559,7 @@ class Socks5: try: self._sock.shutdown(socket.SHUT_RDWR) self._sock.close() - except: + except Exception: # socket is already closed pass self.connected = False @@ -580,7 +580,7 @@ class Socks5: for i in xrange(num_auth): mechanism, = struct.unpack('!B', buff[1 + i]) auth_mechanisms.append(mechanism) - except: + except Exception: return None return auth_mechanisms def _get_auth_response(self): @@ -623,7 +623,7 @@ class Socks5: else: port, = struct.unpack('!H', buff[host_len + 5: host_len + 7]) self.remaining_buff = buff[host_len + 7:] - except: + except Exception: return (None, None, None) return (req_type, host, port) @@ -632,7 +632,7 @@ class Socks5: buff = self._recv() try: version, method = struct.unpack('!BB', buff) - except: + except Exception: version, method = None, None if version != 0x05 or method == 0xff: self.disconnect() @@ -814,7 +814,7 @@ class Socks5Listener(IdleObject): self._serv.bind(ai[4]) self.ai = ai break - except: + except Exception: self.ai = None continue if not self.ai: @@ -844,7 +844,7 @@ class Socks5Listener(IdleObject): self.started = False try: self._serv.close() - except: + except Exception: pass def accept_conn(self): @@ -903,7 +903,7 @@ class Socks5Receiver(Socks5, IdleObject): self._sock.setblocking(False) self._server=ai[4] break - except: + except Exception: if sys.exc_value[0] == errno.EINPROGRESS: break #for all errors, we try other addresses diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index 8f7cd1a1628181df3fbd02d339ac4c68e5d1750a..d334ac1e5c82ff8c5de72b9b2709c40f5ae21fd0 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -339,7 +339,7 @@ class EncryptedStanzaSession(StanzaSession): try: parsed = xmpp.Node(node='<node>' + plaintext + '</node>') - except: + except Exception: raise exceptions.DecryptionError, 'decrypted <data/> not parseable as XML' for child in parsed.getChildren(): diff --git a/src/common/xmpp/auth_nb.py b/src/common/xmpp/auth_nb.py index 89065367ccef77d2c63d732b094e902c30134c2d..3992984522dc81eea646a65be27d3364f9fc3f77 100644 --- a/src/common/xmpp/auth_nb.py +++ b/src/common/xmpp/auth_nb.py @@ -174,7 +174,7 @@ class SASL(PlugIn): self.startsasl = 'failure' try: reason = challenge.getChildren()[0] - except: + except Exception: reason = challenge self.DEBUG('Failed SASL authentification: %s' % reason, 'error') if self.on_sasl : diff --git a/src/common/xmpp/client.py b/src/common/xmpp/client.py index 539a1481f62e22d70c04c8ca19281ea079a92f8b..3b0b05da3b49b6b76ed8bd7158b83fcb270e7662 100644 --- a/src/common/xmpp/client.py +++ b/src/common/xmpp/client.py @@ -318,7 +318,7 @@ class Component(CommonClient): return 'sasl' else: raise auth.NotAuthorized(self.SASL.startsasl) - except: + except Exception: self.DEBUG(self.DBG,"Failed to authenticate %s"%name,'error') # vim: se ts=3: \ No newline at end of file diff --git a/src/common/xmpp/client_nb.py b/src/common/xmpp/client_nb.py index 67c7f6a3ebf2b07dc33ed5658dab31ce38ce215a..d00c31964c26b4c72da4d19febccfc57bf0f7b6b 100644 --- a/src/common/xmpp/client_nb.py +++ b/src/common/xmpp/client_nb.py @@ -378,7 +378,7 @@ class Component(NBCommonClient): return self.SASL.auth() self.onreceive(self._on_auth_component) - except: + except Exception: self.DEBUG(self.DBG,"Failed to authenticate %s" % name,'error') def _on_auth_component(self, data): diff --git a/src/common/xmpp/commands.py b/src/common/xmpp/commands.py index 3e56587381434dddaa7f844dc19f8b6067272758..190e8f96d547d62324c200700bcdf058c668e874 100644 --- a/src/common/xmpp/commands.py +++ b/src/common/xmpp/commands.py @@ -75,7 +75,7 @@ class Commands(PlugIn): jid = str(request.getTo()) try: node = request.getTagAttr('command','node') - except: + except Exception: conn.send(Error(request,ERR_BAD_REQUEST)) raise NodeProcessed if jid in self._handlers: @@ -221,11 +221,11 @@ class Command_Handler_Prototype(PlugIn): # New request or old? try: session = request.getTagAttr('command','sessionid') - except: + except Exception: session = None try: action = request.getTagAttr('command','action') - except: + except Exception: action = None if action is None: action = 'execute' # Check session is in session list @@ -277,7 +277,7 @@ class TestCommand(Command_Handler_Prototype): # This is the only place this should be repeated as all other stages should have SessionIDs try: session = request.getTagAttr('command','sessionid') - except: + except Exception: session = None if session is None: session = self.getSessionID() @@ -309,7 +309,7 @@ class TestCommand(Command_Handler_Prototype): form = DataForm(node = result.getTag(name='command').getTag(name='x',namespace=NS_DATA)) try: num = float(form.getField('radius')) - except: + except Exception: self.cmdSecondStageReply(conn,request) if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea': result = num*(pi**2) diff --git a/src/common/xmpp/debug.py b/src/common/xmpp/debug.py index 9954f3433651de63888c88c4597a11a7ef0fee9d..2ff7997e2ad16a4298c74905e15ded4b0e0438e4 100644 --- a/src/common/xmpp/debug.py +++ b/src/common/xmpp/debug.py @@ -173,7 +173,7 @@ class Debug: if type( log_file ) is type(''): try: self._fh = open(log_file,'w') - except: + except Exception: print 'ERROR: can open %s for writing' sys.exit(0) else: ## assume its a stream type object @@ -196,7 +196,7 @@ class Debug: caller = sys._getframe(1) # used to get name of caller try: mod_name= ":%s" % caller.f_locals['__name__'] - except: + except Exception: mod_name = "" self.show('Debug created for %s%s' % (caller.f_code.co_filename, mod_name )) @@ -272,7 +272,7 @@ class Debug: output = output[:-1] try: self._fh.write( output ) - except: + except Exception: # unicode strikes again ;) s=u'' for i in range(len(output)): @@ -304,7 +304,7 @@ class Debug: # assume comma string try: flags = active_flags.split(',') - except: + except Exception: self.show( '***' ) self.show( '*** Invalid debug param given: %s' % active_flags ) self.show( '*** please correct your param!' ) diff --git a/src/common/xmpp/session.py b/src/common/xmpp/session.py index 3d49d16a53c09fef953bcf71eeebeab8e8eb1432..392692a285df3765e625c4137b8695eab281e4be 100644 --- a/src/common/xmpp/session.py +++ b/src/common/xmpp/session.py @@ -184,7 +184,7 @@ class Session: try: # LOCK_QUEUE sent=self._send(self.sendbuffer) # blocking socket - except: + except Exception: # UNLOCK_QUEUE self.set_socket_state(SOCKET_DEAD) self.DEBUG("Socket error while sending data",'error') diff --git a/src/common/xmpp/transports.py b/src/common/xmpp/transports.py index fe460fe14b573b6928cc19562708b31434535b39..e5c04a2f961215497fd0498f4f88462604a0aec4 100644 --- a/src/common/xmpp/transports.py +++ b/src/common/xmpp/transports.py @@ -146,7 +146,7 @@ class TCPsocket(PlugIn): if raw_data.strip(): self.DEBUG(raw_data,'sent') self._owner.Dispatcher.Event('', DATA_SENT, raw_data) - except: + except Exception: self.DEBUG("Socket error while sending data",'error') self._owner.disconnected() diff --git a/src/common/xmpp/transports_nb.py b/src/common/xmpp/transports_nb.py index cf144e1c064f30a6d34ee05071ed6b5498937492..8b2493fdc8f768ab83287cb82ab6be3f8d2749d4 100644 --- a/src/common/xmpp/transports_nb.py +++ b/src/common/xmpp/transports_nb.py @@ -69,7 +69,7 @@ def torf(cond, tv, fv): def gattr(obj, attr, default=None): try: return getattr(obj, attr) - except: + except Exception: return default class SSLWrapper: @@ -368,7 +368,7 @@ class NonBlockingTcp(PlugIn, IdleObject): self.remove_timeout() try: self._owner.disconnected() - except: + except Exception: pass self.idlequeue.unplug_idle(self.fd) sock = getattr(self, '_sock', None) @@ -652,7 +652,7 @@ class NonBlockingTcp(PlugIn, IdleObject): retval = None try: retval = gattr(self._owner, 'name') - except: + except Exception: pass if retval: return retval return self.getHost() @@ -768,7 +768,7 @@ class NonBlockingTLS(PlugIn): cacerts = os.path.join(common.gajim.DATA_DIR, 'other', 'cacerts.pem') try: tcpsock._sslContext.load_verify_locations(cacerts) - except: + except Exception: log.warning('Unable to load SSL certificats from file %s' % \ os.path.abspath(cacerts)) # load users certs @@ -811,7 +811,7 @@ class NonBlockingTLS(PlugIn): self.starttls='in progress' tcpsock._sslObj.do_handshake() # Errors are handeled in _do_receive function - except: + except Exception: pass tcpsock._sslObj.setblocking(False) log.debug("Synchronous handshake completed") @@ -843,7 +843,7 @@ class NonBlockingTLS(PlugIn): self._owner.Connection.ssl_cert_pem = OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_PEM, cert) return True - except: + except Exception: log.error("Exception caught in _ssl_info_callback:", exc_info=True) traceback.print_exc() # Make sure something is printed, even if log is disabled. @@ -920,7 +920,7 @@ class NBHTTPPROXYsocket(NonBlockingTcp): self.reply = reply.replace('\r', '') try: proto, code, desc = reply.split('\n')[0].split(' ', 2) - except: + except Exception: log.error("_on_headers_sent:", exc_info=True) #traceback.print_exc() self.on_proxy_failure('Invalid proxy reply') diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py index 379d523bbb734ac48e8593c7cd438d5fcb68ede0..b338ad9068baa7a4e294c5267351dec658ee85af 100644 --- a/src/common/zeroconf/connection_handlers_zeroconf.py +++ b/src/common/zeroconf/connection_handlers_zeroconf.py @@ -45,7 +45,7 @@ AGENT_REMOVED = 'agent_removed' HAS_IDLE = True try: import idle -except: +except Exception: gajim.log.debug(_('Unable to load idle module')) HAS_IDLE = False @@ -226,7 +226,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream): try: streamhost = query.getTag('streamhost-used') - except: # this bytestream result is not what we need + except Exception: # this bytestream result is not what we need pass id = real_id[3:] if id in self.files_props: @@ -382,7 +382,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream, connecti try: idle.init() - except: + except Exception: HAS_IDLE = False def _messageCB(self, ip, con, msg): @@ -429,7 +429,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream, connecti try: msg = session.decrypt_stanza(msg) - except: + except Exception: self.dispatch('FAILED_DECRYPT', (frm, tim)) msgtxt = msg.getBody() diff --git a/src/common/zeroconf/zeroconf_bonjour.py b/src/common/zeroconf/zeroconf_bonjour.py index 857cba2694994bab26b979feffe5f4645b071ca8..c6e281ad25b87fc009eabd52c4139b5c7b908628 100644 --- a/src/common/zeroconf/zeroconf_bonjour.py +++ b/src/common/zeroconf/zeroconf_bonjour.py @@ -186,7 +186,7 @@ class Zeroconf: #check if last part is a number and if, increment it try: stripped = str(int(parts[-1])) - except: + except Exception: stripped = 1 alternative_name = self.username + str(stripped+1) self.name_conflictCB(alternative_name) diff --git a/src/config.py b/src/config.py index cd02c2b6fe2802e30ce2218bfa29c1d5061d6a3d..f691b67d0ec85d510b4fa8c891e1549e36574114 100644 --- a/src/config.py +++ b/src/config.py @@ -48,7 +48,7 @@ import dataforms_widget try: import gtkspell HAS_GTK_SPELL = True -except: +except Exception: HAS_GTK_SPELL = False from common import helpers @@ -618,7 +618,7 @@ class PreferencesWindow: if isinstance(ctrl, chat_control.ChatControlBase): try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) - except: + except Exception: spell_obj = None if not spell_obj: @@ -630,7 +630,7 @@ class PreferencesWindow: if isinstance(ctrl, chat_control.ChatControlBase): try: spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) - except: + except Exception: spell_obj = None if spell_obj: spell_obj.detach() @@ -2014,7 +2014,7 @@ class AccountsWindow: custom_port = widget.get_text() try: custom_port = int(custom_port) - except: + except Exception: if not widget.is_focus(): dialogs.ErrorDialog(_('Invalid entry'), _('Custom port must be a port number.')) @@ -3160,7 +3160,7 @@ class AccountCreationWizardWindow: custom_port = self.xml.get_widget('custom_port_entry').get_text() try: custom_port = int(custom_port) - except: + except Exception: dialogs.ErrorDialog(_('Invalid entry'), _('Custom port must be a port number.')) return diff --git a/src/dialogs.py b/src/dialogs.py index c2e431b9763712ccc3fafd044d520c6605c53bc1..7411f764bbe63fa5d6d88d1180ee7cadc1a497e9 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -45,7 +45,7 @@ from common import pep try: import gtkspell HAS_GTK_SPELL = True -except: +except Exception: HAS_GTK_SPELL = False # those imports are not used in this file, but in files that 'import dialogs' @@ -1753,7 +1753,7 @@ class JoinGroupchatWindow: password = self._password_entry.get_text().decode('utf-8') try: nickname = helpers.parse_resource(nickname) - except: + except Exception: ErrorDialog(_('Invalid Nickname'), _('The nickname has not allowed characters.')) return @@ -1764,7 +1764,7 @@ class JoinGroupchatWindow: return try: room_jid = helpers.parse_jid(room_jid) - except: + except Exception: ErrorDialog(_('Invalid group chat Jabber ID'), _('The group chat Jabber ID has not allowed characters.')) return @@ -3058,7 +3058,7 @@ class ImageChooserDialog(FileChooserDialog): path = helpers.get_my_pictures_path() else: path = os.environ['HOME'] - except: + except Exception: path = '' FileChooserDialog.__init__(self, title_text = _('Choose Image'), diff --git a/src/disco.py b/src/disco.py index be51419a4487d400cc9d6372d0802550dc151496..337ad59111f80edef57f557f657fc64b080e02ef 100644 --- a/src/disco.py +++ b/src/disco.py @@ -1103,7 +1103,7 @@ class ToplevelAgentBrowser(AgentBrowser): iter = None try: iter = self.model.get_iter(row) - except: + except Exception: self.tooltip.hide_tooltip() return jid = self.model[iter][0] @@ -1961,7 +1961,7 @@ class DiscussionGroupsBrowser(AgentBrowser): have items on the list, we should actualize them. ''' try: subscriptions = request.getTag('pubsub').getTag('subscriptions') - except: + except Exception: return groups = set() diff --git a/src/features_window.py b/src/features_window.py index 822680d53a69e38a77400b51c4fcea7a45e08a3e..df2e2910ef8f364b8e694afbcfcaeefb58d1a040 100644 --- a/src/features_window.py +++ b/src/features_window.py @@ -164,17 +164,17 @@ class FeaturesWindow: try: import OpenSSL.SSL import OpenSSL.crypto - except: + except Exception: return False return True def zeroconf_available(self): try: import avahi - except: + except Exception: try: import pybonjour - except: + except Exception: return False return True @@ -201,7 +201,7 @@ class FeaturesWindow: return False try: import gnome.ui - except: + except Exception: return False return True @@ -210,7 +210,7 @@ class FeaturesWindow: return False try: import gnomekeyring - except: + except Exception: return False return True @@ -222,7 +222,7 @@ class FeaturesWindow: return False try: import gtkspell - except: + except Exception: return False return True @@ -232,7 +232,7 @@ class FeaturesWindow: elif sys.platform == 'darwin': try: import osx.growler - except: + except Exception: return False return True from common import dbus_support @@ -240,7 +240,7 @@ class FeaturesWindow: return True try: import pynotify - except: + except Exception: return False return True @@ -250,7 +250,7 @@ class FeaturesWindow: return True try: import systray - except: + except Exception: return False return True @@ -280,14 +280,14 @@ class FeaturesWindow: p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'], cwd=gettempdir()) exitcode = p.wait() - except: + except Exception: exitcode = 1 if exitcode == 0: try: p = Popen(['dvipng', '-bg', 'white', '-T', 'tight', tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir()) exitcode = p.wait() - except: + except Exception: exitcode = 1 extensions = ['.tex', '.log', '.aux', '.dvi', '.png'] for ext in extensions: @@ -306,7 +306,7 @@ class FeaturesWindow: def docutils_available(self): try: import docutils - except: + except Exception: return False return True diff --git a/src/filetransfers_window.py b/src/filetransfers_window.py index 8b24a25983345c58b759a29dab0058ce647866a2..84f53d52e5b4141eaea39acc93543e4fcb6cd5e8 100644 --- a/src/filetransfers_window.py +++ b/src/filetransfers_window.py @@ -632,7 +632,7 @@ _('Connection with peer cannot be established.')) iter = None try: iter = self.model.get_iter(row) - except: + except Exception: self.tooltip.hide_tooltip() return sid = self.model[iter][C_SID].decode('utf-8') diff --git a/src/gajim-remote.py b/src/gajim-remote.py index e4ea48b3d7e3bb0a385b24fef4345b180ad6e6f5..241e8d22134e5c108aa8cd0c79d34c1e90951e81 100755 --- a/src/gajim-remote.py +++ b/src/gajim-remote.py @@ -38,7 +38,7 @@ from common import i18n try: PREFERRED_ENCODING = locale.getpreferredencoding() -except: +except Exception: PREFERRED_ENCODING = 'UTF-8' def send_error(error_message): @@ -53,7 +53,7 @@ try: import dbus import dbus.service import dbus.glib -except: +except Exception: print str(exceptions.DbusNotSupported()) sys.exit(1) @@ -358,7 +358,7 @@ class GajimRemote: if not self.sbus: try: self.sbus = dbus.SessionBus() - except: + except Exception: raise exceptions.SessionBusNotPresent test = False @@ -375,7 +375,7 @@ class GajimRemote: or exit if it is not possible ''' try: self.sbus = dbus.SessionBus() - except: + except Exception: raise exceptions.SessionBusNotPresent if not self.check_gajim_running(): @@ -484,7 +484,7 @@ class GajimRemote: if (encode_return): try: ret_str = ret_str.encode(PREFERRED_ENCODING) - except: + except Exception: pass return ret_str diff --git a/src/gajim.py b/src/gajim.py index 9d4426d5d2099ed563f26cc0062300bf7c0110a9..02f58a53459f4ea7684f11ed287f2b17a7f52bfd 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -179,7 +179,7 @@ else: import dl libc = dl.open('/lib/libc.so.6') libc.call('prctl', 15, 'gajim\0', 0, 0, 0) - except: + except Exception: pass if gtk.pygtk_version < (2, 8, 0): @@ -208,7 +208,7 @@ else: try: import winsound # windows-only built-in module for playing wav import win32api # do NOT remove. we req this module - except: + except Exception: pritext = _('Gajim needs pywin32 to run') sectext = _('Please make sure that Pywin32 is installed on your system. You can get it at %s') % 'http://sourceforge.net/project/showfiles.php?group_id=78018' @@ -281,7 +281,7 @@ def pid_alive(): try: pid = int(pf.read().strip()) pf.close() - except: + except Exception: traceback.print_exc() # PID file exists, but something happened trying to read PID # Could be 0.10 style empty PID file, so assume Gajim is running @@ -290,7 +290,7 @@ def pid_alive(): if os.name == 'nt': try: from ctypes import (windll, c_ulong, c_int, Structure, c_char, POINTER, pointer, ) - except: + except Exception: return True class PROCESSENTRY32(Structure): @@ -352,7 +352,7 @@ def pid_alive(): if n.find('gajim') < 0: return False return True # Running Gajim found at pid - except: + except Exception: traceback.print_exc() # If we are here, pidfile exists, but some unexpected error occured. @@ -443,7 +443,7 @@ class GlibIdleQueue(idlequeue.IdleQueue): def _process_events(self, fd, flags): try: return self.process_events(fd, flags) - except: + except Exception: self.remove_idle(fd) self.add_idle(fd, flags) raise @@ -2357,7 +2357,7 @@ class Interface: img = gtk.Image() try: img.set_from_file(image) - except: + except Exception: return False t = img.get_storage_type() if t != gtk.IMAGE_PIXBUF and t != gtk.IMAGE_ANIMATION: @@ -2566,7 +2566,7 @@ class Interface: fd.close() del emoticons self._init_emoticons(path, need_reload=True) - except: + except Exception: pass if len(self.emoticons) == 0: dialogs.WarningDialog(_('Emoticons disabled'), @@ -2860,7 +2860,7 @@ class Interface: ''' try: gajim.idlequeue.process() - except: + except Exception: # Otherwise, an exception will stop our loop if gajim.idlequeue.__class__ == GlibIdleQueue: gobject.timeout_add_seconds(2, self.process_connections) @@ -3074,7 +3074,7 @@ class Interface: '/apps/nautilus/preferences/click_policy') if click_policy == 'single': gajim.single_click = True - except: + except Exception: pass # add default status messages if there is not in the config file if len(gajim.config.get_per('statusmsg')) == 0: @@ -3167,7 +3167,7 @@ class Interface: try: import remote_control self.remote_ctrl = remote_control.Remote() - except: + except Exception: self.remote_ctrl = None else: self.remote_ctrl = None @@ -3205,7 +3205,7 @@ class Interface: bus = dbus.SessionBus() bus.add_signal_receiver(gnome_screensaver_ActiveChanged_cb, 'ActiveChanged', 'org.gnome.ScreenSaver') - except: + except Exception: pass self.show_vcard_when_connect = [] @@ -3261,7 +3261,7 @@ class Interface: try: import gtkspell spell = gtkspell.Spell(tv, lang) - except: + except Exception: dialogs.AspellDictError(lang) if gajim.config.get('soundplayer') == '': diff --git a/src/groupchat_control.py b/src/groupchat_control.py index 054dc9c83b490350744f3194929a0eceebb0eca4..e4f258f683c93cb2a633565390c813a70cdbbf64 100644 --- a/src/groupchat_control.py +++ b/src/groupchat_control.py @@ -1426,7 +1426,7 @@ class GroupchatControl(ChatControlBase): nick = message_array[0] try: nick = helpers.parse_resource(nick) - except: + except Exception: # Invalid Nickname dialogs.ErrorDialog(_('Invalid nickname'), _('The nickname has not allowed characters.')) @@ -1707,7 +1707,7 @@ class GroupchatControl(ChatControlBase): self.change_nick_dialog = None try: nick = helpers.parse_resource(nick) - except: + except Exception: # invalid char dialogs.ErrorDialog(_('Invalid nickname'), _('The nickname has not allowed characters.')) @@ -1876,7 +1876,7 @@ class GroupchatControl(ChatControlBase): # Test jid try: jid = helpers.parse_jid(jid) - except: + except Exception: dialogs.ErrorDialog(_('Invalid group chat Jabber ID'), _('The group chat Jabber ID has not allowed characters.')) return @@ -2297,7 +2297,7 @@ class GroupchatControl(ChatControlBase): iter = None try: iter = model.get_iter(row) - except: + except Exception: self.tooltip.hide_tooltip() return typ = model[iter][C_TYPE].decode('utf-8') diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index 83cdad0baee96fc5f8ca674a6a75f67dc9e40b8a..4cdef98fb4bfc4dfbc70905ef18aecaaa9df3f69 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -141,7 +141,7 @@ def get_default_font(): return client.get_string('/desktop/gnome/interface/font_name' ).decode('utf-8') - except: + except Exception: pass # try to get xfce default font @@ -161,7 +161,7 @@ def get_default_font(): if line.find('name="Gtk/FontName"') != -1: start = line.find('value="') + 7 return line[start:line.find('"', start)].decode('utf-8') - except: + except Exception: #we talk about file print >> sys.stderr, _('Error: cannot open %s for reading') % xfce_config_file @@ -176,7 +176,7 @@ def get_default_font(): font_size = values[1] font_string = '%s %s' % (font_name, font_size) # Verdana 9 return font_string.decode('utf-8') - except: + except Exception: #we talk about file print >> sys.stderr, _('Error: cannot open %s for reading') % kde_config_file @@ -650,10 +650,10 @@ def decode_filechooser_file_paths(file_paths): for file_path in file_paths: try: file_path = file_path.decode(sys.getfilesystemencoding()) - except: + except Exception: try: file_path = file_path.decode('utf-8') - except: + except Exception: pass file_paths_list.append(file_path) @@ -713,7 +713,7 @@ Description=xmpp import gconf # in try because daemon may not be there client = gconf.client_get_default() - except: + except Exception: return old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command') diff --git a/src/htmltextview.py b/src/htmltextview.py index 342cffadf32ef215ef33e0191dc33c4b32b01957..2849461c5acb3a52c4ec80b48328b300d02a1329 100644 --- a/src/htmltextview.py +++ b/src/htmltextview.py @@ -222,7 +222,7 @@ def build_patterns(view, config, interface): '(?:(?<![\w.]' + emoticons_pattern_prematch[:-1] + '))' + \ '(?:' + emoticons_pattern[:-1] + ')' + \ '(?:(?![\w.]' + emoticons_pattern_postmatch[:-1] + '))' - except: + except Exception: pass view.emot_pattern_re = re.compile(emoticons_pattern, re.IGNORECASE) @@ -377,7 +377,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): # validate length val = sign*max(minl,min(abs(val),maxl)) callback(val, *args) - except: + except Exception: warnings.warn('Unable to parse length value "%s"' % value) def __parse_font_size_cb(length, tag): @@ -510,7 +510,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): def __length_tag_cb(self, value, tag, propname): try: tag.set_property(propname, value) - except: + except Exception: gajim.log.warn( "Error with prop: " + propname + " for tag: " + str(tag)) @@ -575,7 +575,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): # Wait 0.1s between each byte try: f.fp._sock.fp._sock.settimeout(0.5) - except: + except Exception: pass # Max image size = 2 MB (to try to prevent DoS) mem = '' @@ -675,7 +675,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler): alt = attrs.get('alt', 'Broken image') try: loader.close() - except: + except Exception: pass return pixbuf diff --git a/src/lastfm.py b/src/lastfm.py index 7f8b1808fa22a85b283f31ad5a582d28812cd409..f368ee7d23077293d71460fb9f6efbd384d35a14 100644 --- a/src/lastfm.py +++ b/src/lastfm.py @@ -75,7 +75,7 @@ class LastFM: xmldocument = urlopen(self.LASTFM_FORMAT_URL % self._username, self._proxies) xmltree = minidom.parse(xmldocument) - except: + except Exception: print 'Error parsing XML from Last.fm...' return False diff --git a/src/message_window.py b/src/message_window.py index c0f921e4a744be3225543131e1daea73f50eae3d..cd4a1d8203cbdff9d0fdc7c7971ef3486659c6a0 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -636,7 +636,7 @@ class MessageWindow(object): jid = key try: return self._controls[acct][jid] - except: + except Exception: return None else: page_num = key diff --git a/src/network_manager_listener.py b/src/network_manager_listener.py index 91a37d0cbbcf76ba8d263eafe3bfa17c1c6db315..710e21818b154459f57c417bada31028ba2dd7a4 100644 --- a/src/network_manager_listener.py +++ b/src/network_manager_listener.py @@ -59,7 +59,7 @@ else: 'org.freedesktop.NetworkManager', 'org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager') - except: + except Exception: pass # vim: se ts=3: diff --git a/src/notify.py b/src/notify.py index 8687e35844ecf23ffbb13b0a42688b963d9229e7..01fa1148d7e0fad4d7de18796731295f480f1bd1 100644 --- a/src/notify.py +++ b/src/notify.py @@ -54,7 +54,7 @@ USER_HAS_GROWL = True try: import osx.growler osx.growler.init() -except: +except Exception: USER_HAS_GROWL = False def get_show_in_roster(event, account, contact, session=None): @@ -313,7 +313,7 @@ def notify(event, jid, account, parameters, advanced_notif_num=None): 'command') try: helpers.exec_command(command) - except: + except Exception: pass def popup(event_type, jid, account, msg_type='', path_to_image=None, diff --git a/src/osx/dbus.py b/src/osx/dbus.py index 700b274d7b1827ed542a663131e7599bb0927b6b..20376bc36d85c6490108bc134f4a131ad39fca99 100644 --- a/src/osx/dbus.py +++ b/src/osx/dbus.py @@ -21,13 +21,13 @@ def readEnv(): gajimpaths.add_from_root(u'dbus.env', u'dbus.env') try: dbus_env = file(gajimpaths[u'dbus.env'], "r") - except: + except Exception: return False try: line1 = dbus_env.readline() line2 = dbus_env.readline() dbus_env.close() - except: + except Exception: print "Invalid dbus.env file" return False return parseEnv(line1, line2) diff --git a/src/osx/growl/Growl.py b/src/osx/growl/Growl.py index 09270f7e64ba0fc3bc3c1c83d15888d7a10a81c2..b9ed533ba2b1d8bdf6ba49039579685eafa45dca 100644 --- a/src/osx/growl/Growl.py +++ b/src/osx/growl/Growl.py @@ -12,7 +12,7 @@ __contributors__ = ["Ingmar J Stein (Growl Team)", try: import _growl -except: +except Exception: _growl = False import types import struct diff --git a/src/remote_control.py b/src/remote_control.py index cfaa04f3c9cb3f8dcb07f028ec76a4b9cfafe378..62d3f8b68d05ad132dc442e92be82dde8da02c20 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -332,7 +332,7 @@ class SignalObject(dbus.service.Object): jid = self._get_real_jid(jid, account) try: jid = helpers.parse_jid(jid) - except: + except Exception: # Jid is not conform, ignore it return DBUS_BOOLEAN(False) diff --git a/src/roster_window.py b/src/roster_window.py index 78a0271cfc28eeb66b826e1f8a617c3a96a912fd..234484d02f26630f2af08a9bbee69986b620838e 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1702,7 +1702,7 @@ class RosterWindow: if not 'com.google.code.Awn' in bus.list_names(): # Awn is not installed return - except: + except Exception: return iconset = gajim.config.get('iconset') prefix = os.path.join(helpers.get_iconset_path(iconset), '32x32') @@ -2379,7 +2379,7 @@ class RosterWindow: titer = None try: titer = model.get_iter(row) - except: + except Exception: self.tooltip.hide_tooltip() return if model[titer][C_TYPE] in ('contact', 'self_contact'): diff --git a/src/systray.py b/src/systray.py index b43a566b6e9eae1a56f5cba64542e0bad84114e0..f5d06b57ab8c6ea75741a3d58f73d93073d6357a 100644 --- a/src/systray.py +++ b/src/systray.py @@ -43,10 +43,10 @@ HAS_SYSTRAY_CAPABILITIES = True try: import egg.trayicon as trayicon # gnomepythonextras trayicon -except: +except Exception: try: import trayicon # our trayicon - except: + except Exception: gajim.log.debug('No trayicon module available') HAS_SYSTRAY_CAPABILITIES = False diff --git a/src/vcard.py b/src/vcard.py index f824217fb071fa81f0216516c1c411a596cef3bb..0685976bfedafeef3fca24f0738e30233b158c05 100644 --- a/src/vcard.py +++ b/src/vcard.py @@ -58,7 +58,7 @@ def get_avatar_pixbuf_encoded_mime(photo): avatar_encoded = img_encoded try: img_decoded = base64.decodestring(img_encoded) - except: + except Exception: pass if img_decoded: if 'TYPE' in photo: diff --git a/test/runtests.py b/test/runtests.py index ef353bce38d63283594d80dabb8cbee6811921b9..1d513c416d9e2ca8a93076fd7bd4e8530340c45e 100755 --- a/test/runtests.py +++ b/test/runtests.py @@ -23,7 +23,7 @@ for o, a in opts: elif o in ('-v', '--verbose'): try: verbose = int(a) - except: + except Exception: print 'verbose must be a number >= 0' sys.exit(2)