Commit 69f29969 authored by mathieui's avatar mathieui

Improve some bare or redundant excepts

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