Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 '''Checks the status of an Android SDK package. | 6 '''Checks the status of an Android SDK package. |
| 7 | 7 |
| 8 Verifies the given package has been installed from the Android SDK Manager and | 8 Verifies the given package has been installed from the Android SDK Manager and |
| 9 that its version is at least the minimum version required by the project | 9 that its version is at least the minimum version required by the project |
| 10 configuration. | 10 configuration. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 parser.add_argument('--package-location', | 55 parser.add_argument('--package-location', |
| 56 help='path to the package\'s expected install location.', | 56 help='path to the package\'s expected install location.', |
| 57 metavar='DIR') | 57 metavar='DIR') |
| 58 parser.add_argument('--stamp', | 58 parser.add_argument('--stamp', |
| 59 help=('if specified, a stamp file will be created at the ' | 59 help=('if specified, a stamp file will be created at the ' |
| 60 'provided location.'), | 60 'provided location.'), |
| 61 metavar='FILE') | 61 metavar='FILE') |
| 62 | 62 |
| 63 args = parser.parse_args() | 63 args = parser.parse_args() |
| 64 | 64 |
| 65 minimum_version = GetRequiredMinimumVersion(args.package_id) | 65 if not ShouldSkipVersionCheck(): |
| 66 CheckPackageVersion(args.package_id, args.package_location, minimum_version) | 66 minimum_version = GetRequiredMinimumVersion(args.package_id) |
| 67 CheckPackageVersion(args.package_id, args.package_location, minimum_version) | |
| 67 | 68 |
| 68 # Create the stamp file. | 69 # Create the stamp file. |
| 69 if args.stamp: | 70 if args.stamp: |
| 70 with open(args.stamp, 'a'): | 71 with open(args.stamp, 'a'): |
| 71 os.utime(args.stamp, None) | 72 os.utime(args.stamp, None) |
| 72 | 73 |
| 73 sys.exit(0) | 74 sys.exit(0) |
| 74 | 75 |
| 75 def ExitError(msg): | 76 def ExitError(msg): |
| 76 sys.exit(colorama.Fore.MAGENTA + colorama.Style.BRIGHT + msg + | 77 sys.exit(colorama.Fore.MAGENTA + colorama.Style.BRIGHT + msg + |
| 77 colorama.Fore.RESET) | 78 colorama.Style.RESET_ALL) |
|
dgn
2015/07/09 15:30:10
Only the color was previously reset, the rest of t
| |
| 78 | 79 |
| 79 | 80 |
| 80 def GetRequiredMinimumVersion(package_id): | 81 def GetRequiredMinimumVersion(package_id): |
| 81 with open(SDK_EXTRAS_JSON_FILE, 'r') as json_file: | 82 with open(SDK_EXTRAS_JSON_FILE, 'r') as json_file: |
| 82 packages = json.load(json_file) | 83 packages = json.load(json_file) |
| 83 | 84 |
| 84 for package in packages: | 85 for package in packages: |
| 85 if package['package_id'] == package_id: | 86 if package['package_id'] == package_id: |
| 86 return int(package['version'].split('.')[0]) | 87 return int(package['version'].split('.')[0]) |
| 87 | 88 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 112 pkg_version = int(match.group('version')) | 113 pkg_version = int(match.group('version')) |
| 113 if pkg_version < minimum_version: | 114 if pkg_version < minimum_version: |
| 114 ExitError(UPDATE_NEEDED_MSG.format( | 115 ExitError(UPDATE_NEEDED_MSG.format( |
| 115 package_id=pkg_id, | 116 package_id=pkg_id, |
| 116 minimum_version=minimum_version, | 117 minimum_version=minimum_version, |
| 117 actual_version=pkg_version, | 118 actual_version=pkg_version, |
| 118 script=UDPATE_SCRIPT_PATH)) | 119 script=UDPATE_SCRIPT_PATH)) |
| 119 | 120 |
| 120 # Everything looks ok, print nothing. | 121 # Everything looks ok, print nothing. |
| 121 | 122 |
| 123 def ShouldSkipVersionCheck(): | |
| 124 ''' | |
| 125 Bots should not run the version check, since they download the sdk extras | |
| 126 in a different way. | |
| 127 ''' | |
| 128 return bool(os.environ.get('CHROME_HEADLESS')) | |
| 122 | 129 |
| 123 if __name__ == '__main__': | 130 if __name__ == '__main__': |
| 124 main() | 131 main() |
| OLD | NEW |