Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: tools/telemetry/telemetry/internal/util/binary_manager.py

Issue 1280903003: Add dependency_manager initialization to binary_manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and refactor the unittest. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 exceptions
13 from telemetry.core import util
14
15
16 TELEMETRY_PROJECT_CONFIG = os.path.join(
17 util.GetTelemetryDir(), 'telemetry', 'internal', 'binary_dependencies.json')
18
19
20 _dependency_manager = None
21
22
23 def NeedsInit():
24 return not _dependency_manager
25
26
27 def InitDependencyManager(environment_config):
28 global _dependency_manager
29 if _dependency_manager:
30 raise exceptions.InitializationError(
31 'Trying to re-initialize the binary manager with config %s'
32 % environment_config)
33 config_files = [TELEMETRY_PROJECT_CONFIG]
34 if environment_config:
35 config_files.append(environment_config)
36 logging.debug('Initializing the dependency manager with config files: %s.'
37 % config_files)
38 _dependency_manager = dependency_manager.DependencyManager(config_files)
39 logging.debug('Successfully initialized the dependency manager.')
6 40
7 41
8 def FetchPath(binary_name, platform, arch): 42 def FetchPath(binary_name, platform, arch):
9 """ Return a path to the appropriate executable for <binary_name>, downloading 43 """ Return a path to the appropriate executable for <binary_name>, downloading
10 from cloud storage if needed, or None if it cannot be found. 44 from cloud storage if needed, or None if it cannot be found.
11 """ 45 """
46 logging.debug('Called FetchPath for binary: %s on platform: %s and arch: %s'
47 % (binary_name, platform, arch))
48 if _dependency_manager is None:
49 raise exceptions.InitializationError(
50 'Called FetchPath with uninitialized binary manager.')
12 return support_binaries.FindPath(binary_name, platform, arch) 51 return support_binaries.FindPath(binary_name, platform, arch)
13 52
53
14 def LocalPath(binary_name, platform, arch): 54 def LocalPath(binary_name, platform, arch):
15 """ Return a local path to the given binary name, or None if an executable 55 """ Return a local path to the given binary name, or None if an executable
16 cannot be found. Will not download the executable. 56 cannot be found. Will not download the executable.
17 """ 57 """
58 logging.debug('Called LocalPath for binary: %s on platform: %s and arch: '
59 '%s' % (binary_name, platform, arch))
60 if _dependency_manager is None:
61 raise exceptions.InitializationError(
62 'Called LocalPath with uninitialized binary manager.')
18 del platform, arch 63 del platform, arch
19 return support_binaries.FindLocallyBuiltPath(binary_name) 64 return support_binaries.FindLocallyBuiltPath(binary_name)
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/core/exceptions.py ('k') | tools/telemetry/telemetry/internal/util/binary_manager_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698