Index: tools/telemetry/telemetry/internal/util/binary_manager.py |
diff --git a/tools/telemetry/telemetry/internal/util/binary_manager.py b/tools/telemetry/telemetry/internal/util/binary_manager.py |
index bfa2c2c014916d81503a7d6fde30ff064543222f..c661e04a69c5ed914568c882accafdb1946b3873 100644 |
--- a/tools/telemetry/telemetry/internal/util/binary_manager.py |
+++ b/tools/telemetry/telemetry/internal/util/binary_manager.py |
@@ -2,18 +2,60 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+#TODO(aiolos): Remove the debug logging once the entire Dependency Manager |
+#system has landed. |
+import logging |
+import os |
+ |
from catapult_base import support_binaries |
+from catapult_base import dependency_manager |
+from telemetry.core import util |
+ |
+ |
+class InitializationError(Exception): |
+ def __init__(self, string): |
+ super(InitializationError, self).__init__(string) |
+ |
+ |
+TELEMETRY_PROJECT_CONFIG = os.path.join( |
+ 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
|
+ |
+_dependency_manager = None |
+ |
+def InitDependencyManagerForUnittests(): |
+ if not _dependency_manager: |
+ InitDependencyManager(None) |
+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.
|
+ global _dependency_manager |
+ if _dependency_manager: |
+ raise InitializationError('Trying to re-initialize the binary manager with ' |
+ 'config %s' % environment_config) |
+ config_files = [TELEMETRY_PROJECT_CONFIG] |
+ if environment_config: |
+ config_files.append(environment_config) |
+ _dependency_manager = dependency_manager.DependencyManager(config_files) |
+ 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
|
def FetchPath(binary_name, platform, arch): |
""" Return a path to the appropriate executable for <binary_name>, downloading |
from cloud storage if needed, or None if it cannot be found. |
""" |
+ logging.debug('Called FetchPath for binary: %s on platform: %s and arch: ' |
+ '%s' % (binary_name, platform, arch)) |
+ if _dependency_manager is None: |
+ raise InitializationError( |
+ 'Called FetchPath with uninitialized binary manager.') |
return support_binaries.FindPath(binary_name, platform, arch) |
def LocalPath(binary_name, platform, arch): |
""" Return a local path to the given binary name, or None if an executable |
cannot be found. Will not download the executable. |
""" |
+ logging.debug('Called LocalPath for binary: %s on platform: %s and arch: ' |
+ '%s' % (binary_name, platform, arch)) |
+ if _dependency_manager is None: |
+ raise InitializationError( |
+ 'Called LocalPath with uninitialized binary manager.') |
del platform, arch |
return support_binaries.FindLocallyBuiltPath(binary_name) |