Fix gsutil path when pulling it from depot_tools on windows https://crrev.com/c/7667499 works for linux, but not windows. This is because we were passing the batch file version of depot_tool's gsutil to python: https://chromium.googlesource.com/chromium/tools/depot_tools/+/refs/heads/main/gsutil.py.bat vs https://chromium.googlesource.com/chromium/tools/depot_tools/+/refs/heads/main/gsutil.py This should fix that. Bug: chromium:492147922 Change-Id: Ia75eb5171d35ed062687643ef0f4282a3e98b5c5 Reviewed-on: https://chromium-review.googlesource.com/c/catapult/+/7833117 Reviewed-by: Brian Sheedy <bsheedy@chromium.org> Commit-Queue: Ben Pastene <bpastene@chromium.org>
diff --git a/common/py_utils/py_utils/cloud_storage.py b/common/py_utils/py_utils/cloud_storage.py index 1655712..ee4fdfa 100644 --- a/common/py_utils/py_utils/cloud_storage.py +++ b/common/py_utils/py_utils/cloud_storage.py
@@ -57,6 +57,12 @@ _gsutil_from_path = shutil.which('gsutil.py') if (_gsutil_from_path and os.path.basename(os.path.dirname(_gsutil_from_path)) == 'depot_tools'): + # shutil.which() will return a matching .bat file if one exists. But we pass + # our gsutil straight to python. So chop off the .bat ext. + if _gsutil_from_path.lower().endswith('.bat'): + _gsutil_py = _gsutil_from_path[:-4] + if os.path.exists(_gsutil_py): + _gsutil_from_path = _gsutil_py _GSUTIL_PATH = _gsutil_from_path # TODO(tbarzic): A workaround for http://crbug.com/386416 and