Update as per pull request comments:

- context manager for file handling
- os.environ.update for setting overrides
This commit is contained in:
Martyn Inglis
2016-03-17 12:51:14 +00:00
parent 9a7788a6f5
commit 6aec6a0bda
2 changed files with 6 additions and 11 deletions

View File

@@ -8,13 +8,11 @@ default_env_file = '/home/ubuntu/environment'
environment = 'live'
if os.path.isfile(default_env_file):
environment_file = open(default_env_file, 'r')
with open(default_env_file, 'r') as environment_file:
environment = environment_file.readline().strip()
# on aws get secrets and export to env
secrets = getAllSecrets(region="eu-west-1")
for key, val in secrets.items():
os.environ[key] = val
os.environ.update(getAllSecrets(region="eu-west-1"))
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]

View File

@@ -9,14 +9,11 @@ default_env_file = '/home/ubuntu/environment'
environment = 'live'
if os.path.isfile(default_env_file):
environment_file = open(default_env_file, 'r')
with open(default_env_file, 'r') as environment_file:
environment = environment_file.readline().strip()
# on aws get secrets and export to env
secrets = getAllSecrets(region="eu-west-1")
for key, val in secrets.items():
os.environ[key] = val
os.environ.update(getAllSecrets(region="eu-west-1"))
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]
application = create_app()