Commit d9c6d995 authored by djacques@chromium.org's avatar djacques@chromium.org

Fix gsutil execution on Windows.

5498b958 runs gsutil using 'os.execv',
which, on Windows, apparently causes it to return before completion.

Also add verbosity to '7z' failures on toolchain downloading.

BUG=chromium:445425
TEST=bot
  - Ran on bot, this fix solves the problem that we were seeing.

R=pgervais@chromium.org, sergeyberezin@chromium.org

Review URL: https://codereview.chromium.org/828463003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@293507 0039d316-1c4b-4281-b951-d872f2087c98
parent 0fb693ff
...@@ -28,7 +28,9 @@ DEFAULT_FALLBACK_GSUTIL = os.path.join( ...@@ -28,7 +28,9 @@ DEFAULT_FALLBACK_GSUTIL = os.path.join(
class SubprocessError(Exception): class SubprocessError(Exception):
pass def __init__(self, message=None, code=0):
super(SubprocessError, self).__init__(message)
self.code = code
class InvalidGsutilError(Exception): class InvalidGsutilError(Exception):
...@@ -46,7 +48,7 @@ def call(args, verbose=True, **kwargs): ...@@ -46,7 +48,7 @@ def call(args, verbose=True, **kwargs):
sys.stdout.write(line) sys.stdout.write(line)
code = proc.wait() code = proc.wait()
if code: if code:
raise SubprocessError('%s failed with %s' % (args, code)) raise SubprocessError('%s failed with %s' % (args, code), code)
return ''.join(out) return ''.join(out)
...@@ -125,7 +127,11 @@ def run_gsutil(force_version, fallback, target, args): ...@@ -125,7 +127,11 @@ def run_gsutil(force_version, fallback, target, args):
else: else:
gsutil_bin = fallback gsutil_bin = fallback
cmd = [sys.executable, gsutil_bin] + args cmd = [sys.executable, gsutil_bin] + args
os.execv(cmd[0], cmd) try:
call(cmd)
except SubprocessError as e:
return e.code
return 0
def parse_args(): def parse_args():
...@@ -145,7 +151,7 @@ def parse_args(): ...@@ -145,7 +151,7 @@ def parse_args():
def main(): def main():
force_version, fallback, target, args = parse_args() force_version, fallback, target, args = parse_args()
run_gsutil(force_version, fallback, target, args) return run_gsutil(force_version, fallback, target, args)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())
...@@ -150,7 +150,7 @@ def ExtractIso(iso_path): ...@@ -150,7 +150,7 @@ def ExtractIso(iso_path):
# TODO(scottmg): Do this (and exe) manually with python code. # TODO(scottmg): Do this (and exe) manually with python code.
# Note that at the beginning of main() we set the working directory to 7z's # Note that at the beginning of main() we set the working directory to 7z's
# location so that 7z can find its codec dll. # location so that 7z can find its codec dll.
RunOrDie('7z x "%s" -y "-o%s" >nul' % (iso_path, target_path)) RunOrDie('7z x "%s" -y "-o%s"' % (iso_path, target_path))
return target_path return target_path
...@@ -431,7 +431,7 @@ def DoTreeMirror(target_dir, tree_sha1): ...@@ -431,7 +431,7 @@ def DoTreeMirror(target_dir, tree_sha1):
local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') local_zip = DownloadUsingGsutil(tree_sha1 + '.zip')
sys.stdout.write('Extracting %s...\n' % local_zip) sys.stdout.write('Extracting %s...\n' % local_zip)
sys.stdout.flush() sys.stdout.flush()
RunOrDie('7z x "%s" -y "-o%s" >nul' % (local_zip, target_dir)) RunOrDie('7z x "%s" -y "-o%s"' % (local_zip, target_dir))
def main(): def main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment