Remove redundant except (SystemExit, KeyboardInterrupt) clauses
This can be replaced by ensuring the final except clause is 'except Exceptions'. This works because SystemExit and KeyboardInterrupt do not inherit from the base 'Exception' classpull/1446/head
parent
fdcd4e7a2c
commit
fbb9231adc
|
@ -78,8 +78,6 @@ def get_services(services_folder):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
services.append(create_service_descriptor(name))
|
services.append(create_service_descriptor(name))
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('Failed to create service from ' + name,
|
LOG.error('Failed to create service from ' + name,
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
@ -88,8 +86,6 @@ def get_services(services_folder):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
services.append(create_service_descriptor(location))
|
services.append(create_service_descriptor(location))
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('Failed to create service from ' + name,
|
LOG.error('Failed to create service from ' + name,
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
@ -117,8 +113,6 @@ def load_services(config, ws, path=None):
|
||||||
try:
|
try:
|
||||||
service_module = imp.load_module(descriptor["name"] + MAINMODULE,
|
service_module = imp.load_module(descriptor["name"] + MAINMODULE,
|
||||||
*descriptor["info"])
|
*descriptor["info"])
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('Failed to import module ' + descriptor['name'],
|
LOG.error('Failed to import module ' + descriptor['name'],
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
@ -127,8 +121,6 @@ def load_services(config, ws, path=None):
|
||||||
try:
|
try:
|
||||||
s = service_module.autodetect(config, ws)
|
s = service_module.autodetect(config, ws)
|
||||||
service += s
|
service += s
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('Failed to autodetect...',
|
LOG.error('Failed to autodetect...',
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
@ -136,8 +128,6 @@ def load_services(config, ws, path=None):
|
||||||
try:
|
try:
|
||||||
s = service_module.load_service(config, ws)
|
s = service_module.load_service(config, ws)
|
||||||
service += s
|
service += s
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.error('Failed to load service...',
|
LOG.error('Failed to load service...',
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
@ -290,8 +280,6 @@ class AudioService(object):
|
||||||
try:
|
try:
|
||||||
if self.pulse_quiet:
|
if self.pulse_quiet:
|
||||||
self.pulse_quiet()
|
self.pulse_quiet()
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.error(exc)
|
LOG.error(exc)
|
||||||
|
|
||||||
|
@ -473,8 +461,6 @@ def main():
|
||||||
if 'mycroft.audio.service' not in _message.get('type'):
|
if 'mycroft.audio.service' not in _message.get('type'):
|
||||||
return
|
return
|
||||||
message = json.dumps(_message)
|
message = json.dumps(_message)
|
||||||
except (KeyboardInterrupt, SystemExit):
|
|
||||||
raise
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception(e)
|
LOG.exception(e)
|
||||||
LOG.debug(message)
|
LOG.debug(message)
|
||||||
|
|
|
@ -273,8 +273,6 @@ class HotWordFactory(object):
|
||||||
clazz = HotWordFactory.CLASSES.get(module)
|
clazz = HotWordFactory.CLASSES.get(module)
|
||||||
try:
|
try:
|
||||||
return clazz(hotword, config, lang=lang)
|
return clazz(hotword, config, lang=lang)
|
||||||
except (KeyboardInterrupt, SystemExit):
|
except Exception:
|
||||||
raise
|
|
||||||
except:
|
|
||||||
LOG.exception('Could not create hotword. Falling back to default.')
|
LOG.exception('Could not create hotword. Falling back to default.')
|
||||||
return HotWordFactory.CLASSES['pocketsphinx']()
|
return HotWordFactory.CLASSES['pocketsphinx']()
|
||||||
|
|
Loading…
Reference in New Issue