OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '1.6.1' | 9 __version__ = '1.6.1' |
10 | 10 |
11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow | 11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow |
12 # caching (between all different invocations of presubmit scripts for a given | 12 # caching (between all different invocations of presubmit scripts for a given |
13 # change). We should add it as our presubmit scripts start feeling slow. | 13 # change). We should add it as our presubmit scripts start feeling slow. |
14 | 14 |
15 import cPickle # Exposed through the API. | 15 import cPickle # Exposed through the API. |
16 import cStringIO # Exposed through the API. | 16 import cStringIO # Exposed through the API. |
17 import fnmatch | 17 import fnmatch |
18 import glob | 18 import glob |
19 import inspect | 19 import inspect |
| 20 import json # Exposed through the API. |
20 import logging | 21 import logging |
21 import marshal # Exposed through the API. | 22 import marshal # Exposed through the API. |
22 import optparse | 23 import optparse |
23 import os # Somewhat exposed through the API. | 24 import os # Somewhat exposed through the API. |
24 import pickle # Exposed through the API. | 25 import pickle # Exposed through the API. |
25 import random | 26 import random |
26 import re # Exposed through the API. | 27 import re # Exposed through the API. |
27 import sys # Parts exposed through API. | 28 import sys # Parts exposed through API. |
28 import tempfile # Exposed through the API. | 29 import tempfile # Exposed through the API. |
29 import time | 30 import time |
30 import traceback # Exposed through the API. | 31 import traceback # Exposed through the API. |
31 import types | 32 import types |
32 import unittest # Exposed through the API. | 33 import unittest # Exposed through the API. |
33 import urllib2 # Exposed through the API. | 34 import urllib2 # Exposed through the API. |
34 from warnings import warn | 35 from warnings import warn |
35 | 36 |
36 try: | |
37 import simplejson as json # pylint: disable=F0401 | |
38 except ImportError: | |
39 try: | |
40 import json # pylint: disable=F0401 | |
41 except ImportError: | |
42 # Import the one included in depot_tools. | |
43 sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) | |
44 import simplejson as json # pylint: disable=F0401 | |
45 | |
46 # Local imports. | 37 # Local imports. |
47 import fix_encoding | 38 import fix_encoding |
48 import gclient_utils | 39 import gclient_utils |
49 import owners | 40 import owners |
50 import presubmit_canned_checks | 41 import presubmit_canned_checks |
51 import rietveld | 42 import rietveld |
52 import scm | 43 import scm |
53 import subprocess2 as subprocess # Exposed through the API. | 44 import subprocess2 as subprocess # Exposed through the API. |
54 | 45 |
55 | 46 |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 except PresubmitFailure, e: | 1259 except PresubmitFailure, e: |
1269 print >> sys.stderr, e | 1260 print >> sys.stderr, e |
1270 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1261 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
1271 print >> sys.stderr, 'If all fails, contact maruel@' | 1262 print >> sys.stderr, 'If all fails, contact maruel@' |
1272 return 2 | 1263 return 2 |
1273 | 1264 |
1274 | 1265 |
1275 if __name__ == '__main__': | 1266 if __name__ == '__main__': |
1276 fix_encoding.fix_encoding() | 1267 fix_encoding.fix_encoding() |
1277 sys.exit(Main(None)) | 1268 sys.exit(Main(None)) |
OLD | NEW |