From c9f904f2051c80c4610be50abc02bd064a948e0c Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Fri, 14 Oct 2022 20:59:49 +0000 Subject: [PATCH] Move python2_usage.txt from depot_tools to temp The initial version of detecting Python 2 usage in presubmit child scripts used a text file in depot_tools to record Python 2 usage. This caused problems in chromeos so this change moves to the file to the temp directory, which is where it should have been in the first place. Bug: 1366661 Change-Id: I003b813d7bd5f70956dd3418f86e8ed6edf88220 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3954470 Reviewed-by: Gavin Mak Commit-Queue: Bruce Dawson --- presubmit_support.py | 7 +++++-- vpython | 2 +- vpython.bat | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/presubmit_support.py b/presubmit_support.py index 8d5338533..93a9e7373 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1740,8 +1740,11 @@ 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 sys.platform == 'win32': + temp = os.environ['TEMP'] + else: + temp = '/tmp' + python2_usage_log_file = os.path.join(temp, 'python2_usage.txt') if os.path.exists(python2_usage_log_file): os.remove(python2_usage_log_file) thread_pool = ThreadPool() diff --git a/vpython b/vpython index 41bb92775..9f0362712 100755 --- a/vpython +++ b/vpython @@ -41,7 +41,7 @@ base_dir=$(dirname "$0") source "$base_dir/cipd_bin_setup.sh" cipd_bin_setup &> /dev/null -echo $@ from $(pwd) >> "$base_dir/python2_usage.txt" +echo $@ from $(pwd) >> "/tmp/python2_usage.txt" if [[ $(uname -s) = MINGW* || $(uname -s) = CYGWIN* ]]; then cmd.exe //c $0.bat "$@" diff --git a/vpython.bat b/vpython.bat index c6818714a..12a9d14dc 100644 --- a/vpython.bat +++ b/vpython.bat @@ -6,5 +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" +echo %* from %cd% >> "%TEMP%\python2_usage.txt" "%~dp0\.cipd_bin\vpython.exe" %*