diff --git a/.gitignore b/.gitignore index cb3efa641..7f90bd510 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,6 @@ testing_support/google_appengine # Ignore VsChromium configuration file. /vs-chromium-project.txt + +# Ignore the file that logs Python 2 scripts run during presubmits. +/python2_usage.txt diff --git a/presubmit_support.py b/presubmit_support.py index 30c003601..679c0c145 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1725,6 +1725,10 @@ def DoPresubmitChecks(change, if not presubmit_files and verbose: sys.stdout.write('Warning, no PRESUBMIT.py found.\n') results = [] + depot_tools = os.path.dirname(os.path.abspath(__file__)) + python2_usage_log_file = os.path.join(depot_tools, 'python2_usage.txt') + if os.path.exists(python2_usage_log_file): + os.remove(python2_usage_log_file) thread_pool = ThreadPool() executer = PresubmitExecuter(change, committing, verbose, gerrit_obj, dry_run, thread_pool, parallel, use_python3, @@ -1751,6 +1755,17 @@ def DoPresubmitChecks(change, results += thread_pool.RunAsync() + if os.path.exists(python2_usage_log_file): + with open(python2_usage_log_file) as f: + python2_usage = [x.strip() for x in f.readlines()] + results.append( + OutputApi(committing).PresubmitPromptWarning( + 'Python 2 scripts were run during %s presubmits. Please see ' + 'https://bugs.chromium.org/p/chromium/issues/detail?id=1313804' + '#c61 for tips on resolving this.' + % python_version, + items=python2_usage)) + messages = {} should_prompt = False presubmits_failed = False diff --git a/vpython b/vpython index 997658acc..c63795471 100755 --- a/vpython +++ b/vpython @@ -41,6 +41,8 @@ base_dir=$(dirname "$0") source "$base_dir/cipd_bin_setup.sh" cipd_bin_setup &> /dev/null +echo $@ from $(pwd) >> "$base_dir/python2_usage.txt" + # If Python bootstrapping is not disabled, make sure Python has been # bootstrapped and add it to the front of PATH. if [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then diff --git a/vpython.bat b/vpython.bat index 0b1826172..43f00cf79 100644 --- a/vpython.bat +++ b/vpython.bat @@ -6,4 +6,5 @@ :: See revert instructions in cipd_manifest.txt call "%~dp0\cipd_bin_setup.bat" > nul 2>&1 +echo %* from %cd% >> "%~dp0\python2_usage.txt" "%~dp0\.cipd_bin\vpython.exe" -vpython-interpreter "%~dp0\python.bat" %*