| OLD | NEW |
| 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 argparse |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 import zipfile | 11 import zipfile |
| 12 | 12 |
| 13 BINARY_FOR_PLATFORM = { | 13 BINARY_FOR_PLATFORM = { |
| 14 "linux-x64" : "mojo_shell", | 14 "linux-x64" : "mojo_shell", |
| 15 "android-arm" : "MojoShell.apk" | 15 "android-arm" : "MojoShell.apk" |
| 16 } | 16 } |
| 17 | 17 |
| 18 if not sys.platform.startswith("linux"): | 18 if not sys.platform.startswith("linux"): |
| 19 print "Not supported for your platform" | 19 print "Not supported for your platform" |
| 20 sys.exit(0) | 20 sys.exit(0) |
| 21 | 21 |
| 22 CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) | 22 CURRENT_PATH = os.path.dirname(os.path.realpath(__file__)) |
| 23 sys.path.insert(0, os.path.join(CURRENT_PATH, "pylib")) | 23 sys.path.insert(0, os.path.join(CURRENT_PATH, "pylib")) |
| 24 import gs | 24 import gs |
| 25 | 25 |
| 26 PREBUILT_FILE_PATH = os.path.join(CURRENT_PATH, "prebuilt", "shell") | 26 PREBUILT_FILE_PATH = os.path.join(CURRENT_PATH, "prebuilt", "shell") |
| 27 | 27 |
| 28 | 28 |
| 29 def download(tools_directory): | 29 def download(tools_directory, version_file): |
| 30 stamp_path = os.path.join(PREBUILT_FILE_PATH, "VERSION") | 30 stamp_path = os.path.join(PREBUILT_FILE_PATH, "VERSION") |
| 31 | 31 |
| 32 version_path = os.path.join(CURRENT_PATH, "../VERSION") | 32 version_path = os.path.join(CURRENT_PATH, version_file) |
| 33 with open(version_path) as version_file: | 33 with open(version_path) as version_file: |
| 34 version = version_file.read().strip() | 34 version = version_file.read().strip() |
| 35 | 35 |
| 36 try: | 36 try: |
| 37 with open(stamp_path) as stamp_file: | 37 with open(stamp_path) as stamp_file: |
| 38 current_version = stamp_file.read().strip() | 38 current_version = stamp_file.read().strip() |
| 39 if current_version == version: | 39 if current_version == version: |
| 40 return 0 # Already have the right version. | 40 return 0 # Already have the right version. |
| 41 except IOError: | 41 except IOError: |
| 42 pass # If the stamp file does not exist we need to download new binaries. | 42 pass # If the stamp file does not exist we need to download new binaries. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 parser = argparse.ArgumentParser(description="Download mojo_shell binaries " | 74 parser = argparse.ArgumentParser(description="Download mojo_shell binaries " |
| 75 "from google storage") | 75 "from google storage") |
| 76 parser.add_argument("--tools-directory", | 76 parser.add_argument("--tools-directory", |
| 77 dest="tools_directory", | 77 dest="tools_directory", |
| 78 metavar="<tools-directory>", | 78 metavar="<tools-directory>", |
| 79 type=str, | 79 type=str, |
| 80 required=True, | 80 required=True, |
| 81 help="Path to the directory containing " | 81 help="Path to the directory containing " |
| 82 "find_depot_tools.py, specified as a relative path " | 82 "find_depot_tools.py, specified as a relative path " |
| 83 "from the location of this file.") | 83 "from the location of this file.") |
| 84 parser.add_argument("--version-file", |
| 85 dest="version_file", |
| 86 metavar="<version-file>", |
| 87 type=str, |
| 88 default="../VERSION", |
| 89 help="Path to the file containing the version of the " |
| 90 "shell to be fetched, specified as a relative path " |
| 91 "from the location of this file (default: " |
| 92 "%(default)s).") |
| 84 args = parser.parse_args() | 93 args = parser.parse_args() |
| 85 return download(args.tools_directory) | 94 return download(args.tools_directory, args.version_file) |
| 86 | 95 |
| 87 if __name__ == "__main__": | 96 if __name__ == "__main__": |
| 88 sys.exit(main()) | 97 sys.exit(main()) |
| OLD | NEW |