Created
August 6, 2013 00:59
-
-
Save kr/6161118 to your computer and use it in GitHub Desktop.
convert a json dictionary into environment variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# jsonenv reads a json object as input and produces | |
# escaped shell commands for setting environment vars | |
import json | |
import pipes | |
import sys | |
for k, v in json.load(sys.stdin).items(): | |
k = pipes.quote(k) | |
v = pipes.quote(v) | |
print "%s=%s export %s;" % (k, v, k) |
this should work without the need to paste code into cmdline again:
for k, v in json.load(open('local.settings.json')).items():
os.environ[k] = v
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks