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

Unified Diff: build/env_dump.py

Issue 24195006: Dump only salient differences from env_dump.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/env_dump.py
diff --git a/build/env_dump.py b/build/env_dump.py
index d6a18c83224cf1d142c1b50b3135b6c056e9fdc4..1534b377bd63c80b9763d29c167a6162bafd0403 100755
--- a/build/env_dump.py
+++ b/build/env_dump.py
@@ -20,7 +20,7 @@ def main():
help='File to dump the environment as JSON into.')
parser.add_option(
'-d', '--dump-mode', action='store_true',
- help='Dump the environment to the file and exit immediately.')
+ help='Dump the environment to sys.stdout and exit immediately.')
iannucci 2013/09/18 00:55:37 just 'stdout' in help string :)
options, args = parser.parse_args()
if not options.output_json:
@@ -29,8 +29,7 @@ def main():
if options.dump_mode:
iannucci 2013/09/18 00:55:37 we should make it an error to pass options.output_
if args:
parser.error("Cannot specify args with --dump-mode")
- with open(options.output_json, 'w') as f:
- json.dump(dict(os.environ), f)
+ json.dump(dict(os.environ), sys.stdout)
else:
envsetup_cmd = ' '.join(map(pipes.quote, args))
full_cmd = [
@@ -38,9 +37,19 @@ def main():
'. %s; %s -d -f %s' % (envsetup_cmd, os.path.abspath(__file__),
iannucci 2013/09/18 00:55:37 I don't think we need to pass -f any more, since i
options.output_json)
]
- ret = subprocess.call(full_cmd)
- if ret:
- sys.exit('Error running %s and dumping env' % envsetup_cmd)
+ try:
+ output = subprocess.check_output(full_cmd)
+ except Exception as e:
+ sys.exit('Error running % and dumping environment.' % envsetup_cmd)
iannucci 2013/09/18 00:55:37 missing %s
+
+ env_diff = {}
+ new_env = json.loads(output)
+ for k, val in new_env.items():
+ if k == '_' or (k in os.environ and os.environ[k] == val):
+ continue
+ env_diff[k] = val
+ with open(options.output_json, 'w') as f:
+ json.dump(env_diff, f)
if __name__ == '__main__':
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698