Commit 69f29969 authored by mathieui's avatar mathieui

Improve some bare or redundant excepts

parent bbfb8348
......@@ -360,7 +360,7 @@ class Config(RawConfigParser):
try:
with open(self.file_name, 'r', encoding='utf-8') as df:
lines_before = [line.strip() for line in df]
except:
except OSError:
log.error('Unable to read the config file %s',
self.file_name,
exc_info=True)
......
......@@ -57,7 +57,7 @@ class Executor(threading.Thread):
if self.filename:
try:
stdout = open(self.filename, self.redirection_mode)
except (OSError, IOError):
except OSError:
log.error('Could not open redirection file: %s', self.filename, exc_info=True)
return
try:
......
......@@ -261,7 +261,7 @@ class Logger(object):
else:
try:
fd.flush() # TODO do something better here?
except:
except OSError:
log.error('Unable to flush the log file (%s)',
os.path.join(log_dir, jid),
exc_info=True)
......
......@@ -172,8 +172,7 @@ def set_user_affiliation(xmpp, muc_jid, affiliation, nick=None, jid=None, reason
try:
return xmpp.plugin['xep_0045'].set_affiliation(str(muc_jid), str(jid) if jid else None, nick, affiliation)
except:
import traceback
log.debug('Error setting the affiliation: %s', traceback.format_exc())
log.debug('Error setting the affiliation: %s', exc_info=True)
return False
def cancel_config(xmpp, room):
......
......@@ -266,17 +266,13 @@ class PluginManager(object):
completion function that completes the name of the plugins, from
all .py files in plugins_dir
"""
try:
names = set()
for path_ in self.load_path:
try:
add = set(os.listdir(path_))
names |= add
except:
except OSError:
pass
except OSError as e:
self.core.information('Completion failed: %s' % e, 'Error')
return False
plugins_files = [name[:-3] for name in names if name.endswith('.py')
and name != '__init__.py' and not name.startswith('.')]
plugins_files.sort()
......
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