Skip to content

Commit 875c846

Browse files
zijiehe-google-comcopybara-github
authored andcommitted
[Fuchsia] Handle the case when the gsutil.py wrapper is not present
Since the tool is also used out of chromium environment, find_depot_tools.py and gsutil.py may not always be present. In the case, gsutil will be executed directly as a backup plan. Bug: 394836671 Change-Id: I3c5985df1804ee39c491bd7f18f98e7ce76de7ef Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6676483 Commit-Queue: Zijie He <[email protected]> Reviewed-by: Guocheng Wei <[email protected]> Cr-Commit-Position: refs/heads/main@{#1480113} NOKEYCHECK=True GitOrigin-RevId: 24c39397cf9b52d2e98d7b0e93b8961c94dc8868
1 parent 5a2f125 commit 875c846

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fuchsia/test/gs_util_wrapper.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@
88
import subprocess
99
import sys
1010

11-
from typing import List
11+
from typing import List, Optional
1212

1313
from common import DIR_SRC_ROOT
1414

1515

16-
def _find_gsutil() -> str:
16+
def _find_gsutil() -> Optional[str]:
1717
""" Returns the location of the gsutil.py. """
18+
if not os.path.isfile(
19+
os.path.join(DIR_SRC_ROOT, 'build', 'find_depot_tools.py')):
20+
# No gsutil.py and find_depot_tools.py wrapper, will run gsutil
21+
# directly.
22+
return None
23+
1824
sys.path.append(os.path.join(DIR_SRC_ROOT, 'build'))
1925
# Do not pollute the environment, callers should not use find_depot_tools
2026
# directly.
@@ -31,4 +37,7 @@ def _find_gsutil() -> str:
3137
def run_gsutil(args: List[str]) -> None:
3238
""" Runs gsutil with |args| and throws CalledProcessError if the process
3339
failed. """
40+
if not GSUTIL_PATH:
41+
# Try to run gsutil directly if there isn't a gsutil.py wrapper.
42+
return subprocess.run(['gsutil'] + args, check=True)
3443
return subprocess.run([sys.executable, GSUTIL_PATH] + args, check=True)

0 commit comments

Comments
 (0)