[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):
try:
func()
except:
except Exception:
pass
return

View File

@ -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'

View File

@ -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,

View File

@ -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')

View File

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

View File

@ -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

View File

@ -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':

View File

@ -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)

View File

@ -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]

View File

@ -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

View File

@ -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')

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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():

View File

@ -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 :

View File

@ -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:

View File

@ -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):

View File

@ -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)

View File

@ -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!' )

View File

@ -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')

View File

@ -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()

View File

@ -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')

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -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'),

View File

@ -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()

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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') == '':

View File

@ -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')

View File

@ -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')

View File

@ -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

View File

@ -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

View File

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

View File

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

View File

@ -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,

View File

@ -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)

View File

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

View File

@ -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)

View File

@ -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'):

View File

@ -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

View File

@ -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:

View File

@ -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)