Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: mojo/public/tools/pylib/gs.py

Issue 870143008: Move //tools/gs.py into //mojo/public/tools (Closed) Base URL: https://github.com/domokit/mojo.git@expose_downloading_network_service
Patch Set: Response to review Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/tools/download_shell_binary.py ('k') | mojo/tools/roll/roll_network_service.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 3 # found in the LICENSE file.
5 4
6 import os 5 import os
7 import subprocess 6 import subprocess
8 import sys 7 import sys
9 import find_depot_tools
10 8
11 def download_from_public_bucket(gs_path, output_path): 9 def download_from_public_bucket(gs_path, output_path, find_depot_tools_path):
viettrungluu 2015/02/12 17:20:25 It occurs to me that this is a very strange API. P
blundell 2015/02/12 19:31:28 Done.
10 sys.path.insert(0, find_depot_tools_path)
11 # pylint: disable=F0401
12 import find_depot_tools
12 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 13 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
13 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") 14 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
14 15
15 # We're downloading from a public bucket which does not need authentication, 16 # We're downloading from a public bucket which does not need authentication,
16 # but the user might have busted credential files somewhere such as ~/.boto 17 # but the user might have busted credential files somewhere such as ~/.boto
17 # that the gsutil script will try (and fail) to use. Setting these 18 # that the gsutil script will try (and fail) to use. Setting these
18 # environment variables convinces gsutil not to attempt to use these, but 19 # environment variables convinces gsutil not to attempt to use these, but
19 # also generates a useless warning about failing to load the file. We want 20 # also generates a useless warning about failing to load the file. We want
20 # to discard this warning but still preserve all output in the case of an 21 # to discard this warning but still preserve all output in the case of an
21 # actual failure. So, we run the script and capture all output and then 22 # actual failure. So, we run the script and capture all output and then
22 # throw the output away if the script succeeds (return code 0). 23 # throw the output away if the script succeeds (return code 0).
23 env = os.environ.copy() 24 env = os.environ.copy()
24 env["AWS_CREDENTIAL_FILE"] = "" 25 env["AWS_CREDENTIAL_FILE"] = ""
25 env["BOTO_CONFIG"] = "" 26 env["BOTO_CONFIG"] = ""
26 try: 27 try:
27 subprocess.check_output( 28 subprocess.check_output(
28 [gsutil_exe, 29 [gsutil_exe,
29 "--bypass_prodaccess", 30 "--bypass_prodaccess",
30 "cp", 31 "cp",
31 gs_path, 32 gs_path,
32 output_path], 33 output_path],
33 stderr=subprocess.STDOUT, 34 stderr=subprocess.STDOUT,
34 env=env) 35 env=env)
35 except subprocess.CalledProcessError as e: 36 except subprocess.CalledProcessError as e:
36 print e.output 37 print e.output
37 sys.exit(1) 38 sys.exit(1)
OLDNEW
« no previous file with comments | « mojo/public/tools/download_shell_binary.py ('k') | mojo/tools/roll/roll_network_service.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698