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

Unified Diff: build/android/devil/devil_env.py

Issue 1509493003: [Android] Fix environment variable handling in devil_env. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows-friendly environment initialization Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/adb_command_line.py ('k') | build/android/devil/devil_env_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/devil_env.py
diff --git a/build/android/devil/devil_env.py b/build/android/devil/devil_env.py
index f477b470e892e64406279bba848db41a62352442..8249e53c0aa6745735f87d36c2173610bb88c630 100644
--- a/build/android/devil/devil_env.py
+++ b/build/android/devil/devil_env.py
@@ -47,18 +47,21 @@ _LEGACY_ENVIRONMENT_VARIABLES = {
def _GetEnvironmentVariableConfig():
- env_var_config = {}
- for k, v in _LEGACY_ENVIRONMENT_VARIABLES.iteritems():
- path = os.environ.get(k)
- if path:
- env_var_config[v['dependency_name']] = {
+ path_config = (
+ (os.environ.get(k), v)
+ for k, v in _LEGACY_ENVIRONMENT_VARIABLES.iteritems())
+ return {
+ 'config_type': 'BaseConfig',
+ 'dependencies': {
+ c['dependency_name']: {
'file_info': {
- v['platform']: {
- 'local_paths': [path]
- }
- }
- }
- return env_var_config
+ c['platform']: {
+ 'local_paths': [p],
+ },
+ },
+ } for p, c in path_config if p
+ },
+ }
class _Environment(object):
@@ -100,12 +103,16 @@ class _Environment(object):
# TODO(jbudorick): Remove this recursion if/when dependency_manager
# supports loading configurations directly from a dict.
if configs:
- with tempfile.NamedTemporaryFile() as next_config_file:
- next_config_file.write(json.dumps(configs[0]))
- next_config_file.flush()
- self._InitializeRecursive(
- configs=configs[1:],
- config_files=[next_config_file.name] + (config_files or []))
+ with tempfile.NamedTemporaryFile(delete=False) as next_config_file:
+ try:
+ next_config_file.write(json.dumps(configs[0]))
+ next_config_file.close()
+ self._InitializeRecursive(
+ configs=configs[1:],
+ config_files=[next_config_file.name] + (config_files or []))
+ finally:
+ if os.path.exists(next_config_file.name):
+ os.remove(next_config_file.name)
else:
config_files = config_files or []
if 'DEVIL_ENV_CONFIG' in os.environ:
« no previous file with comments | « build/android/adb_command_line.py ('k') | build/android/devil/devil_env_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698