validate_binary_dependencies 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  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
  4. # found in the LICENSE file.
  5. import argparse
  6. import json
  7. import os
  8. import sys
  9. from telemetry.core import util
  10. sys.path.insert(1, os.path.abspath(os.path.join(
  11. util.GetCatapultDir(), 'common', 'py_utils')))
  12. sys.path.insert(1, os.path.abspath(os.path.join(
  13. util.GetCatapultDir(), 'dependency_manager')))
  14. from py_utils import cloud_storage
  15. import dependency_manager
  16. def ValidateCloudStorageDependencies(file_path):
  17. base_config = dependency_manager.BaseConfig(file_path)
  18. cloud_storage_deps_not_exist = []
  19. for dep_info in base_config.IterDependencyInfo():
  20. if dep_info.has_cloud_storage_info:
  21. if not dep_info.cloud_storage_info.DependencyExistsInCloudStorage():
  22. print >> sys.stderr, (
  23. '%s does not exist in cloud storage' % dep_info.cloud_storage_info)
  24. cloud_storage_deps_not_exist = True
  25. else:
  26. print >> sys.stdout, (
  27. '%s passes cloud storage validation' % dep_info.dependency)
  28. if cloud_storage_deps_not_exist:
  29. raise Exception(
  30. "Some dependencies specify cloud storage locations that don't exist.")
  31. def Main(args):
  32. parser = argparse.ArgumentParser(
  33. description='Validate the dependencies in a binary dependency json file')
  34. parser.add_argument('file_path', type=str,
  35. help='The path to binary dependency json file')
  36. options = parser.parse_args(args)
  37. ValidateCloudStorageDependencies(options.file_path)
  38. return 0
  39. if __name__ == '__main__':
  40. sys.exit(Main(sys.argv[1:]))