From fbb9231adc349f13a0f2114afe89d6ac7f1d8de3 Mon Sep 17 00:00:00 2001 From: "Matthew D. Scholefield" Date: Tue, 27 Feb 2018 14:28:29 -0600 Subject: [PATCH] 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' class --- mycroft/audio/main.py | 14 -------------- mycroft/client/speech/hotword_factory.py | 4 +--- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/mycroft/audio/main.py b/mycroft/audio/main.py index 624a9222e1..74930e8eb1 100644 --- a/mycroft/audio/main.py +++ b/mycroft/audio/main.py @@ -78,8 +78,6 @@ def get_services(services_folder): continue try: services.append(create_service_descriptor(name)) - except (KeyboardInterrupt, SystemExit): - raise except Exception: LOG.error('Failed to create service from ' + name, exc_info=True) @@ -88,8 +86,6 @@ def get_services(services_folder): continue try: services.append(create_service_descriptor(location)) - except (KeyboardInterrupt, SystemExit): - raise except Exception: LOG.error('Failed to create service from ' + name, exc_info=True) @@ -117,8 +113,6 @@ def load_services(config, ws, path=None): try: service_module = imp.load_module(descriptor["name"] + MAINMODULE, *descriptor["info"]) - except (KeyboardInterrupt, SystemExit): - raise except Exception: LOG.error('Failed to import module ' + descriptor['name'], exc_info=True) @@ -127,8 +121,6 @@ def load_services(config, ws, path=None): try: s = service_module.autodetect(config, ws) service += s - except (KeyboardInterrupt, SystemExit): - raise except Exception: LOG.error('Failed to autodetect...', exc_info=True) @@ -136,8 +128,6 @@ def load_services(config, ws, path=None): try: s = service_module.load_service(config, ws) service += s - except (KeyboardInterrupt, SystemExit): - raise except Exception: LOG.error('Failed to load service...', exc_info=True) @@ -290,8 +280,6 @@ class AudioService(object): try: if self.pulse_quiet: self.pulse_quiet() - except (KeyboardInterrupt, SystemExit): - raise except Exception as exc: LOG.error(exc) @@ -473,8 +461,6 @@ def main(): if 'mycroft.audio.service' not in _message.get('type'): return message = json.dumps(_message) - except (KeyboardInterrupt, SystemExit): - raise except Exception as e: LOG.exception(e) LOG.debug(message) diff --git a/mycroft/client/speech/hotword_factory.py b/mycroft/client/speech/hotword_factory.py index ca680bf26c..85f5960a54 100644 --- a/mycroft/client/speech/hotword_factory.py +++ b/mycroft/client/speech/hotword_factory.py @@ -273,8 +273,6 @@ class HotWordFactory(object): clazz = HotWordFactory.CLASSES.get(module) try: return clazz(hotword, config, lang=lang) - except (KeyboardInterrupt, SystemExit): - raise - except: + except Exception: LOG.exception('Could not create hotword. Falling back to default.') return HotWordFactory.CLASSES['pocketsphinx']()