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

Unified Diff: mojo/public/tools/download_shell_binary.py

Issue 698883005: Update mojo sdk to rev cfc99316100efdfa7d53d83f9e07f1d4d3765c21 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/download_shell_binary.py
diff --git a/mojo/public/tools/download_shell_binary.py b/mojo/public/tools/download_shell_binary.py
index 16180c4f2dce6b61719cf1a55d2e3aeffbc44e71..e28034c0fe75478475a3a6f32180bc5984378f9e 100755
--- a/mojo/public/tools/download_shell_binary.py
+++ b/mojo/public/tools/download_shell_binary.py
@@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import argparse
import os
import subprocess
import sys
@@ -18,37 +19,48 @@ if not sys.platform.startswith("linux"):
print "Not supported for your platform"
sys.exit(0)
-version_path = os.path.join(current_path, "../VERSION")
-with open(version_path) as version_file:
- version = version_file.read().strip()
-
prebuilt_file_path = os.path.join(current_path, "prebuilt")
stamp_path = os.path.join(prebuilt_file_path, "VERSION")
-try:
- with open(stamp_path) as stamp_file:
- current_version = stamp_file.read().strip()
- if current_version == version:
- sys.exit(0)
-except IOError:
- pass
+depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
-platform = "linux-x64" # TODO: configurate
-basename = platform + ".zip"
+def download():
+ version_path = os.path.join(current_path, "../VERSION")
+ with open(version_path) as version_file:
+ version = version_file.read().strip()
-gs_path = "gs://mojo/shell/" + version + "/" + basename
+ try:
+ with open(stamp_path) as stamp_file:
+ current_version = stamp_file.read().strip()
+ if current_version == version:
+ return 0 # Already have the right version.
+ except IOError:
+ pass # If the stamp file does not exist we need to download a new binary.
-depot_tools_path = find_depot_tools.add_depot_tools_to_path()
-gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
+ platform = "linux-x64" # TODO: configurate
+ basename = platform + ".zip"
+
+ gs_path = "gs://mojo/shell/" + version + "/" + basename
+
+ with tempfile.NamedTemporaryFile() as temp_zip_file:
+ subprocess.check_call([gsutil_exe, "--bypass_prodaccess",
+ "cp", gs_path, temp_zip_file.name])
+ with zipfile.ZipFile(temp_zip_file.name) as z:
+ zi = z.getinfo("mojo_shell")
+ mode = zi.external_attr >> 16L
+ z.extract(zi, prebuilt_file_path)
+ os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode)
+
+ with open(stamp_path, 'w') as stamp_file:
+ stamp_file.write(version)
+ return 0
+
+def main():
+ parser = argparse.ArgumentParser(description="Download mojo_shell binary "
+ "from google storage")
+ parser.parse_args()
+ return download()
-with tempfile.NamedTemporaryFile() as temp_zip_file:
- subprocess.check_call([gsutil_exe, "--bypass_prodaccess",
- "cp", gs_path, temp_zip_file.name])
- with zipfile.ZipFile(temp_zip_file.name) as z:
- zi = z.getinfo("mojo_shell")
- mode = zi.external_attr >> 16L
- z.extract(zi, prebuilt_file_path)
- os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode)
-
-with open(stamp_path, 'w') as stamp_file:
- stamp_file.write(version + "\n")
+if __name__ == "__main__":
+ sys.exit(main())
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py ('k') | mojo/services/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698