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

Side by Side 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse
6 import os 7 import os
7 import subprocess 8 import subprocess
8 import sys 9 import sys
9 import tempfile 10 import tempfile
10 import zipfile 11 import zipfile
11 12
12 current_path = os.path.dirname(os.path.realpath(__file__)) 13 current_path = os.path.dirname(os.path.realpath(__file__))
13 sys.path.insert(0, os.path.join(current_path, "..", "..", "..", "tools")) 14 sys.path.insert(0, os.path.join(current_path, "..", "..", "..", "tools"))
14 # pylint: disable=F0401 15 # pylint: disable=F0401
15 import find_depot_tools 16 import find_depot_tools
16 17
17 if not sys.platform.startswith("linux"): 18 if not sys.platform.startswith("linux"):
18 print "Not supported for your platform" 19 print "Not supported for your platform"
19 sys.exit(0) 20 sys.exit(0)
20 21
21 version_path = os.path.join(current_path, "../VERSION")
22 with open(version_path) as version_file:
23 version = version_file.read().strip()
24
25 prebuilt_file_path = os.path.join(current_path, "prebuilt") 22 prebuilt_file_path = os.path.join(current_path, "prebuilt")
26 stamp_path = os.path.join(prebuilt_file_path, "VERSION") 23 stamp_path = os.path.join(prebuilt_file_path, "VERSION")
27 24
28 try:
29 with open(stamp_path) as stamp_file:
30 current_version = stamp_file.read().strip()
31 if current_version == version:
32 sys.exit(0)
33 except IOError:
34 pass
35
36 platform = "linux-x64" # TODO: configurate
37 basename = platform + ".zip"
38
39 gs_path = "gs://mojo/shell/" + version + "/" + basename
40
41 depot_tools_path = find_depot_tools.add_depot_tools_to_path() 25 depot_tools_path = find_depot_tools.add_depot_tools_to_path()
42 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil") 26 gsutil_exe = os.path.join(depot_tools_path, "third_party", "gsutil", "gsutil")
43 27
44 with tempfile.NamedTemporaryFile() as temp_zip_file: 28 def download():
45 subprocess.check_call([gsutil_exe, "--bypass_prodaccess", 29 version_path = os.path.join(current_path, "../VERSION")
46 "cp", gs_path, temp_zip_file.name]) 30 with open(version_path) as version_file:
47 with zipfile.ZipFile(temp_zip_file.name) as z: 31 version = version_file.read().strip()
48 zi = z.getinfo("mojo_shell")
49 mode = zi.external_attr >> 16L
50 z.extract(zi, prebuilt_file_path)
51 os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode)
52 32
53 with open(stamp_path, 'w') as stamp_file: 33 try:
54 stamp_file.write(version + "\n") 34 with open(stamp_path) as stamp_file:
35 current_version = stamp_file.read().strip()
36 if current_version == version:
37 return 0 # Already have the right version.
38 except IOError:
39 pass # If the stamp file does not exist we need to download a new binary.
40
41 platform = "linux-x64" # TODO: configurate
42 basename = platform + ".zip"
43
44 gs_path = "gs://mojo/shell/" + version + "/" + basename
45
46 with tempfile.NamedTemporaryFile() as temp_zip_file:
47 subprocess.check_call([gsutil_exe, "--bypass_prodaccess",
48 "cp", gs_path, temp_zip_file.name])
49 with zipfile.ZipFile(temp_zip_file.name) as z:
50 zi = z.getinfo("mojo_shell")
51 mode = zi.external_attr >> 16L
52 z.extract(zi, prebuilt_file_path)
53 os.chmod(os.path.join(prebuilt_file_path, "mojo_shell"), mode)
54
55 with open(stamp_path, 'w') as stamp_file:
56 stamp_file.write(version)
57 return 0
58
59 def main():
60 parser = argparse.ArgumentParser(description="Download mojo_shell binary "
61 "from google storage")
62 parser.parse_args()
63 return download()
64
65 if __name__ == "__main__":
66 sys.exit(main())
OLDNEW
« 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