diff options
Diffstat (limited to 'catapult/devil/devil/devil_env.py')
-rw-r--r-- | catapult/devil/devil/devil_env.py | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/catapult/devil/devil/devil_env.py b/catapult/devil/devil/devil_env.py index aa4fe1ee..b39e01c8 100644 --- a/catapult/devil/devil/devil_env.py +++ b/catapult/devil/devil/devil_env.py @@ -11,12 +11,10 @@ import sys import tempfile import threading -CATAPULT_ROOT_PATH = os.path.abspath(os.path.join( - os.path.dirname(__file__), '..', '..')) -DEPENDENCY_MANAGER_PATH = os.path.join( - CATAPULT_ROOT_PATH, 'dependency_manager') -PYMOCK_PATH = os.path.join( - CATAPULT_ROOT_PATH, 'third_party', 'mock') +CATAPULT_ROOT_PATH = os.path.abspath( + os.path.join(os.path.dirname(__file__), '..', '..')) +DEPENDENCY_MANAGER_PATH = os.path.join(CATAPULT_ROOT_PATH, 'dependency_manager') +PYMOCK_PATH = os.path.join(CATAPULT_ROOT_PATH, 'third_party', 'mock') @contextlib.contextmanager @@ -28,52 +26,49 @@ def SysPath(path): else: sys.path.pop() + with SysPath(DEPENDENCY_MANAGER_PATH): import dependency_manager # pylint: disable=import-error _ANDROID_BUILD_TOOLS = {'aapt', 'dexdump', 'split-select'} -_DEVIL_DEFAULT_CONFIG = os.path.abspath(os.path.join( - os.path.dirname(__file__), 'devil_dependencies.json')) +_DEVIL_DEFAULT_CONFIG = os.path.abspath( + os.path.join(os.path.dirname(__file__), 'devil_dependencies.json')) _LEGACY_ENVIRONMENT_VARIABLES = { - 'ADB_PATH': { - 'dependency_name': 'adb', - 'platform': 'linux2_x86_64', - }, - 'ANDROID_SDK_ROOT': { - 'dependency_name': 'android_sdk', - 'platform': 'linux2_x86_64', - }, + 'ADB_PATH': { + 'dependency_name': 'adb', + 'platform': 'linux2_x86_64', + }, + 'ANDROID_SDK_ROOT': { + 'dependency_name': 'android_sdk', + 'platform': 'linux2_x86_64', + }, } def EmptyConfig(): - return { - 'config_type': 'BaseConfig', - 'dependencies': {} - } + return {'config_type': 'BaseConfig', 'dependencies': {}} def LocalConfigItem(dependency_name, dependency_platform, dependency_path): if isinstance(dependency_path, basestring): dependency_path = [dependency_path] return { - dependency_name: { - 'file_info': { - dependency_platform: { - 'local_paths': dependency_path - }, + dependency_name: { + 'file_info': { + dependency_platform: { + 'local_paths': dependency_path + }, + }, }, - }, } def _GetEnvironmentVariableConfig(): env_config = EmptyConfig() - path_config = ( - (os.environ.get(k), v) - for k, v in _LEGACY_ENVIRONMENT_VARIABLES.iteritems()) + path_config = ((os.environ.get(k), v) + for k, v in _LEGACY_ENVIRONMENT_VARIABLES.iteritems()) path_config = ((p, c) for p, c in path_config if p) for p, c in path_config: env_config['dependencies'].update( @@ -82,7 +77,6 @@ def _GetEnvironmentVariableConfig(): class _Environment(object): - def __init__(self): self._dm_init_lock = threading.Lock() self._dm = None @@ -111,9 +105,7 @@ class _Environment(object): env_config = _GetEnvironmentVariableConfig() if env_config: configs.insert(0, env_config) - self._InitializeRecursive( - configs=configs, - config_files=config_files) + self._InitializeRecursive(configs=configs, config_files=config_files) assert self._dm is not None, 'Failed to create dependency manager.' def _InitializeRecursive(self, configs=None, config_files=None): @@ -191,4 +183,3 @@ def GetPlatform(arch=None, device=None): config = _Environment() - |