Commit 567f1e17 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

[thorstenp] di not use emtpy except clauses

parent 84e717c8
......@@ -82,7 +82,7 @@ def check(ret):
def force(func):
try:
func()
except:
except Exception:
pass
return
......
......@@ -56,7 +56,7 @@
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 @@ def __init__(self, type_id, parent_win, widget_name, contact, acct,
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'
......
......@@ -107,7 +107,7 @@ def get_feed_link(self):
''' 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,
......
......@@ -121,7 +121,7 @@ def changestatus(self, request):
try:
form = dataforms.SimpleDataForm(extend = request.getTag('command').\
getTag('x'))
except:
except Exception:
self.badRequest(request)
return False
......@@ -131,14 +131,14 @@ def changestatus(self, request):
('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 @@ def leavegroupchats(self, request):
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 @@ def leavegroupchats(self, request):
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')
......
......@@ -481,7 +481,7 @@ def foreach(self, cb, data = None):
def is_valid_int(self, val):
try:
ival = int(val)
except:
except Exception:
return None
return ival
......
......@@ -41,7 +41,7 @@
try:
randomsource = random.SystemRandom()
except:
except Exception:
randomsource = random.Random()
randomsource.seed()
......@@ -447,7 +447,7 @@ def connect(self, data = None):
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 @@ def connect(self, data = None):
else:
proxy['password'] = u''
except:
except Exception:
proxy = None
else:
proxy = None
......
......@@ -67,7 +67,7 @@
HAS_IDLE = True
try:
import idle
except:
except Exception:
gajim.log.debug(_('Unable to load idle module'))
HAS_IDLE = False
......@@ -461,7 +461,7 @@ def _bytestreamResultCB(self, con, iq_obj):
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 @@ def get_cached_vcard(self, fjid, is_fake_jid = False):
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 @@ def _IqCB(self, con, iq_obj):
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 @@ def _vCardCB(self, con, vc):
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 @@ def __init__(self):
try:
idle.init()
except:
except Exception:
HAS_IDLE = False
self.gmail_last_tid = None
......@@ -1532,7 +1532,7 @@ def _LastResultCB(self, con, iq_obj):
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 @@ def _messageCB(self, con, msg):
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 @@ def _presenceCB(self, con, prs):
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 @@ def _presenceCB(self, con, prs):
prio = prs.getPriority()
try:
prio = int(prio)
except:
except Exception:
prio = 0
keyID = ''
if sigTag and self.USE_GPG and ptype != 'error':
......
......@@ -69,7 +69,7 @@
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 @@ def get_windows_reg_env(varname, default=''):
try:
val = str(win32api.RegQueryValueEx(rkey, varname)[0])
val = win32api.ExpandEnvironmentStrings(val) # expand using environ
except:
except Exception:
pass
finally:
win32api.RegCloseKey(rkey)
......
......@@ -369,7 +369,7 @@ def get_unread_msgs(self):
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]
......
......@@ -257,7 +257,7 @@ def end(self):
self.idlequeue.unplug_idle(self.fd)
try:
self.pipe.close()
except:
except Exception:
pass
def pollend(self):
......@@ -337,7 +337,7 @@ def on_result(host, result_array):
def process():
try:
idlequeue.process()
except:
except Exception:
# Otherwise, an exception will stop our loop
gobject.timeout_add(200, process)
raise
......
......@@ -67,7 +67,7 @@ def read_line(self, line):
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 @@ def write(self):
# win32 needs this
try:
os.remove(self.__filename)
except:
except Exception:
pass
try:
os.rename(self.__tempfile, self.__filename)
......@@ -360,7 +360,7 @@ def update_config_to_01014(self):
)
con.commit()
except:
except Exception:
pass
con.close()
gajim.config.set('version', '0.10.1.4')
......
......@@ -116,7 +116,7 @@ def _PubSubCB(self, conn, stanza):
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):
......
......@@ -48,7 +48,7 @@ class LASTINPUTINFO(ctypes.Structure):
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 @@ def __init__(self, away_interval = 60, xa_interval = 120):
self.state = STATE_AWAKE # assume we are awake
try:
idle.init()
except:
except Exception:
SUPPORTED = False
self.state = STATE_UNKNOWN
......
......@@ -382,7 +382,7 @@ def close_file(self):
if not self.file.closed:
try:
self.file.close()
except:
except Exception:
pass
self.file = None
......@@ -410,7 +410,7 @@ def rem_fd(self, fd):
del(self.file_props['fd'])
try:
fd.close()
except:
except Exception:
pass
......@@ -559,7 +559,7 @@ def disconnect(self):
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 @@ def _parse_auth_buff(self, buff):
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 @@ def _parse_request_buff(self, buff):
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 @@ def read_connect(self):
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 @@ def bind(self):
self._serv.bind(ai[4])
self.ai = ai
break
except:
except Exception:
self.ai = None
continue
if not self.ai:
......@@ -844,7 +844,7 @@ def disconnect(self):
self.started = False
try:
self._serv.close()
except:
except Exception:
pass
def accept_conn(self):
......@@ -903,7 +903,7 @@ def connect(self):
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
......
......@@ -339,7 +339,7 @@ def decrypt_stanza(self, stanza):
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():
......
......@@ -174,7 +174,7 @@ def SASLHandler(self, conn, challenge):
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 :
......
......@@ -318,7 +318,7 @@ def auth(self,name,password,dup=None,sasl=0):
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
......@@ -378,7 +378,7 @@ def auth(self, name, password, dup=None, sasl=0):
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):
......
......@@ -75,7 +75,7 @@ def _CommandHandler(self,conn,request):
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 @@ def Execute(self,conn,request):
# 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 @@ def cmdFirstStage(self,conn,request):
# 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 @@ def cmdThirdStage(self,conn,request):
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)
......
......@@ -173,7 +173,7 @@ def __init__( self,
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 @@ def __init__( self,
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 @@ def show( self, msg, flag = None, prefix = None, sufix = None,
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 @@ def active_set( self, active_flags = None ):
# 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!' )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment