| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 '''A simple tool to update the Native Client SDK to the latest version''' | 6 '''A simple tool to update the Native Client SDK to the latest version''' |
| 7 | 7 |
| 8 import cStringIO | 8 import cStringIO |
| 9 import cygtar | 9 import cygtar |
| 10 import json | 10 import json |
| 11 import manifest_util | 11 import manifest_util |
| 12 import optparse | 12 import optparse |
| 13 import os | 13 import os |
| 14 from sdk_update_common import * | 14 from sdk_update_common import RenameDir, RemoveDir, Error |
| 15 import shutil | 15 import shutil |
| 16 import subprocess | 16 import subprocess |
| 17 import sys | 17 import sys |
| 18 import tempfile | 18 import tempfile |
| 19 # when pylint runs the third_party module is the one from depot_tools |
| 20 # pylint: disable=E0611 |
| 19 from third_party import fancy_urllib | 21 from third_party import fancy_urllib |
| 20 import urllib2 | 22 import urllib2 |
| 21 import urlparse | 23 import urlparse |
| 22 | 24 |
| 25 # pylint: disable=C0301 |
| 23 | 26 |
| 24 #------------------------------------------------------------------------------ | 27 #------------------------------------------------------------------------------ |
| 25 # Constants | 28 # Constants |
| 26 | 29 |
| 27 # This revision number is autogenerated from the Chrome revision. | 30 # This revision number is autogenerated from the Chrome revision. |
| 28 REVISION = '{REVISION}' | 31 REVISION = '{REVISION}' |
| 29 | 32 |
| 30 GLOBAL_HELP = '''Usage: naclsdk [options] command [command_options] | 33 GLOBAL_HELP = '''Usage: naclsdk [options] command [command_options] |
| 31 | 34 |
| 32 naclsdk is a simple utility that updates the Native Client (NaCl) | 35 naclsdk is a simple utility that updates the Native Client (NaCl) |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 scheme != 'https' or | 296 scheme != 'https' or |
| 294 not path.startswith('/nativeclient-mirror/nacl/nacl_sdk')): | 297 not path.startswith('/nativeclient-mirror/nacl/nacl_sdk')): |
| 295 WarningPrint('Only whitelisted sources from ' | 298 WarningPrint('Only whitelisted sources from ' |
| 296 '\'https://commondatastorage.googleapis.com/nativeclient-' | 299 '\'https://commondatastorage.googleapis.com/nativeclient-' |
| 297 'mirror/nacl/nacl_sdk\' are currently allowed.') | 300 'mirror/nacl/nacl_sdk\' are currently allowed.') |
| 298 return | 301 return |
| 299 if string in self._data['sources']: | 302 if string in self._data['sources']: |
| 300 WarningPrint('source \''+string+'\' already exists in config.') | 303 WarningPrint('source \''+string+'\' already exists in config.') |
| 301 return | 304 return |
| 302 try: | 305 try: |
| 303 url_stream = UrlOpen(string) | 306 UrlOpen(string) |
| 304 except urllib2.URLError: | 307 except urllib2.URLError: |
| 305 WarningPrint('Unable to fetch manifest URL \'%s\'. Exiting...' % string) | 308 WarningPrint('Unable to fetch manifest URL \'%s\'. Exiting...' % string) |
| 306 return | 309 return |
| 307 | 310 |
| 308 self._data['sources'].append(string) | 311 self._data['sources'].append(string) |
| 309 InfoPrint('source \''+string+'\' added to config.') | 312 InfoPrint('source \''+string+'\' added to config.') |
| 310 | 313 |
| 311 def RemoveSource(self, string): | 314 def RemoveSource(self, string): |
| 312 '''Remove a source file to load packages from. | 315 '''Remove a source file to load packages from. |
| 313 | 316 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 367 |
| 365 | 368 |
| 366 def Info(options, argv, config): | 369 def Info(options, argv, config): |
| 367 '''Usage: %prof [global_options] info [options] bundle_names... | 370 '''Usage: %prof [global_options] info [options] bundle_names... |
| 368 | 371 |
| 369 Displays information about a SDK bundle.''' | 372 Displays information about a SDK bundle.''' |
| 370 | 373 |
| 371 DebugPrint("Running List command with: %s, %s" %(options, argv)) | 374 DebugPrint("Running List command with: %s, %s" %(options, argv)) |
| 372 | 375 |
| 373 parser = optparse.OptionParser(usage=Info.__doc__) | 376 parser = optparse.OptionParser(usage=Info.__doc__) |
| 374 (info_options, args) = parser.parse_args(argv) | 377 (_, args) = parser.parse_args(argv) |
| 375 | 378 |
| 376 if not args: | 379 if not args: |
| 377 parser.print_help() | 380 parser.print_help() |
| 378 return | 381 return |
| 379 | 382 |
| 380 manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources()) | 383 manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources()) |
| 381 valid_bundles = [bundle.name for bundle in manifest.GetBundles()] | 384 valid_bundles = [bundle.name for bundle in manifest.GetBundles()] |
| 382 valid_args = set(args) & set(valid_bundles) | 385 valid_args = set(args) & set(valid_bundles) |
| 383 invalid_args = set(args) - valid_args | 386 invalid_args = set(args) - valid_args |
| 384 if invalid_args: | 387 if invalid_args: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 revision)) | 432 revision)) |
| 430 | 433 |
| 431 | 434 |
| 432 DebugPrint("Running List command with: %s, %s" %(options, argv)) | 435 DebugPrint("Running List command with: %s, %s" %(options, argv)) |
| 433 | 436 |
| 434 parser = optparse.OptionParser(usage=List.__doc__) | 437 parser = optparse.OptionParser(usage=List.__doc__) |
| 435 parser.add_option( | 438 parser.add_option( |
| 436 '-r', '--revision', dest='revision', | 439 '-r', '--revision', dest='revision', |
| 437 default=False, action='store_true', | 440 default=False, action='store_true', |
| 438 help='display revision numbers') | 441 help='display revision numbers') |
| 439 (list_options, args) = parser.parse_args(argv) | 442 (list_options, _) = parser.parse_args(argv) |
| 440 | 443 |
| 441 manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources()) | 444 manifest = LoadManifestFromURLs([options.manifest_url] + config.GetSources()) |
| 442 manifest_path = os.path.join(options.user_data_dir, options.manifest_filename) | 445 manifest_path = os.path.join(options.user_data_dir, options.manifest_filename) |
| 443 local_manifest = LoadFromFile(manifest_path, manifest_util.SDKManifest()) | 446 local_manifest = LoadFromFile(manifest_path, manifest_util.SDKManifest()) |
| 444 | 447 |
| 445 any_bundles_need_update = False | 448 any_bundles_need_update = False |
| 446 InfoPrint('Bundles:') | 449 InfoPrint('Bundles:') |
| 447 InfoPrint(' I: installed\n *: update available\n') | 450 InfoPrint(' I: installed\n *: update available\n') |
| 448 for bundle in manifest.GetBundles(): | 451 for bundle in manifest.GetBundles(): |
| 449 local_bundle = local_manifest.GetBundle(bundle.name) | 452 local_bundle = local_manifest.GetBundle(bundle.name) |
| 450 installed = local_bundle is not None | |
| 451 needs_update = local_bundle and local_manifest.BundleNeedsUpdate(bundle) | 453 needs_update = local_bundle and local_manifest.BundleNeedsUpdate(bundle) |
| 452 if needs_update: | 454 if needs_update: |
| 453 any_bundles_need_update = True | 455 any_bundles_need_update = True |
| 454 | 456 |
| 455 PrintBundle(local_bundle, bundle, needs_update, list_options.revision) | 457 PrintBundle(local_bundle, bundle, needs_update, list_options.revision) |
| 456 | 458 |
| 457 if not any_bundles_need_update: | 459 if not any_bundles_need_update: |
| 458 InfoPrint('\nAll installed bundles are up-to-date.') | 460 InfoPrint('\nAll installed bundles are up-to-date.') |
| 459 | 461 |
| 460 local_only_bundles = set([b.name for b in local_manifest.GetBundles()]) | 462 local_only_bundles = set([b.name for b in local_manifest.GetBundles()]) |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 | 749 |
| 748 return 0 # Success | 750 return 0 # Success |
| 749 | 751 |
| 750 | 752 |
| 751 if __name__ == '__main__': | 753 if __name__ == '__main__': |
| 752 try: | 754 try: |
| 753 sys.exit(main(sys.argv[1:])) | 755 sys.exit(main(sys.argv[1:])) |
| 754 except Error as error: | 756 except Error as error: |
| 755 print "Error: %s" % error | 757 print "Error: %s" % error |
| 756 sys.exit(1) | 758 sys.exit(1) |
| OLD | NEW |