diff --git a/PRESUBMIT.py b/PRESUBMIT.py index c09f69ad69..ffe82a1ccf 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -11,6 +11,17 @@ details on the presubmit API built into depot_tools. def CommonChecks(input_api, output_api): results = [] + import sys + if not sys.version.startswith('2.5'): + # Depot_tools has the particularity that it needs to be tested on python + # 2.5. But we don't want the presubmit check to fail if it is not installed. + results.append(output_api.PresubmitNotifyResult( + 'You should install python 2.5 and run ln -s $(which python2.5) python.' + '\n' + 'A great place to put this symlink is in depot_tools.\n' + 'Otherwise, you break depot_tools on python 2.5, you get to keep the ' + 'pieces.')) + results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) black_list = list(input_api.DEFAULT_BLACK_LIST) + [ diff --git a/chrome-update.py b/chrome-update.py index 3889361783..4f5731cb4d 100755 --- a/chrome-update.py +++ b/chrome-update.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/drover.py b/drover.py index abd942aa86..04fbd265a9 100755 --- a/drover.py +++ b/drover.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/fix_encoding.py b/fix_encoding.py index ab418695b2..87e54a5790 100644 --- a/fix_encoding.py +++ b/fix_encoding.py @@ -187,7 +187,8 @@ class WinUnicodeConsoleOutput(WinUnicodeOutputBase): # Loads the necessary function. from ctypes import byref, GetLastError, POINTER, windll, WINFUNCTYPE - from ctypes.wintypes import BOOL, DWORD, HANDLE, LPVOID, LPWSTR + from ctypes.wintypes import BOOL, DWORD, HANDLE, LPWSTR + from ctypes.wintypes import LPVOID # pylint: disable=E0611 self._DWORD = DWORD self._byref = byref diff --git a/gcl.py b/gcl.py index 76a217c442..6136d1c5a9 100755 --- a/gcl.py +++ b/gcl.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -25,12 +25,8 @@ try: import simplejson as json # pylint: disable=F0401 except ImportError: try: - import json - # Some versions of python2.5 have an incomplete json module. Check to make - # sure loads exists. - # pylint: disable=W0104 - json.loads - except (ImportError, AttributeError): + import json # pylint: disable=F0401 + except ImportError: # Import the one included in depot_tools. sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) import simplejson as json # pylint: disable=F0401 diff --git a/gclient.py b/gclient.py index c33973dfde..e63f85abd0 100644 --- a/gclient.py +++ b/gclient.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/git_cl.py b/git_cl.py index e22ea6afbc..1887cbb8da 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1,7 +1,12 @@ -#!/usr/bin/python -# git-cl -- a git-command for integrating reviews on Rietveld +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + # Copyright (C) 2008 Evan Martin +"""A git-command for integrating reviews on Rietveld.""" + import errno import logging import optparse @@ -23,7 +28,7 @@ try: import simplejson as json # pylint: disable=F0401 except ImportError: try: - import json + import json # pylint: disable=F0401 except ImportError: # Fall back to the packaged version. sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) diff --git a/owners.py b/owners.py index 5aabb60077..5be7ff6d00 100644 --- a/owners.py +++ b/owners.py @@ -18,6 +18,8 @@ BASIC_EMAIL_REGEXP = r'^[\w\-\+\%\.]+\@[\w\-\+\%\.]+$' def _assert_is_collection(obj): assert not isinstance(obj, basestring) + # Module 'collections' has no 'Iterable' member + # pylint: disable=E1101 if hasattr(collections, 'Iterable') and hasattr(collections, 'Sized'): assert (isinstance(obj, collections.Iterable) and isinstance(obj, collections.Sized)) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 0e9d5da62f..a1144b8641 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -598,6 +598,7 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None): return [output_api.PresubmitError( 'Please install pylint with "sudo apt-get install python-setuptools; ' 'sudo easy_install pylint"\n' + 'or visit http://pypi.python.org/pypi/setuptools.\n' 'Cannot do static analysis of python files.')] if result: if input_api.is_committing: diff --git a/presubmit_support.py b/presubmit_support.py index 5a003eba00..fcc6a8555c 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -38,13 +38,8 @@ try: import simplejson as json # pylint: disable=F0401 except ImportError: try: - import json - # Some versions of python2.5 have an incomplete json module. Check to make - # sure loads exists. - # Statement seems to have no effect - # pylint: disable=W0104 - json.loads - except (ImportError, AttributeError): + import json # pylint: disable=F0401 + except ImportError: # Import the one included in depot_tools. sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) import simplejson as json # pylint: disable=F0401 diff --git a/trychange.py b/trychange.py index a848c5b24c..003f040b26 100755 --- a/trychange.py +++ b/trychange.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -25,20 +25,15 @@ try: import simplejson as json # pylint: disable=F0401 except ImportError: try: - import json + import json # pylint: disable=F0401 except ImportError: - json = None + # Import the one included in depot_tools. + sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party')) + import simplejson as json # pylint: disable=F0401 -try: - import breakpad # pylint: disable=W0611 -except ImportError: - pass - -try: - import gcl -except ImportError: - gcl = None +import breakpad # pylint: disable=W0611 +import gcl import fix_encoding import gclient_utils import scm diff --git a/watchlists.py b/watchlists.py index 57b810cb17..a6b5582aae 100755 --- a/watchlists.py +++ b/watchlists.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file.