OLD | NEW |
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Top-level presubmit script for depot tools. | 5 """Top-level presubmit script for depot tools. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
8 details on the presubmit API built into gcl. | 8 details on the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return [] | 50 return [] |
51 | 51 |
52 def RunPylint(input_api, output_api): | 52 def RunPylint(input_api, output_api): |
53 import glob | 53 import glob |
54 files = glob.glob('*.py') | 54 files = glob.glob('*.py') |
55 # It's a python script | 55 # It's a python script |
56 files.append('git-try') | 56 files.append('git-try') |
57 # It uses non-standard pylint exceptions that makes pylint always fail. | 57 # It uses non-standard pylint exceptions that makes pylint always fail. |
58 files.remove('cpplint.py') | 58 files.remove('cpplint.py') |
59 try: | 59 try: |
60 proc = input_api.subprocess.Popen(['pylint', '-E'] + sorted(files)) | 60 proc = input_api.subprocess.Popen(['pylint'] + sorted(files)) |
61 proc.communicate() | 61 proc.communicate() |
62 if proc.returncode: | 62 if proc.returncode: |
63 return [output_api.PresubmitError('Fix pylint errors first.')] | 63 return [output_api.PresubmitError('Fix pylint errors first.')] |
64 return [] | 64 return [] |
65 except OSError, e: | 65 except OSError: |
66 if input_api.platform == 'win32': | 66 if input_api.platform == 'win32': |
67 return [output_api.PresubmitNotifyResult( | 67 return [output_api.PresubmitNotifyResult( |
68 'Warning: Can\'t run pylint because it is not installed. Please ' | 68 'Warning: Can\'t run pylint because it is not installed. Please ' |
69 'install manually\n' | 69 'install manually\n' |
70 'Cannot do static analysis of python files.')] | 70 'Cannot do static analysis of python files.')] |
71 return [output_api.PresubmitError( | 71 return [output_api.PresubmitError( |
72 'Please install pylint with "sudo apt-get install python-setuptools; ' | 72 'Please install pylint with "sudo apt-get install python-setuptools; ' |
73 'sudo easy_install pylint"\n' | 73 'sudo easy_install pylint"\n' |
74 'Cannot do static analysis of python files.')] | 74 'Cannot do static analysis of python files.')] |
OLD | NEW |