Commit fca53394 authored by maruel@chromium.org's avatar maruel@chromium.org

Workaround the fact that pylint calls sys.exit().

Otherwise the following presubmit checks where never called.

TBR=nsylvain
BUG=
TEST=fixes unit tests

Review URL: http://codereview.chromium.org/5995003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@69844 0039d316-1c4b-4281-b951-d872f2087c98
parent 2e9ba2ac
...@@ -494,9 +494,10 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None): ...@@ -494,9 +494,10 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None):
# were listed, try to run pylint. # were listed, try to run pylint.
try: try:
from pylint import lint from pylint import lint
if lint.Run(sorted(files)): result = lint.Run(sorted(files))
return [output_api.PresubmitPromptWarning('Fix pylint errors first.')] except SystemExit, e:
return [] # pylint has the bad habit of calling sys.exit(), trap it here.
result = e.code
except ImportError: except ImportError:
if input_api.platform == 'win32': if input_api.platform == 'win32':
return [output_api.PresubmitNotifyResult( return [output_api.PresubmitNotifyResult(
...@@ -507,6 +508,9 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None): ...@@ -507,6 +508,9 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None):
'Please install pylint with "sudo apt-get install python-setuptools; ' 'Please install pylint with "sudo apt-get install python-setuptools; '
'sudo easy_install pylint"\n' 'sudo easy_install pylint"\n'
'Cannot do static analysis of python files.')] 'Cannot do static analysis of python files.')]
if result:
return [output_api.PresubmitPromptWarning('Fix pylint errors first.')]
return []
finally: finally:
warnings.filterwarnings('default', category=DeprecationWarning) warnings.filterwarnings('default', category=DeprecationWarning)
......
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