OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 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 """This module fetches and prints the dependencies given a benchmark.""" | 6 """This module fetches and prints the dependencies given a benchmark.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'telemetry')) | 11 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, 'telemetry')) |
12 | 12 |
13 from catapult_base import cloud_storage | 13 from catapult_base import cloud_storage |
14 from telemetry import benchmark_runner | 14 from telemetry import benchmark_runner |
15 | 15 |
16 | 16 |
17 def _GetPerfDir(*subdirs): | 17 def _GetPerfDir(*subdirs): |
aiolos (Not reviewing)
2015/10/13 13:40:15
These functions are in path_util now. It might be
eakuefner
2016/01/06 23:15:19
Done. Also, I have added path_util.GetPerfClientCo
| |
18 perf_dir = os.path.realpath(os.path.dirname(__file__)) | 18 perf_dir = os.path.realpath(os.path.dirname(__file__)) |
19 return os.path.join(perf_dir, *subdirs) | 19 return os.path.join(perf_dir, *subdirs) |
20 | 20 |
21 | 21 |
22 def GetChromiumDir(): | 22 def GetChromiumDir(): |
23 return _GetPerfDir(os.path.pardir, os.path.pardir, os.path.pardir) | 23 return _GetPerfDir(os.path.pardir, os.path.pardir, os.path.pardir) |
24 | 24 |
25 | 25 |
26 def _FetchDependenciesIfNeeded(story_set): | 26 def _FetchDependenciesIfNeeded(story_set): |
27 """ Download files needed by a user story set. """ | 27 """ Download files needed by a user story set. """ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 prefix_len = len(os.path.realpath(GetChromiumDir())) + 1 | 60 prefix_len = len(os.path.realpath(GetChromiumDir())) + 1 |
61 return [dep[prefix_len:] for dep in deps if dep] | 61 return [dep[prefix_len:] for dep in deps if dep] |
62 | 62 |
63 | 63 |
64 def _show_usage(): | 64 def _show_usage(): |
65 print ('Usage: %s benchmark_name\n' | 65 print ('Usage: %s benchmark_name\n' |
66 'Fetch the dependencies of benchmark_name.' % sys.argv[0]) | 66 'Fetch the dependencies of benchmark_name.' % sys.argv[0]) |
67 | 67 |
68 | 68 |
69 def main(output=sys.stdout): | 69 def main(output=sys.stdout): |
70 top_level_dir = _GetPerfDir() | |
70 config = benchmark_runner.ProjectConfig( | 71 config = benchmark_runner.ProjectConfig( |
71 top_level_dir=_GetPerfDir(), | 72 top_level_dir=top_level_dir, |
72 benchmark_dirs=[_GetPerfDir('benchmarks')]) | 73 benchmark_dirs=[_GetPerfDir('benchmarks')], |
74 client_config=os.path.abspath(os.path.join( | |
75 top_level_dir, 'core', 'binary_dependencies.json'))) | |
73 | 76 |
74 name = sys.argv[1] | 77 name = sys.argv[1] |
75 benchmark = benchmark_runner.GetBenchmarkByName(name, config) | 78 benchmark = benchmark_runner.GetBenchmarkByName(name, config) |
76 if not benchmark: | 79 if not benchmark: |
77 raise ValueError('No such benchmark: %s' % name) | 80 raise ValueError('No such benchmark: %s' % name) |
78 | 81 |
79 # Download files according to specified benchmark. | 82 # Download files according to specified benchmark. |
80 story_set = benchmark().CreateStorySet(None) | 83 story_set = benchmark().CreateStorySet(None) |
81 | 84 |
82 _FetchDependenciesIfNeeded(story_set) | 85 _FetchDependenciesIfNeeded(story_set) |
83 | 86 |
84 # Print files downloaded. | 87 # Print files downloaded. |
85 deps = _EnumerateDependencies(story_set) | 88 deps = _EnumerateDependencies(story_set) |
86 for dep in deps: | 89 for dep in deps: |
87 print >> output, dep | 90 print >> output, dep |
88 | 91 |
89 | 92 |
90 if __name__ == '__main__': | 93 if __name__ == '__main__': |
91 if len(sys.argv) != 2 or sys.argv[1][0] == '-': | 94 if len(sys.argv) != 2 or sys.argv[1][0] == '-': |
92 _show_usage() | 95 _show_usage() |
93 else: | 96 else: |
94 main() | 97 main() |
OLD | NEW |