[thorstenp] fix empty exception clauses
This commit is contained in:
parent
f0dce41ab6
commit
3392c54dd0
|
@ -2333,7 +2333,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
for jid in raw_roster:
|
||||
try:
|
||||
j = helpers.parse_jid(jid)
|
||||
except:
|
||||
except Exception:
|
||||
print >> sys.stderr, _('JID %s is not RFC compliant. It will not be added to your roster. Use roster management tools such as http://jru.jabberstudio.org/ to remove it') % jid
|
||||
else:
|
||||
infos = raw_roster[jid]
|
||||
|
|
|
@ -27,7 +27,7 @@ try:
|
|||
from docutils.parsers.rst import roles
|
||||
from docutils import nodes,utils
|
||||
from docutils.parsers.rst.roles import set_classes
|
||||
except:
|
||||
except ImportError:
|
||||
print "Requires docutils 0.4 for set_classes to be available"
|
||||
def create_xhtml(text):
|
||||
return None
|
||||
|
|
|
@ -161,8 +161,10 @@ class SASL(PlugIn):
|
|||
if challenge.getNamespace()!=NS_SASL: return
|
||||
if challenge.getName()=='failure':
|
||||
self.startsasl='failure'
|
||||
try: reason=challenge.getChildren()[0]
|
||||
except: reason=challenge
|
||||
try:
|
||||
reason=challenge.getChildren()[0]
|
||||
except Exception:
|
||||
reason=challenge
|
||||
self.DEBUG('Failed SASL authentification: %s'%reason,'error')
|
||||
raise NodeProcessed
|
||||
elif challenge.getName()=='success':
|
||||
|
|
|
@ -149,7 +149,8 @@ def getPrivacyLists(disp):
|
|||
if list_.getName()=='list': dict_['lists'].append(list_.getAttr('name'))
|
||||
else: dict_[list_.getName()]=list_.getAttr('name')
|
||||
return dict_
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def getPrivacyList(disp,listname):
|
||||
""" Requests specific privacy list listname. Returns list of XML nodes (rules)
|
||||
|
@ -157,7 +158,8 @@ def getPrivacyList(disp,listname):
|
|||
try:
|
||||
resp=disp.SendAndWaitForResponse(Iq('get',NS_PRIVACY,payload=[Node('list',{'name':listname})]))
|
||||
if isResultNode(resp): return resp.getQueryPayload()[0]
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def setActivePrivacyList(disp,listname=None,typ='active'):
|
||||
""" Switches privacy list 'listname' to specified type.
|
||||
|
|
|
@ -69,8 +69,10 @@ class IBB(PlugIn):
|
|||
err=None
|
||||
sid,blocksize=stanza.getTagAttr('open','sid'),stanza.getTagAttr('open','block-size')
|
||||
self.DEBUG('StreamOpenHandler called sid->%s blocksize->%s'%(sid,blocksize),'info')
|
||||
try: blocksize=int(blocksize)
|
||||
except: err=ERR_BAD_REQUEST
|
||||
try:
|
||||
blocksize=int(blocksize)
|
||||
except Exception:
|
||||
err=ERR_BAD_REQUEST
|
||||
if not sid or not blocksize: err=ERR_BAD_REQUEST
|
||||
elif sid in self._streams.keys(): err=ERR_UNEXPECTED_REQUEST
|
||||
if err: rep=Error(stanza,err)
|
||||
|
@ -137,8 +139,12 @@ class IBB(PlugIn):
|
|||
"""
|
||||
sid,seq,data=stanza.getTagAttr('data','sid'),stanza.getTagAttr('data','seq'),stanza.getTagData('data')
|
||||
self.DEBUG('ReceiveHandler called sid->%s seq->%s'%(sid,seq),'info')
|
||||
try: seq=int(seq); data=base64.decodestring(data)
|
||||
except: seq=''; data=''
|
||||
try:
|
||||
seq=int(seq)
|
||||
data=base64.decodestring(data)
|
||||
except Exception:
|
||||
seq=''
|
||||
data=''
|
||||
err=None
|
||||
if not sid in self._streams.keys(): err=ERR_ITEM_NOT_FOUND
|
||||
else:
|
||||
|
|
|
@ -326,22 +326,30 @@ class Protocol(Node):
|
|||
self.timestamp=None
|
||||
for d in self.getTags('delay',namespace=NS_DELAY2):
|
||||
try:
|
||||
if d.getAttr('stamp')<self.getTimestamp2(): self.setTimestamp(d.getAttr('stamp'))
|
||||
except: pass
|
||||
if d.getAttr('stamp') < self.getTimestamp2():
|
||||
self.setTimestamp(d.getAttr('stamp'))
|
||||
except Exception:
|
||||
pass
|
||||
if not self.timestamp:
|
||||
for x in self.getTags('x',namespace=NS_DELAY):
|
||||
try:
|
||||
if x.getAttr('stamp')<self.getTimestamp(): self.setTimestamp(x.getAttr('stamp'))
|
||||
except: pass
|
||||
if x.getAttr('stamp') < self.getTimestamp():
|
||||
self.setTimestamp(x.getAttr('stamp'))
|
||||
except Exception:
|
||||
pass
|
||||
if timestamp is not None: self.setTimestamp(timestamp) # To auto-timestamp stanza just pass timestamp=''
|
||||
def getTo(self):
|
||||
""" Return value of the 'to' attribute. """
|
||||
try: return self['to']
|
||||
except: return None
|
||||
try:
|
||||
return self['to']
|
||||
except KeyError:
|
||||
return None
|
||||
def getFrom(self):
|
||||
""" Return value of the 'from' attribute. """
|
||||
try: return self['from']
|
||||
except: return None
|
||||
try:
|
||||
return self['from']
|
||||
except KeyError:
|
||||
return None
|
||||
def getTimestamp(self):
|
||||
""" Return the timestamp in the 'yyyymmddThhmmss' format. """
|
||||
if self.timestamp: return self.timestamp
|
||||
|
|
|
@ -127,8 +127,10 @@ class Session:
|
|||
""" Reads all pending incoming data.
|
||||
Raises IOError on disconnection.
|
||||
Blocks until at least one byte is read."""
|
||||
try: received = self._recv(10240)
|
||||
except: received = ''
|
||||
try:
|
||||
received = self._recv(10240)
|
||||
except socket.error:
|
||||
received = ''
|
||||
|
||||
if len(received): # length of 0 means disconnect
|
||||
self.DEBUG(repr(self.fileno())+' '+received,'got')
|
||||
|
|
|
@ -168,8 +168,7 @@ class Node(object):
|
|||
return self.attrs
|
||||
def getAttr(self, key):
|
||||
""" Returns value of specified attribute. """
|
||||
try: return self.attrs[key]
|
||||
except: return None
|
||||
return self.attrs.get(key)
|
||||
def getChildren(self):
|
||||
""" Returns all node's child nodes as list. """
|
||||
return self.kids
|
||||
|
@ -203,12 +202,16 @@ class Node(object):
|
|||
return self.getTags(name, attrs, namespace, one=1)
|
||||
def getTagAttr(self,tag,attr):
|
||||
""" Returns attribute value of the child with specified name (or None if no such attribute)."""
|
||||
try: return self.getTag(tag).attrs[attr]
|
||||
except: return None
|
||||
try:
|
||||
return self.getTag(tag).attrs[attr]
|
||||
except:
|
||||
return None
|
||||
def getTagData(self,tag):
|
||||
""" Returns cocatenated CDATA of the child with specified name."""
|
||||
try: return self.getTag(tag).getData()
|
||||
except: return None
|
||||
try:
|
||||
return self.getTag(tag).getData()
|
||||
except Exception:
|
||||
return None
|
||||
def getTags(self, name, attrs={}, namespace=None, one=0):
|
||||
""" Filters all child nodes using specified arguments as filter.
|
||||
Returns the list of nodes found. """
|
||||
|
@ -264,13 +267,17 @@ class Node(object):
|
|||
def setTagAttr(self,tag,attr,val):
|
||||
""" Creates new node (if not already present) with name "tag"
|
||||
and sets it's attribute "attr" to value "val". """
|
||||
try: self.getTag(tag).attrs[attr]=val
|
||||
except: self.addChild(tag,attrs={attr:val})
|
||||
try:
|
||||
self.getTag(tag).attrs[attr]=val
|
||||
except Exception:
|
||||
self.addChild(tag,attrs={attr:val})
|
||||
def setTagData(self,tag,val,attrs={}):
|
||||
""" Creates new node (if not already present) with name "tag" and (optionally) attributes "attrs"
|
||||
and sets it's CDATA to string "val". """
|
||||
try: self.getTag(tag,attrs).setData(ustr(val))
|
||||
except: self.addChild(tag,attrs,payload=[ustr(val)])
|
||||
try:
|
||||
self.getTag(tag,attrs).setData(ustr(val))
|
||||
except Exception:
|
||||
self.addChild(tag,attrs,payload=[ustr(val)])
|
||||
def has_attr(self,key):
|
||||
""" Checks if node have attribute "key"."""
|
||||
return key in self.attrs
|
||||
|
|
|
@ -100,8 +100,10 @@ class TCPsocket(PlugIn):
|
|||
self._recv=self._sock.recv
|
||||
self.DEBUG("Successfully connected to remote host %s"%repr(server),'start')
|
||||
return 'ok'
|
||||
except: continue
|
||||
except: pass
|
||||
except Exception:
|
||||
continue
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def plugout(self):
|
||||
""" Disconnect from the remote server and unregister self.disconnected method from
|
||||
|
@ -112,12 +114,16 @@ class TCPsocket(PlugIn):
|
|||
|
||||
def receive(self):
|
||||
""" Reads all pending incoming data. Calls owner's disconnected() method if appropriate."""
|
||||
try: received = self._recv(1024000)
|
||||
except: received = ''
|
||||
try:
|
||||
received = self._recv(1024000)
|
||||
except socket.error:
|
||||
received = ''
|
||||
|
||||
while temp_failure_retry(select.select,[self._sock],[],[],0)[0]:
|
||||
try: add = self._recv(1024000)
|
||||
except: add=''
|
||||
try:
|
||||
add = self._recv(1024000)
|
||||
except socket.error:
|
||||
add=''
|
||||
received +=add
|
||||
if not add: break
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ class SSLWrapper:
|
|||
if self.exc_args[0] > 0:
|
||||
errno = self.exc_args[0]
|
||||
strerror = self.exc_args[1]
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.parent.__init__(self, errno, strerror)
|
||||
|
||||
|
@ -112,7 +113,8 @@ class SSLWrapper:
|
|||
if len(ppeer) == 2 and isinstance(ppeer[0], basestring) \
|
||||
and isinstance(ppeer[1], int):
|
||||
self.peer = ppeer
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def __str__(self):
|
||||
s = str(self.__class__)
|
||||
|
@ -356,8 +358,10 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
|||
def pollend(self, retry=False):
|
||||
if not self.printed_error:
|
||||
self.printed_error = True
|
||||
try: self._do_receive(errors_only=True)
|
||||
except: log.error("pollend: Got exception from _do_receive:", exc_info=True)
|
||||
try:
|
||||
self._do_receive(errors_only=True)
|
||||
except Exception:
|
||||
log.error("pollend: Got exception from _do_receive:", exc_info=True)
|
||||
conn_failure_cb = self.on_connect_failure
|
||||
self.disconnect()
|
||||
if conn_failure_cb:
|
||||
|
@ -381,8 +385,10 @@ class NonBlockingTcp(PlugIn, IdleObject):
|
|||
except socket.error, e:
|
||||
if e[0] != errno.ENOTCONN:
|
||||
log.error("Error shutting down socket for %s:", self.getName(), exc_info=True)
|
||||
try: sock.close()
|
||||
except: log.error("Error closing socket for %s:", self.getName(), exc_info=True)
|
||||
try:
|
||||
sock.close()
|
||||
except Exception:
|
||||
log.error("Error closing socket for %s:", self.getName(), exc_info=True)
|
||||
# socket descriptor cannot be (un)plugged anymore
|
||||
self.fd = -1
|
||||
if self.on_disconnect:
|
||||
|
|
|
@ -105,7 +105,7 @@ class ZeroconfListener(IdleObject):
|
|||
self.started = False
|
||||
try:
|
||||
self._serv.close()
|
||||
except:
|
||||
except socket.error:
|
||||
pass
|
||||
self.conn_holder.kill_all_connections()
|
||||
|
||||
|
@ -343,7 +343,7 @@ class P2PConnection(IdleObject, PlugIn):
|
|||
self._sock = socket.socket(*ai[:3])
|
||||
self._sock.setblocking(False)
|
||||
self._server = ai[4]
|
||||
except:
|
||||
except socket.error:
|
||||
if sys.exc_value[0] != errno.EINPROGRESS:
|
||||
# for all errors, we try other addresses
|
||||
self.connect_to_next_ip()
|
||||
|
@ -491,7 +491,7 @@ class P2PConnection(IdleObject, PlugIn):
|
|||
try:
|
||||
self._sock.shutdown(socket.SHUT_RDWR)
|
||||
self._sock.close()
|
||||
except:
|
||||
except socket.error:
|
||||
# socket is already closed
|
||||
pass
|
||||
self.fd = -1
|
||||
|
|
|
@ -640,7 +640,7 @@ class PreferencesWindow:
|
|||
tv = gtk.TextView()
|
||||
try:
|
||||
gtkspell.Spell(tv, lang)
|
||||
except:
|
||||
except Exception:
|
||||
dialogs.ErrorDialog(
|
||||
_('Dictionary for lang %s not available') % lang,
|
||||
_('You have to install %s dictionary to use spellchecking, or '
|
||||
|
|
|
@ -795,7 +795,7 @@ default_name = ''):
|
|||
# Save image
|
||||
try:
|
||||
pixbuf.save(file_path, type_)
|
||||
except:
|
||||
except Exception:
|
||||
if os.path.exists(file_path):
|
||||
os.remove(file_path)
|
||||
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg'
|
||||
|
|
|
@ -1046,7 +1046,8 @@ if __name__ == '__main__':
|
|||
change_cursor = tag
|
||||
elif tag == tag_table.lookup('focus-out-line'):
|
||||
over_line = True
|
||||
except: pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
#if line_tooltip.timeout != 0:
|
||||
# Check if we should hide the line tooltip
|
||||
|
|
Loading…
Reference in New Issue