[thorstenp] di not use emtpy except clauses

This commit is contained in:
Yann Leboulanger 2008-10-11 09:37:13 +00:00
parent 84e717c8df
commit 567f1e17c1
46 changed files with 149 additions and 149 deletions

View File

@ -82,7 +82,7 @@ def check(ret):
def force(func): def force(func):
try: try:
func() func()
except: except Exception:
pass pass
return return

View File

@ -56,7 +56,7 @@ from common.xmpp.protocol import NS_ESESSION
try: try:
import gtkspell import gtkspell
HAS_GTK_SPELL = True HAS_GTK_SPELL = True
except: except Exception:
HAS_GTK_SPELL = False HAS_GTK_SPELL = False
HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0) HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0)
@ -281,7 +281,7 @@ class ChatControlBase(MessageControl):
for lang in dict(langs): for lang in dict(langs):
try: try:
spell.set_language(langs[lang]) spell.set_language(langs[lang])
except: except Exception:
del langs[lang] del langs[lang]
# now set the one the user selected # now set the one the user selected
per_type = 'contacts' per_type = 'contacts'

View File

@ -107,7 +107,7 @@ class OldEntry(xmpp.Node, object):
''' Get source link ''' ''' Get source link '''
try: try:
return self.getTag('feed').getTags('link',{'rel':'alternate'})[1].getData() return self.getTag('feed').getTags('link',{'rel':'alternate'})[1].getData()
except: except Exception:
return None return None
feed_link = property(get_feed_link, None, None, feed_link = property(get_feed_link, None, None,

View File

@ -121,7 +121,7 @@ class ChangeStatusCommand(AdHocCommand):
try: try:
form = dataforms.SimpleDataForm(extend = request.getTag('command').\ form = dataforms.SimpleDataForm(extend = request.getTag('command').\
getTag('x')) getTag('x'))
except: except Exception:
self.badRequest(request) self.badRequest(request)
return False return False
@ -131,14 +131,14 @@ class ChangeStatusCommand(AdHocCommand):
('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'): ('free-for-chat', 'online', 'away', 'xa', 'dnd', 'offline'):
self.badRequest(request) self.badRequest(request)
return False 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 # AttributeError if that field is of wrong type
self.badRequest(request) self.badRequest(request)
return False return False
try: try:
presencedesc = form['presence-desc'].value presencedesc = form['presence-desc'].value
except: # same exceptions as in last comment except Exception: # same exceptions as in last comment
presencedesc = u'' presencedesc = u''
response, cmd = self.buildResponse(request, status = 'completed') response, cmd = self.buildResponse(request, status = 'completed')
@ -219,13 +219,13 @@ class LeaveGroupchatsCommand(AdHocCommand):
try: try:
form = dataforms.SimpleDataForm(extend = request.getTag('command').\ form = dataforms.SimpleDataForm(extend = request.getTag('command').\
getTag('x')) getTag('x'))
except: except Exception:
self.badRequest(request) self.badRequest(request)
return False return False
try: try:
gc = form['groupchats'].values 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) self.badRequest(request)
return False return False
account = self.connection.name account = self.connection.name
@ -240,7 +240,7 @@ class LeaveGroupchatsCommand(AdHocCommand):
gajim.interface.roster.remove_groupchat(room_jid, account) gajim.interface.roster.remove_groupchat(room_jid, account)
continue continue
gc_control.parent_win.remove_tab(gc_control, None, force = True) 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) self.badRequest(request)
return False return False
response, cmd = self.buildResponse(request, status = 'completed') response, cmd = self.buildResponse(request, status = 'completed')

View File

@ -481,7 +481,7 @@ class Config:
def is_valid_int(self, val): def is_valid_int(self, val):
try: try:
ival = int(val) ival = int(val)
except: except Exception:
return None return None
return ival return ival

View File

@ -41,7 +41,7 @@ import locale
try: try:
randomsource = random.SystemRandom() randomsource = random.SystemRandom()
except: except Exception:
randomsource = random.Random() randomsource = random.Random()
randomsource.seed() randomsource.seed()
@ -447,7 +447,7 @@ class Connection(ConnectionHandlers):
try: try:
try: try:
env_http_proxy = os.environ['HTTP_PROXY'] env_http_proxy = os.environ['HTTP_PROXY']
except: except Exception:
env_http_proxy = os.environ['http_proxy'] env_http_proxy = os.environ['http_proxy']
env_http_proxy = env_http_proxy.strip('"') env_http_proxy = env_http_proxy.strip('"')
# Dispose of the http:// prefix # Dispose of the http:// prefix
@ -474,7 +474,7 @@ class Connection(ConnectionHandlers):
else: else:
proxy['password'] = u'' proxy['password'] = u''
except: except Exception:
proxy = None proxy = None
else: else:
proxy = None proxy = None

View File

@ -67,7 +67,7 @@ PEP_CONFIG = 'pep_config'
HAS_IDLE = True HAS_IDLE = True
try: try:
import idle import idle
except: except Exception:
gajim.log.debug(_('Unable to load idle module')) gajim.log.debug(_('Unable to load idle module'))
HAS_IDLE = False HAS_IDLE = False
@ -461,7 +461,7 @@ class ConnectionBytestream:
try: try:
streamhost = query.getTag('streamhost-used') 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 pass
id = real_id[3:] id = real_id[3:]
if id in self.files_props: if id in self.files_props:
@ -944,7 +944,7 @@ class ConnectionVcard:
f.close() f.close()
try: try:
card = common.xmpp.Node(node = c) card = common.xmpp.Node(node = c)
except: except Exception:
# We are unable to parse it. Remove it # We are unable to parse it. Remove it
os.remove(path_to_file) os.remove(path_to_file)
return None return None
@ -1107,7 +1107,7 @@ class ConnectionVcard:
order = meta.getAttr('order') order = meta.getAttr('order')
try: try:
order = int(order) order = int(order)
except: except Exception:
order = 0 order = 0
if order is not None: if order is not None:
data['order'] = order data['order'] = order
@ -1174,7 +1174,7 @@ class ConnectionVcard:
try: try:
photo_decoded = base64.decodestring(photo) photo_decoded = base64.decodestring(photo)
avatar_sha = sha.sha(photo_decoded).hexdigest() avatar_sha = sha.sha(photo_decoded).hexdigest()
except: except Exception:
avatar_sha = '' avatar_sha = ''
else: else:
avatar_sha = '' avatar_sha = ''
@ -1388,7 +1388,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
try: try:
idle.init() idle.init()
except: except Exception:
HAS_IDLE = False HAS_IDLE = False
self.gmail_last_tid = None self.gmail_last_tid = None
@ -1532,7 +1532,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
status = qp.getData() status = qp.getData()
try: try:
seconds = int(seconds) seconds = int(seconds)
except: except Exception:
return return
id = iq_obj.getID() id = iq_obj.getID()
if id in self.groupchat_jids: if id in self.groupchat_jids:
@ -1771,7 +1771,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
try: try:
msg = session.decrypt_stanza(msg) msg = session.decrypt_stanza(msg)
msgtxt = msg.getBody() msgtxt = msg.getBody()
except: except Exception:
self.dispatch('FAILED_DECRYPT', (frm, tim, session)) self.dispatch('FAILED_DECRYPT', (frm, tim, session))
# Receipt requested # Receipt requested
@ -1938,7 +1938,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
gajim.log.debug('PresenceCB: %s' % ptype) gajim.log.debug('PresenceCB: %s' % ptype)
try: try:
who = helpers.get_full_jid_from_iq(prs) who = helpers.get_full_jid_from_iq(prs)
except: except Exception:
if prs.getTag('error').getTag('jid-malformed'): if prs.getTag('error').getTag('jid-malformed'):
# wrong jid, we probably tried to change our nick in a room to a non # wrong jid, we probably tried to change our nick in a room to a non
# valid one # valid one
@ -2000,7 +2000,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
prio = prs.getPriority() prio = prs.getPriority()
try: try:
prio = int(prio) prio = int(prio)
except: except Exception:
prio = 0 prio = 0
keyID = '' keyID = ''
if sigTag and self.USE_GPG and ptype != 'error': if sigTag and self.USE_GPG and ptype != 'error':

View File

@ -69,7 +69,7 @@ try:
import winsound # windows-only built-in module for playing wav import winsound # windows-only built-in module for playing wav
import win32api import win32api
import win32con import win32con
except: except Exception:
pass pass
special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats')) special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats'))
@ -447,7 +447,7 @@ def launch_browser_mailer(kind, uri):
if os.name == 'nt': if os.name == 'nt':
try: try:
os.startfile(uri) # if pywin32 is installed we open os.startfile(uri) # if pywin32 is installed we open
except: except Exception:
pass pass
else: else:
@ -474,14 +474,14 @@ def launch_browser_mailer(kind, uri):
command = build_command(command, uri) command = build_command(command, uri)
try: try:
exec_command(command) exec_command(command)
except: except Exception:
pass pass
def launch_file_manager(path_to_open): def launch_file_manager(path_to_open):
if os.name == 'nt': if os.name == 'nt':
try: try:
os.startfile(path_to_open) # if pywin32 is installed we open os.startfile(path_to_open) # if pywin32 is installed we open
except: except Exception:
pass pass
else: else:
if gajim.config.get('openwith') == 'gnome-open': 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) command = build_command(command, path_to_open)
try: try:
exec_command(command) exec_command(command)
except: except Exception:
pass pass
def play_sound(event): def play_sound(event):
@ -524,7 +524,7 @@ def play_sound_file(path_to_soundfile):
try: try:
winsound.PlaySound(path_to_soundfile, winsound.PlaySound(path_to_soundfile,
winsound.SND_FILENAME|winsound.SND_ASYNC) winsound.SND_FILENAME|winsound.SND_ASYNC)
except: except Exception:
pass pass
elif os.name == 'posix': elif os.name == 'posix':
if gajim.config.get('soundplayer') == '': if gajim.config.get('soundplayer') == '':
@ -660,7 +660,7 @@ def ensure_utf8_string(string):
'''make sure string is in UTF-8''' '''make sure string is in UTF-8'''
try: try:
string = decode_string(string).encode('utf-8') string = decode_string(string).encode('utf-8')
except: except Exception:
pass pass
return string return string
@ -702,7 +702,7 @@ r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders')
try: try:
val = str(win32api.RegQueryValueEx(rkey, varname)[0]) val = str(win32api.RegQueryValueEx(rkey, varname)[0])
val = win32api.ExpandEnvironmentStrings(val) # expand using environ val = win32api.ExpandEnvironmentStrings(val) # expand using environ
except: except Exception:
pass pass
finally: finally:
win32api.RegCloseKey(rkey) win32api.RegCloseKey(rkey)

View File

@ -369,7 +369,7 @@ class Logger:
self.cur.execute( self.cur.execute(
'SELECT message_id from unread_messages') 'SELECT message_id from unread_messages')
results = self.cur.fetchall() results = self.cur.fetchall()
except: except Exception:
pass pass
for message in results: for message in results:
msg_id = message[0] msg_id = message[0]

View File

@ -257,7 +257,7 @@ class IdleCommand(IdleObject):
self.idlequeue.unplug_idle(self.fd) self.idlequeue.unplug_idle(self.fd)
try: try:
self.pipe.close() self.pipe.close()
except: except Exception:
pass pass
def pollend(self): def pollend(self):
@ -337,7 +337,7 @@ if __name__ == '__main__':
def process(): def process():
try: try:
idlequeue.process() idlequeue.process()
except: except Exception:
# Otherwise, an exception will stop our loop # Otherwise, an exception will stop our loop
gobject.timeout_add(200, process) gobject.timeout_add(200, process)
raise raise

View File

@ -67,7 +67,7 @@ class OptionsParser:
def read(self): def read(self):
try: try:
fd = open(self.__filename) fd = open(self.__filename)
except: except Exception:
if os.path.exists(self.__filename): if os.path.exists(self.__filename):
#we talk about a file #we talk about a file
print _('error: cannot open %s for reading') % self.__filename print _('error: cannot open %s for reading') % self.__filename
@ -128,7 +128,7 @@ class OptionsParser:
# win32 needs this # win32 needs this
try: try:
os.remove(self.__filename) os.remove(self.__filename)
except: except Exception:
pass pass
try: try:
os.rename(self.__tempfile, self.__filename) os.rename(self.__tempfile, self.__filename)
@ -360,7 +360,7 @@ class OptionsParser:
) )
con.commit() con.commit()
except: except Exception:
pass pass
con.close() con.close()
gajim.config.set('version', '0.10.1.4') gajim.config.set('version', '0.10.1.4')

View File

@ -116,7 +116,7 @@ class ConnectionPubSub:
try: try:
cb, args, kwargs = self.__callbacks.pop(stanza.getID()) cb, args, kwargs = self.__callbacks.pop(stanza.getID())
cb(conn, stanza, *args, **kwargs) cb(conn, stanza, *args, **kwargs)
except: except Exception:
pass pass
def request_pb_configuration(self, jid, node): def request_pb_configuration(self, jid, node):

View File

@ -48,7 +48,7 @@ try:
import osx.idle as idle import osx.idle as idle
else: # unix else: # unix
import idle import idle
except: except Exception:
gajim.log.debug('Unable to load idle module') gajim.log.debug('Unable to load idle module')
SUPPORTED = False SUPPORTED = False
@ -92,7 +92,7 @@ class SleepyUnix:
self.state = STATE_AWAKE # assume we are awake self.state = STATE_AWAKE # assume we are awake
try: try:
idle.init() idle.init()
except: except Exception:
SUPPORTED = False SUPPORTED = False
self.state = STATE_UNKNOWN self.state = STATE_UNKNOWN

View File

@ -382,7 +382,7 @@ class Socks5:
if not self.file.closed: if not self.file.closed:
try: try:
self.file.close() self.file.close()
except: except Exception:
pass pass
self.file = None self.file = None
@ -410,7 +410,7 @@ class Socks5:
del(self.file_props['fd']) del(self.file_props['fd'])
try: try:
fd.close() fd.close()
except: except Exception:
pass pass
@ -559,7 +559,7 @@ class Socks5:
try: try:
self._sock.shutdown(socket.SHUT_RDWR) self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close() self._sock.close()
except: except Exception:
# socket is already closed # socket is already closed
pass pass
self.connected = False self.connected = False
@ -580,7 +580,7 @@ class Socks5:
for i in xrange(num_auth): for i in xrange(num_auth):
mechanism, = struct.unpack('!B', buff[1 + i]) mechanism, = struct.unpack('!B', buff[1 + i])
auth_mechanisms.append(mechanism) auth_mechanisms.append(mechanism)
except: except Exception:
return None return None
return auth_mechanisms return auth_mechanisms
def _get_auth_response(self): def _get_auth_response(self):
@ -623,7 +623,7 @@ class Socks5:
else: else:
port, = struct.unpack('!H', buff[host_len + 5: host_len + 7]) port, = struct.unpack('!H', buff[host_len + 5: host_len + 7])
self.remaining_buff = buff[host_len + 7:] self.remaining_buff = buff[host_len + 7:]
except: except Exception:
return (None, None, None) return (None, None, None)
return (req_type, host, port) return (req_type, host, port)
@ -632,7 +632,7 @@ class Socks5:
buff = self._recv() buff = self._recv()
try: try:
version, method = struct.unpack('!BB', buff) version, method = struct.unpack('!BB', buff)
except: except Exception:
version, method = None, None version, method = None, None
if version != 0x05 or method == 0xff: if version != 0x05 or method == 0xff:
self.disconnect() self.disconnect()
@ -814,7 +814,7 @@ class Socks5Listener(IdleObject):
self._serv.bind(ai[4]) self._serv.bind(ai[4])
self.ai = ai self.ai = ai
break break
except: except Exception:
self.ai = None self.ai = None
continue continue
if not self.ai: if not self.ai:
@ -844,7 +844,7 @@ class Socks5Listener(IdleObject):
self.started = False self.started = False
try: try:
self._serv.close() self._serv.close()
except: except Exception:
pass pass
def accept_conn(self): def accept_conn(self):
@ -903,7 +903,7 @@ class Socks5Receiver(Socks5, IdleObject):
self._sock.setblocking(False) self._sock.setblocking(False)
self._server=ai[4] self._server=ai[4]
break break
except: except Exception:
if sys.exc_value[0] == errno.EINPROGRESS: if sys.exc_value[0] == errno.EINPROGRESS:
break break
#for all errors, we try other addresses #for all errors, we try other addresses

View File

@ -339,7 +339,7 @@ class EncryptedStanzaSession(StanzaSession):
try: try:
parsed = xmpp.Node(node='<node>' + plaintext + '</node>') parsed = xmpp.Node(node='<node>' + plaintext + '</node>')
except: except Exception:
raise exceptions.DecryptionError, 'decrypted <data/> not parseable as XML' raise exceptions.DecryptionError, 'decrypted <data/> not parseable as XML'
for child in parsed.getChildren(): for child in parsed.getChildren():

View File

@ -174,7 +174,7 @@ class SASL(PlugIn):
self.startsasl = 'failure' self.startsasl = 'failure'
try: try:
reason = challenge.getChildren()[0] reason = challenge.getChildren()[0]
except: except Exception:
reason = challenge reason = challenge
self.DEBUG('Failed SASL authentification: %s' % reason, 'error') self.DEBUG('Failed SASL authentification: %s' % reason, 'error')
if self.on_sasl : if self.on_sasl :

View File

@ -318,7 +318,7 @@ class Component(CommonClient):
return 'sasl' return 'sasl'
else: else:
raise auth.NotAuthorized(self.SASL.startsasl) raise auth.NotAuthorized(self.SASL.startsasl)
except: except Exception:
self.DEBUG(self.DBG,"Failed to authenticate %s"%name,'error') self.DEBUG(self.DBG,"Failed to authenticate %s"%name,'error')
# vim: se ts=3: # vim: se ts=3:

View File

@ -378,7 +378,7 @@ class Component(NBCommonClient):
return return
self.SASL.auth() self.SASL.auth()
self.onreceive(self._on_auth_component) self.onreceive(self._on_auth_component)
except: except Exception:
self.DEBUG(self.DBG,"Failed to authenticate %s" % name,'error') self.DEBUG(self.DBG,"Failed to authenticate %s" % name,'error')
def _on_auth_component(self, data): def _on_auth_component(self, data):

View File

@ -75,7 +75,7 @@ class Commands(PlugIn):
jid = str(request.getTo()) jid = str(request.getTo())
try: try:
node = request.getTagAttr('command','node') node = request.getTagAttr('command','node')
except: except Exception:
conn.send(Error(request,ERR_BAD_REQUEST)) conn.send(Error(request,ERR_BAD_REQUEST))
raise NodeProcessed raise NodeProcessed
if jid in self._handlers: if jid in self._handlers:
@ -221,11 +221,11 @@ class Command_Handler_Prototype(PlugIn):
# New request or old? # New request or old?
try: try:
session = request.getTagAttr('command','sessionid') session = request.getTagAttr('command','sessionid')
except: except Exception:
session = None session = None
try: try:
action = request.getTagAttr('command','action') action = request.getTagAttr('command','action')
except: except Exception:
action = None action = None
if action is None: action = 'execute' if action is None: action = 'execute'
# Check session is in session list # 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 # This is the only place this should be repeated as all other stages should have SessionIDs
try: try:
session = request.getTagAttr('command','sessionid') session = request.getTagAttr('command','sessionid')
except: except Exception:
session = None session = None
if session is None: if session is None:
session = self.getSessionID() 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)) form = DataForm(node = result.getTag(name='command').getTag(name='x',namespace=NS_DATA))
try: try:
num = float(form.getField('radius')) num = float(form.getField('radius'))
except: except Exception:
self.cmdSecondStageReply(conn,request) self.cmdSecondStageReply(conn,request)
if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea': if sessions[request.getTagAttr('command','sessionid')]['data']['type'] == 'circlearea':
result = num*(pi**2) result = num*(pi**2)

View File

@ -173,7 +173,7 @@ class Debug:
if type( log_file ) is type(''): if type( log_file ) is type(''):
try: try:
self._fh = open(log_file,'w') self._fh = open(log_file,'w')
except: except Exception:
print 'ERROR: can open %s for writing' print 'ERROR: can open %s for writing'
sys.exit(0) sys.exit(0)
else: ## assume its a stream type object else: ## assume its a stream type object
@ -196,7 +196,7 @@ class Debug:
caller = sys._getframe(1) # used to get name of caller caller = sys._getframe(1) # used to get name of caller
try: try:
mod_name= ":%s" % caller.f_locals['__name__'] mod_name= ":%s" % caller.f_locals['__name__']
except: except Exception:
mod_name = "" mod_name = ""
self.show('Debug created for %s%s' % (caller.f_code.co_filename, self.show('Debug created for %s%s' % (caller.f_code.co_filename,
mod_name )) mod_name ))
@ -272,7 +272,7 @@ class Debug:
output = output[:-1] output = output[:-1]
try: try:
self._fh.write( output ) self._fh.write( output )
except: except Exception:
# unicode strikes again ;) # unicode strikes again ;)
s=u'' s=u''
for i in range(len(output)): for i in range(len(output)):
@ -304,7 +304,7 @@ class Debug:
# assume comma string # assume comma string
try: try:
flags = active_flags.split(',') flags = active_flags.split(',')
except: except Exception:
self.show( '***' ) self.show( '***' )
self.show( '*** Invalid debug param given: %s' % active_flags ) self.show( '*** Invalid debug param given: %s' % active_flags )
self.show( '*** please correct your param!' ) self.show( '*** please correct your param!' )

View File

@ -184,7 +184,7 @@ class Session:
try: try:
# LOCK_QUEUE # LOCK_QUEUE
sent=self._send(self.sendbuffer) # blocking socket sent=self._send(self.sendbuffer) # blocking socket
except: except Exception:
# UNLOCK_QUEUE # UNLOCK_QUEUE
self.set_socket_state(SOCKET_DEAD) self.set_socket_state(SOCKET_DEAD)
self.DEBUG("Socket error while sending data",'error') self.DEBUG("Socket error while sending data",'error')

View File

@ -146,7 +146,7 @@ class TCPsocket(PlugIn):
if raw_data.strip(): if raw_data.strip():
self.DEBUG(raw_data,'sent') self.DEBUG(raw_data,'sent')
self._owner.Dispatcher.Event('', DATA_SENT, raw_data) self._owner.Dispatcher.Event('', DATA_SENT, raw_data)
except: except Exception:
self.DEBUG("Socket error while sending data",'error') self.DEBUG("Socket error while sending data",'error')
self._owner.disconnected() self._owner.disconnected()

View File

@ -69,7 +69,7 @@ def torf(cond, tv, fv):
def gattr(obj, attr, default=None): def gattr(obj, attr, default=None):
try: try:
return getattr(obj, attr) return getattr(obj, attr)
except: except Exception:
return default return default
class SSLWrapper: class SSLWrapper:
@ -368,7 +368,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
self.remove_timeout() self.remove_timeout()
try: try:
self._owner.disconnected() self._owner.disconnected()
except: except Exception:
pass pass
self.idlequeue.unplug_idle(self.fd) self.idlequeue.unplug_idle(self.fd)
sock = getattr(self, '_sock', None) sock = getattr(self, '_sock', None)
@ -652,7 +652,7 @@ class NonBlockingTcp(PlugIn, IdleObject):
retval = None retval = None
try: try:
retval = gattr(self._owner, 'name') retval = gattr(self._owner, 'name')
except: except Exception:
pass pass
if retval: return retval if retval: return retval
return self.getHost() return self.getHost()
@ -768,7 +768,7 @@ class NonBlockingTLS(PlugIn):
cacerts = os.path.join(common.gajim.DATA_DIR, 'other', 'cacerts.pem') cacerts = os.path.join(common.gajim.DATA_DIR, 'other', 'cacerts.pem')
try: try:
tcpsock._sslContext.load_verify_locations(cacerts) tcpsock._sslContext.load_verify_locations(cacerts)
except: except Exception:
log.warning('Unable to load SSL certificats from file %s' % \ log.warning('Unable to load SSL certificats from file %s' % \
os.path.abspath(cacerts)) os.path.abspath(cacerts))
# load users certs # load users certs
@ -811,7 +811,7 @@ class NonBlockingTLS(PlugIn):
self.starttls='in progress' self.starttls='in progress'
tcpsock._sslObj.do_handshake() tcpsock._sslObj.do_handshake()
# Errors are handeled in _do_receive function # Errors are handeled in _do_receive function
except: except Exception:
pass pass
tcpsock._sslObj.setblocking(False) tcpsock._sslObj.setblocking(False)
log.debug("Synchronous handshake completed") log.debug("Synchronous handshake completed")
@ -843,7 +843,7 @@ class NonBlockingTLS(PlugIn):
self._owner.Connection.ssl_cert_pem = OpenSSL.crypto.dump_certificate( self._owner.Connection.ssl_cert_pem = OpenSSL.crypto.dump_certificate(
OpenSSL.crypto.FILETYPE_PEM, cert) OpenSSL.crypto.FILETYPE_PEM, cert)
return True return True
except: except Exception:
log.error("Exception caught in _ssl_info_callback:", exc_info=True) log.error("Exception caught in _ssl_info_callback:", exc_info=True)
traceback.print_exc() # Make sure something is printed, even if log is disabled. 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', '') self.reply = reply.replace('\r', '')
try: try:
proto, code, desc = reply.split('\n')[0].split(' ', 2) proto, code, desc = reply.split('\n')[0].split(' ', 2)
except: except Exception:
log.error("_on_headers_sent:", exc_info=True) log.error("_on_headers_sent:", exc_info=True)
#traceback.print_exc() #traceback.print_exc()
self.on_proxy_failure('Invalid proxy reply') self.on_proxy_failure('Invalid proxy reply')

View File

@ -45,7 +45,7 @@ AGENT_REMOVED = 'agent_removed'
HAS_IDLE = True HAS_IDLE = True
try: try:
import idle import idle
except: except Exception:
gajim.log.debug(_('Unable to load idle module')) gajim.log.debug(_('Unable to load idle module'))
HAS_IDLE = False HAS_IDLE = False
@ -226,7 +226,7 @@ class ConnectionBytestream(connection_handlers.ConnectionBytestream):
try: try:
streamhost = query.getTag('streamhost-used') 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 pass
id = real_id[3:] id = real_id[3:]
if id in self.files_props: if id in self.files_props:
@ -382,7 +382,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream, connecti
try: try:
idle.init() idle.init()
except: except Exception:
HAS_IDLE = False HAS_IDLE = False
def _messageCB(self, ip, con, msg): def _messageCB(self, ip, con, msg):
@ -429,7 +429,7 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream, connecti
try: try:
msg = session.decrypt_stanza(msg) msg = session.decrypt_stanza(msg)
except: except Exception:
self.dispatch('FAILED_DECRYPT', (frm, tim)) self.dispatch('FAILED_DECRYPT', (frm, tim))
msgtxt = msg.getBody() msgtxt = msg.getBody()

View File

@ -186,7 +186,7 @@ class Zeroconf:
#check if last part is a number and if, increment it #check if last part is a number and if, increment it
try: try:
stripped = str(int(parts[-1])) stripped = str(int(parts[-1]))
except: except Exception:
stripped = 1 stripped = 1
alternative_name = self.username + str(stripped+1) alternative_name = self.username + str(stripped+1)
self.name_conflictCB(alternative_name) self.name_conflictCB(alternative_name)

View File

@ -48,7 +48,7 @@ import dataforms_widget
try: try:
import gtkspell import gtkspell
HAS_GTK_SPELL = True HAS_GTK_SPELL = True
except: except Exception:
HAS_GTK_SPELL = False HAS_GTK_SPELL = False
from common import helpers from common import helpers
@ -618,7 +618,7 @@ class PreferencesWindow:
if isinstance(ctrl, chat_control.ChatControlBase): if isinstance(ctrl, chat_control.ChatControlBase):
try: try:
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
except: except Exception:
spell_obj = None spell_obj = None
if not spell_obj: if not spell_obj:
@ -630,7 +630,7 @@ class PreferencesWindow:
if isinstance(ctrl, chat_control.ChatControlBase): if isinstance(ctrl, chat_control.ChatControlBase):
try: try:
spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview) spell_obj = gtkspell.get_from_text_view(ctrl.msg_textview)
except: except Exception:
spell_obj = None spell_obj = None
if spell_obj: if spell_obj:
spell_obj.detach() spell_obj.detach()
@ -2014,7 +2014,7 @@ class AccountsWindow:
custom_port = widget.get_text() custom_port = widget.get_text()
try: try:
custom_port = int(custom_port) custom_port = int(custom_port)
except: except Exception:
if not widget.is_focus(): if not widget.is_focus():
dialogs.ErrorDialog(_('Invalid entry'), dialogs.ErrorDialog(_('Invalid entry'),
_('Custom port must be a port number.')) _('Custom port must be a port number.'))
@ -3160,7 +3160,7 @@ class AccountCreationWizardWindow:
custom_port = self.xml.get_widget('custom_port_entry').get_text() custom_port = self.xml.get_widget('custom_port_entry').get_text()
try: try:
custom_port = int(custom_port) custom_port = int(custom_port)
except: except Exception:
dialogs.ErrorDialog(_('Invalid entry'), dialogs.ErrorDialog(_('Invalid entry'),
_('Custom port must be a port number.')) _('Custom port must be a port number.'))
return return

View File

@ -45,7 +45,7 @@ from common import pep
try: try:
import gtkspell import gtkspell
HAS_GTK_SPELL = True HAS_GTK_SPELL = True
except: except Exception:
HAS_GTK_SPELL = False HAS_GTK_SPELL = False
# those imports are not used in this file, but in files that 'import dialogs' # 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') password = self._password_entry.get_text().decode('utf-8')
try: try:
nickname = helpers.parse_resource(nickname) nickname = helpers.parse_resource(nickname)
except: except Exception:
ErrorDialog(_('Invalid Nickname'), ErrorDialog(_('Invalid Nickname'),
_('The nickname has not allowed characters.')) _('The nickname has not allowed characters.'))
return return
@ -1764,7 +1764,7 @@ class JoinGroupchatWindow:
return return
try: try:
room_jid = helpers.parse_jid(room_jid) room_jid = helpers.parse_jid(room_jid)
except: except Exception:
ErrorDialog(_('Invalid group chat Jabber ID'), ErrorDialog(_('Invalid group chat Jabber ID'),
_('The group chat Jabber ID has not allowed characters.')) _('The group chat Jabber ID has not allowed characters.'))
return return
@ -3058,7 +3058,7 @@ class ImageChooserDialog(FileChooserDialog):
path = helpers.get_my_pictures_path() path = helpers.get_my_pictures_path()
else: else:
path = os.environ['HOME'] path = os.environ['HOME']
except: except Exception:
path = '' path = ''
FileChooserDialog.__init__(self, FileChooserDialog.__init__(self,
title_text = _('Choose Image'), title_text = _('Choose Image'),

View File

@ -1103,7 +1103,7 @@ class ToplevelAgentBrowser(AgentBrowser):
iter = None iter = None
try: try:
iter = self.model.get_iter(row) iter = self.model.get_iter(row)
except: except Exception:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
return return
jid = self.model[iter][0] jid = self.model[iter][0]
@ -1961,7 +1961,7 @@ class DiscussionGroupsBrowser(AgentBrowser):
have items on the list, we should actualize them. ''' have items on the list, we should actualize them. '''
try: try:
subscriptions = request.getTag('pubsub').getTag('subscriptions') subscriptions = request.getTag('pubsub').getTag('subscriptions')
except: except Exception:
return return
groups = set() groups = set()

View File

@ -164,17 +164,17 @@ class FeaturesWindow:
try: try:
import OpenSSL.SSL import OpenSSL.SSL
import OpenSSL.crypto import OpenSSL.crypto
except: except Exception:
return False return False
return True return True
def zeroconf_available(self): def zeroconf_available(self):
try: try:
import avahi import avahi
except: except Exception:
try: try:
import pybonjour import pybonjour
except: except Exception:
return False return False
return True return True
@ -201,7 +201,7 @@ class FeaturesWindow:
return False return False
try: try:
import gnome.ui import gnome.ui
except: except Exception:
return False return False
return True return True
@ -210,7 +210,7 @@ class FeaturesWindow:
return False return False
try: try:
import gnomekeyring import gnomekeyring
except: except Exception:
return False return False
return True return True
@ -222,7 +222,7 @@ class FeaturesWindow:
return False return False
try: try:
import gtkspell import gtkspell
except: except Exception:
return False return False
return True return True
@ -232,7 +232,7 @@ class FeaturesWindow:
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
try: try:
import osx.growler import osx.growler
except: except Exception:
return False return False
return True return True
from common import dbus_support from common import dbus_support
@ -240,7 +240,7 @@ class FeaturesWindow:
return True return True
try: try:
import pynotify import pynotify
except: except Exception:
return False return False
return True return True
@ -250,7 +250,7 @@ class FeaturesWindow:
return True return True
try: try:
import systray import systray
except: except Exception:
return False return False
return True return True
@ -280,14 +280,14 @@ class FeaturesWindow:
p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'], p = Popen(['latex', '--interaction=nonstopmode', tmpfile + '.tex'],
cwd=gettempdir()) cwd=gettempdir())
exitcode = p.wait() exitcode = p.wait()
except: except Exception:
exitcode = 1 exitcode = 1
if exitcode == 0: if exitcode == 0:
try: try:
p = Popen(['dvipng', '-bg', 'white', '-T', 'tight', p = Popen(['dvipng', '-bg', 'white', '-T', 'tight',
tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir()) tmpfile + '.dvi', '-o', tmpfile + '.png'], cwd=gettempdir())
exitcode = p.wait() exitcode = p.wait()
except: except Exception:
exitcode = 1 exitcode = 1
extensions = ['.tex', '.log', '.aux', '.dvi', '.png'] extensions = ['.tex', '.log', '.aux', '.dvi', '.png']
for ext in extensions: for ext in extensions:
@ -306,7 +306,7 @@ class FeaturesWindow:
def docutils_available(self): def docutils_available(self):
try: try:
import docutils import docutils
except: except Exception:
return False return False
return True return True

View File

@ -632,7 +632,7 @@ _('Connection with peer cannot be established.'))
iter = None iter = None
try: try:
iter = self.model.get_iter(row) iter = self.model.get_iter(row)
except: except Exception:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
return return
sid = self.model[iter][C_SID].decode('utf-8') sid = self.model[iter][C_SID].decode('utf-8')

View File

@ -38,7 +38,7 @@ from common import i18n
try: try:
PREFERRED_ENCODING = locale.getpreferredencoding() PREFERRED_ENCODING = locale.getpreferredencoding()
except: except Exception:
PREFERRED_ENCODING = 'UTF-8' PREFERRED_ENCODING = 'UTF-8'
def send_error(error_message): def send_error(error_message):
@ -53,7 +53,7 @@ try:
import dbus import dbus
import dbus.service import dbus.service
import dbus.glib import dbus.glib
except: except Exception:
print str(exceptions.DbusNotSupported()) print str(exceptions.DbusNotSupported())
sys.exit(1) sys.exit(1)
@ -358,7 +358,7 @@ class GajimRemote:
if not self.sbus: if not self.sbus:
try: try:
self.sbus = dbus.SessionBus() self.sbus = dbus.SessionBus()
except: except Exception:
raise exceptions.SessionBusNotPresent raise exceptions.SessionBusNotPresent
test = False test = False
@ -375,7 +375,7 @@ class GajimRemote:
or exit if it is not possible ''' or exit if it is not possible '''
try: try:
self.sbus = dbus.SessionBus() self.sbus = dbus.SessionBus()
except: except Exception:
raise exceptions.SessionBusNotPresent raise exceptions.SessionBusNotPresent
if not self.check_gajim_running(): if not self.check_gajim_running():
@ -484,7 +484,7 @@ class GajimRemote:
if (encode_return): if (encode_return):
try: try:
ret_str = ret_str.encode(PREFERRED_ENCODING) ret_str = ret_str.encode(PREFERRED_ENCODING)
except: except Exception:
pass pass
return ret_str return ret_str

View File

@ -179,7 +179,7 @@ else:
import dl import dl
libc = dl.open('/lib/libc.so.6') libc = dl.open('/lib/libc.so.6')
libc.call('prctl', 15, 'gajim\0', 0, 0, 0) libc.call('prctl', 15, 'gajim\0', 0, 0, 0)
except: except Exception:
pass pass
if gtk.pygtk_version < (2, 8, 0): if gtk.pygtk_version < (2, 8, 0):
@ -208,7 +208,7 @@ else:
try: try:
import winsound # windows-only built-in module for playing wav import winsound # windows-only built-in module for playing wav
import win32api # do NOT remove. we req this module import win32api # do NOT remove. we req this module
except: except Exception:
pritext = _('Gajim needs pywin32 to run') 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' 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: try:
pid = int(pf.read().strip()) pid = int(pf.read().strip())
pf.close() pf.close()
except: except Exception:
traceback.print_exc() traceback.print_exc()
# PID file exists, but something happened trying to read PID # PID file exists, but something happened trying to read PID
# Could be 0.10 style empty PID file, so assume Gajim is running # Could be 0.10 style empty PID file, so assume Gajim is running
@ -290,7 +290,7 @@ def pid_alive():
if os.name == 'nt': if os.name == 'nt':
try: try:
from ctypes import (windll, c_ulong, c_int, Structure, c_char, POINTER, pointer, ) from ctypes import (windll, c_ulong, c_int, Structure, c_char, POINTER, pointer, )
except: except Exception:
return True return True
class PROCESSENTRY32(Structure): class PROCESSENTRY32(Structure):
@ -352,7 +352,7 @@ def pid_alive():
if n.find('gajim') < 0: if n.find('gajim') < 0:
return False return False
return True # Running Gajim found at pid return True # Running Gajim found at pid
except: except Exception:
traceback.print_exc() traceback.print_exc()
# If we are here, pidfile exists, but some unexpected error occured. # 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): def _process_events(self, fd, flags):
try: try:
return self.process_events(fd, flags) return self.process_events(fd, flags)
except: except Exception:
self.remove_idle(fd) self.remove_idle(fd)
self.add_idle(fd, flags) self.add_idle(fd, flags)
raise raise
@ -2357,7 +2357,7 @@ class Interface:
img = gtk.Image() img = gtk.Image()
try: try:
img.set_from_file(image) img.set_from_file(image)
except: except Exception:
return False return False
t = img.get_storage_type() t = img.get_storage_type()
if t != gtk.IMAGE_PIXBUF and t != gtk.IMAGE_ANIMATION: if t != gtk.IMAGE_PIXBUF and t != gtk.IMAGE_ANIMATION:
@ -2566,7 +2566,7 @@ class Interface:
fd.close() fd.close()
del emoticons del emoticons
self._init_emoticons(path, need_reload=True) self._init_emoticons(path, need_reload=True)
except: except Exception:
pass pass
if len(self.emoticons) == 0: if len(self.emoticons) == 0:
dialogs.WarningDialog(_('Emoticons disabled'), dialogs.WarningDialog(_('Emoticons disabled'),
@ -2860,7 +2860,7 @@ class Interface:
''' '''
try: try:
gajim.idlequeue.process() gajim.idlequeue.process()
except: except Exception:
# Otherwise, an exception will stop our loop # Otherwise, an exception will stop our loop
if gajim.idlequeue.__class__ == GlibIdleQueue: if gajim.idlequeue.__class__ == GlibIdleQueue:
gobject.timeout_add_seconds(2, self.process_connections) gobject.timeout_add_seconds(2, self.process_connections)
@ -3074,7 +3074,7 @@ class Interface:
'/apps/nautilus/preferences/click_policy') '/apps/nautilus/preferences/click_policy')
if click_policy == 'single': if click_policy == 'single':
gajim.single_click = True gajim.single_click = True
except: except Exception:
pass pass
# add default status messages if there is not in the config file # add default status messages if there is not in the config file
if len(gajim.config.get_per('statusmsg')) == 0: if len(gajim.config.get_per('statusmsg')) == 0:
@ -3167,7 +3167,7 @@ class Interface:
try: try:
import remote_control import remote_control
self.remote_ctrl = remote_control.Remote() self.remote_ctrl = remote_control.Remote()
except: except Exception:
self.remote_ctrl = None self.remote_ctrl = None
else: else:
self.remote_ctrl = None self.remote_ctrl = None
@ -3205,7 +3205,7 @@ class Interface:
bus = dbus.SessionBus() bus = dbus.SessionBus()
bus.add_signal_receiver(gnome_screensaver_ActiveChanged_cb, bus.add_signal_receiver(gnome_screensaver_ActiveChanged_cb,
'ActiveChanged', 'org.gnome.ScreenSaver') 'ActiveChanged', 'org.gnome.ScreenSaver')
except: except Exception:
pass pass
self.show_vcard_when_connect = [] self.show_vcard_when_connect = []
@ -3261,7 +3261,7 @@ class Interface:
try: try:
import gtkspell import gtkspell
spell = gtkspell.Spell(tv, lang) spell = gtkspell.Spell(tv, lang)
except: except Exception:
dialogs.AspellDictError(lang) dialogs.AspellDictError(lang)
if gajim.config.get('soundplayer') == '': if gajim.config.get('soundplayer') == '':

View File

@ -1426,7 +1426,7 @@ class GroupchatControl(ChatControlBase):
nick = message_array[0] nick = message_array[0]
try: try:
nick = helpers.parse_resource(nick) nick = helpers.parse_resource(nick)
except: except Exception:
# Invalid Nickname # Invalid Nickname
dialogs.ErrorDialog(_('Invalid nickname'), dialogs.ErrorDialog(_('Invalid nickname'),
_('The nickname has not allowed characters.')) _('The nickname has not allowed characters.'))
@ -1707,7 +1707,7 @@ class GroupchatControl(ChatControlBase):
self.change_nick_dialog = None self.change_nick_dialog = None
try: try:
nick = helpers.parse_resource(nick) nick = helpers.parse_resource(nick)
except: except Exception:
# invalid char # invalid char
dialogs.ErrorDialog(_('Invalid nickname'), dialogs.ErrorDialog(_('Invalid nickname'),
_('The nickname has not allowed characters.')) _('The nickname has not allowed characters.'))
@ -1876,7 +1876,7 @@ class GroupchatControl(ChatControlBase):
# Test jid # Test jid
try: try:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except: except Exception:
dialogs.ErrorDialog(_('Invalid group chat Jabber ID'), dialogs.ErrorDialog(_('Invalid group chat Jabber ID'),
_('The group chat Jabber ID has not allowed characters.')) _('The group chat Jabber ID has not allowed characters.'))
return return
@ -2297,7 +2297,7 @@ class GroupchatControl(ChatControlBase):
iter = None iter = None
try: try:
iter = model.get_iter(row) iter = model.get_iter(row)
except: except Exception:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
return return
typ = model[iter][C_TYPE].decode('utf-8') typ = model[iter][C_TYPE].decode('utf-8')

View File

@ -141,7 +141,7 @@ def get_default_font():
return client.get_string('/desktop/gnome/interface/font_name' return client.get_string('/desktop/gnome/interface/font_name'
).decode('utf-8') ).decode('utf-8')
except: except Exception:
pass pass
# try to get xfce default font # try to get xfce default font
@ -161,7 +161,7 @@ def get_default_font():
if line.find('name="Gtk/FontName"') != -1: if line.find('name="Gtk/FontName"') != -1:
start = line.find('value="') + 7 start = line.find('value="') + 7
return line[start:line.find('"', start)].decode('utf-8') return line[start:line.find('"', start)].decode('utf-8')
except: except Exception:
#we talk about file #we talk about file
print >> sys.stderr, _('Error: cannot open %s for reading') % xfce_config_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_size = values[1]
font_string = '%s %s' % (font_name, font_size) # Verdana 9 font_string = '%s %s' % (font_name, font_size) # Verdana 9
return font_string.decode('utf-8') return font_string.decode('utf-8')
except: except Exception:
#we talk about file #we talk about file
print >> sys.stderr, _('Error: cannot open %s for reading') % kde_config_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: for file_path in file_paths:
try: try:
file_path = file_path.decode(sys.getfilesystemencoding()) file_path = file_path.decode(sys.getfilesystemencoding())
except: except Exception:
try: try:
file_path = file_path.decode('utf-8') file_path = file_path.decode('utf-8')
except: except Exception:
pass pass
file_paths_list.append(file_path) file_paths_list.append(file_path)
@ -713,7 +713,7 @@ Description=xmpp
import gconf import gconf
# in try because daemon may not be there # in try because daemon may not be there
client = gconf.client_get_default() client = gconf.client_get_default()
except: except Exception:
return return
old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command') old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command')

View File

@ -222,7 +222,7 @@ def build_patterns(view, config, interface):
'(?:(?<![\w.]' + emoticons_pattern_prematch[:-1] + '))' + \ '(?:(?<![\w.]' + emoticons_pattern_prematch[:-1] + '))' + \
'(?:' + emoticons_pattern[:-1] + ')' + \ '(?:' + emoticons_pattern[:-1] + ')' + \
'(?:(?![\w.]' + emoticons_pattern_postmatch[:-1] + '))' '(?:(?![\w.]' + emoticons_pattern_postmatch[:-1] + '))'
except: except Exception:
pass pass
view.emot_pattern_re = re.compile(emoticons_pattern, re.IGNORECASE) view.emot_pattern_re = re.compile(emoticons_pattern, re.IGNORECASE)
@ -377,7 +377,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
# validate length # validate length
val = sign*max(minl,min(abs(val),maxl)) val = sign*max(minl,min(abs(val),maxl))
callback(val, *args) callback(val, *args)
except: except Exception:
warnings.warn('Unable to parse length value "%s"' % value) warnings.warn('Unable to parse length value "%s"' % value)
def __parse_font_size_cb(length, tag): 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): def __length_tag_cb(self, value, tag, propname):
try: try:
tag.set_property(propname, value) tag.set_property(propname, value)
except: except Exception:
gajim.log.warn( "Error with prop: " + propname + " for tag: " + str(tag)) 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 # Wait 0.1s between each byte
try: try:
f.fp._sock.fp._sock.settimeout(0.5) f.fp._sock.fp._sock.settimeout(0.5)
except: except Exception:
pass pass
# Max image size = 2 MB (to try to prevent DoS) # Max image size = 2 MB (to try to prevent DoS)
mem = '' mem = ''
@ -675,7 +675,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
alt = attrs.get('alt', 'Broken image') alt = attrs.get('alt', 'Broken image')
try: try:
loader.close() loader.close()
except: except Exception:
pass pass
return pixbuf return pixbuf

View File

@ -75,7 +75,7 @@ class LastFM:
xmldocument = urlopen(self.LASTFM_FORMAT_URL % self._username, xmldocument = urlopen(self.LASTFM_FORMAT_URL % self._username,
self._proxies) self._proxies)
xmltree = minidom.parse(xmldocument) xmltree = minidom.parse(xmldocument)
except: except Exception:
print 'Error parsing XML from Last.fm...' print 'Error parsing XML from Last.fm...'
return False return False

View File

@ -636,7 +636,7 @@ class MessageWindow(object):
jid = key jid = key
try: try:
return self._controls[acct][jid] return self._controls[acct][jid]
except: except Exception:
return None return None
else: else:
page_num = key page_num = key

View File

@ -59,7 +59,7 @@ else:
'org.freedesktop.NetworkManager', 'org.freedesktop.NetworkManager',
'org.freedesktop.NetworkManager', 'org.freedesktop.NetworkManager',
'/org/freedesktop/NetworkManager') '/org/freedesktop/NetworkManager')
except: except Exception:
pass pass
# vim: se ts=3: # vim: se ts=3:

View File

@ -54,7 +54,7 @@ USER_HAS_GROWL = True
try: try:
import osx.growler import osx.growler
osx.growler.init() osx.growler.init()
except: except Exception:
USER_HAS_GROWL = False USER_HAS_GROWL = False
def get_show_in_roster(event, account, contact, session=None): 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') 'command')
try: try:
helpers.exec_command(command) helpers.exec_command(command)
except: except Exception:
pass pass
def popup(event_type, jid, account, msg_type='', path_to_image=None, def popup(event_type, jid, account, msg_type='', path_to_image=None,

View File

@ -21,13 +21,13 @@ def readEnv():
gajimpaths.add_from_root(u'dbus.env', u'dbus.env') gajimpaths.add_from_root(u'dbus.env', u'dbus.env')
try: try:
dbus_env = file(gajimpaths[u'dbus.env'], "r") dbus_env = file(gajimpaths[u'dbus.env'], "r")
except: except Exception:
return False return False
try: try:
line1 = dbus_env.readline() line1 = dbus_env.readline()
line2 = dbus_env.readline() line2 = dbus_env.readline()
dbus_env.close() dbus_env.close()
except: except Exception:
print "Invalid dbus.env file" print "Invalid dbus.env file"
return False return False
return parseEnv(line1, line2) return parseEnv(line1, line2)

View File

@ -12,7 +12,7 @@ __contributors__ = ["Ingmar J Stein (Growl Team)",
try: try:
import _growl import _growl
except: except Exception:
_growl = False _growl = False
import types import types
import struct import struct

View File

@ -332,7 +332,7 @@ class SignalObject(dbus.service.Object):
jid = self._get_real_jid(jid, account) jid = self._get_real_jid(jid, account)
try: try:
jid = helpers.parse_jid(jid) jid = helpers.parse_jid(jid)
except: except Exception:
# Jid is not conform, ignore it # Jid is not conform, ignore it
return DBUS_BOOLEAN(False) return DBUS_BOOLEAN(False)

View File

@ -1702,7 +1702,7 @@ class RosterWindow:
if not 'com.google.code.Awn' in bus.list_names(): if not 'com.google.code.Awn' in bus.list_names():
# Awn is not installed # Awn is not installed
return return
except: except Exception:
return return
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
prefix = os.path.join(helpers.get_iconset_path(iconset), '32x32') prefix = os.path.join(helpers.get_iconset_path(iconset), '32x32')
@ -2379,7 +2379,7 @@ class RosterWindow:
titer = None titer = None
try: try:
titer = model.get_iter(row) titer = model.get_iter(row)
except: except Exception:
self.tooltip.hide_tooltip() self.tooltip.hide_tooltip()
return return
if model[titer][C_TYPE] in ('contact', 'self_contact'): if model[titer][C_TYPE] in ('contact', 'self_contact'):

View File

@ -43,10 +43,10 @@ HAS_SYSTRAY_CAPABILITIES = True
try: try:
import egg.trayicon as trayicon # gnomepythonextras trayicon import egg.trayicon as trayicon # gnomepythonextras trayicon
except: except Exception:
try: try:
import trayicon # our trayicon import trayicon # our trayicon
except: except Exception:
gajim.log.debug('No trayicon module available') gajim.log.debug('No trayicon module available')
HAS_SYSTRAY_CAPABILITIES = False HAS_SYSTRAY_CAPABILITIES = False

View File

@ -58,7 +58,7 @@ def get_avatar_pixbuf_encoded_mime(photo):
avatar_encoded = img_encoded avatar_encoded = img_encoded
try: try:
img_decoded = base64.decodestring(img_encoded) img_decoded = base64.decodestring(img_encoded)
except: except Exception:
pass pass
if img_decoded: if img_decoded:
if 'TYPE' in photo: if 'TYPE' in photo:

View File

@ -23,7 +23,7 @@ for o, a in opts:
elif o in ('-v', '--verbose'): elif o in ('-v', '--verbose'):
try: try:
verbose = int(a) verbose = int(a)
except: except Exception:
print 'verbose must be a number >= 0' print 'verbose must be a number >= 0'
sys.exit(2) sys.exit(2)