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