mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 10:46:54 +00:00
Catch Keyboard interruptions in our application
Add logging to our main application
This commit is contained in:
parent
67f9e04335
commit
c0659d1a8c
1 changed files with 15 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
|||
"""Command-line implementation of flake8."""
|
||||
import logging
|
||||
|
||||
import flake8
|
||||
from flake8 import checker
|
||||
from flake8 import defaults
|
||||
|
|
@ -7,6 +9,8 @@ from flake8.options import aggregator
|
|||
from flake8.options import manager
|
||||
from flake8.plugins import manager as plugin_manager
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def register_default_options(option_manager):
|
||||
"""Register the default options on our OptionManager."""
|
||||
|
|
@ -267,9 +271,7 @@ class Application(object):
|
|||
"""Report all the errors found by flake8 3.0."""
|
||||
self.file_checker_manager.report()
|
||||
|
||||
def run(self, argv=None):
|
||||
# type: (Union[NoneType, List[str]]) -> NoneType
|
||||
"""Run our application."""
|
||||
def _run(self, argv):
|
||||
self.find_plugins()
|
||||
self.register_plugin_options()
|
||||
self.parse_configuration_and_cli(argv)
|
||||
|
|
@ -280,6 +282,16 @@ class Application(object):
|
|||
self.run_checks()
|
||||
self.report_errors()
|
||||
|
||||
def run(self, argv=None):
|
||||
# type: (Union[NoneType, List[str]]) -> NoneType
|
||||
"""Run our application."""
|
||||
try:
|
||||
self._run(argv)
|
||||
except KeyboardInterrupt as exc:
|
||||
LOG.critical('Caught keyboard interrupt from user')
|
||||
LOG.exception(exc)
|
||||
self.file_checker_manager._force_cleanup()
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
# type: (Union[NoneType, List[str]]) -> NoneType
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue