• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
5import argparse
6import json
7import os
8import sys
9
10from telemetry.core import util
11
12sys.path.insert(1, os.path.abspath(os.path.join(
13    util.GetCatapultDir(), 'catapult_base')))
14sys.path.insert(1, os.path.abspath(os.path.join(
15    util.GetCatapultDir(), 'dependency_manager')))
16from catapult_base import cloud_storage
17import dependency_manager
18
19
20def 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
38def 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
48if __name__ == '__main__':
49  sys.exit(Main(sys.argv[1:]))
50