Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 #TODO(aiolos): Remove the debug logging once the entire Dependency Manager | |
| 6 #system has landed. | |
| 7 import logging | |
| 8 import os | |
| 9 | |
| 5 from catapult_base import support_binaries | 10 from catapult_base import support_binaries |
| 11 from catapult_base import dependency_manager | |
| 12 from telemetry.core import util | |
| 6 | 13 |
| 7 | 14 |
| 15 class InitializationError(Exception): | |
| 16 def __init__(self, string): | |
| 17 super(InitializationError, self).__init__(string) | |
| 18 | |
| 19 | |
| 20 TELEMETRY_PROJECT_CONFIG = os.path.join( | |
| 21 util.GetTelemetryDir(), 'telemetry', 'internal', 'binary_dependencies.json') | |
|
nednguyen
2015/08/10 17:01:10
Did you already add this file?
aiolos (Not reviewing)
2015/08/10 20:37:27
Not yet. We don't actually do anything with the fi
| |
| 22 | |
| 23 _dependency_manager = None | |
| 24 | |
| 25 def InitDependencyManagerForUnittests(): | |
| 26 if not _dependency_manager: | |
| 27 InitDependencyManager(None) | |
| 28 | |
| 29 def InitDependencyManager(environment_config): | |
|
eakuefner
2015/08/10 17:07:03
nit: two newlines between top-level definitions.
aiolos (Not reviewing)
2015/08/10 20:37:27
Done.
| |
| 30 global _dependency_manager | |
| 31 if _dependency_manager: | |
| 32 raise InitializationError('Trying to re-initialize the binary manager with ' | |
| 33 'config %s' % environment_config) | |
| 34 config_files = [TELEMETRY_PROJECT_CONFIG] | |
| 35 if environment_config: | |
| 36 config_files.append(environment_config) | |
| 37 _dependency_manager = dependency_manager.DependencyManager(config_files) | |
| 38 logging.debug('Initialized the dependency manager.') | |
|
nednguyen
2015/08/10 17:01:10
This log should come before the dependency_manager
aiolos (Not reviewing)
2015/08/10 20:37:27
That's actually why I wanted it after. I've cared
| |
| 39 | |
| 8 def FetchPath(binary_name, platform, arch): | 40 def FetchPath(binary_name, platform, arch): |
| 9 """ Return a path to the appropriate executable for <binary_name>, downloading | 41 """ Return a path to the appropriate executable for <binary_name>, downloading |
| 10 from cloud storage if needed, or None if it cannot be found. | 42 from cloud storage if needed, or None if it cannot be found. |
| 11 """ | 43 """ |
| 44 logging.debug('Called FetchPath for binary: %s on platform: %s and arch: ' | |
| 45 '%s' % (binary_name, platform, arch)) | |
| 46 if _dependency_manager is None: | |
| 47 raise InitializationError( | |
| 48 'Called FetchPath with uninitialized binary manager.') | |
| 12 return support_binaries.FindPath(binary_name, platform, arch) | 49 return support_binaries.FindPath(binary_name, platform, arch) |
| 13 | 50 |
| 14 def LocalPath(binary_name, platform, arch): | 51 def LocalPath(binary_name, platform, arch): |
| 15 """ Return a local path to the given binary name, or None if an executable | 52 """ Return a local path to the given binary name, or None if an executable |
| 16 cannot be found. Will not download the executable. | 53 cannot be found. Will not download the executable. |
| 17 """ | 54 """ |
| 55 logging.debug('Called LocalPath for binary: %s on platform: %s and arch: ' | |
| 56 '%s' % (binary_name, platform, arch)) | |
| 57 if _dependency_manager is None: | |
| 58 raise InitializationError( | |
| 59 'Called LocalPath with uninitialized binary manager.') | |
| 18 del platform, arch | 60 del platform, arch |
| 19 return support_binaries.FindLocallyBuiltPath(binary_name) | 61 return support_binaries.FindLocallyBuiltPath(binary_name) |
| OLD | NEW |