Replace direct access of os.environ with getenv()

This commit is contained in:
Ryan Ahearn
2022-11-01 11:42:14 -04:00
parent b4256d0a6c
commit 6868daad90
2 changed files with 46 additions and 46 deletions

View File

@@ -1,10 +1,10 @@
import json
import os
from os import getenv
class CloudfoundryConfig:
def __init__(self):
self.parsed_services = json.loads(os.environ.get('VCAP_SERVICES') or '{}')
self.parsed_services = json.loads(getenv('VCAP_SERVICES') or '{}')
buckets = self.parsed_services.get('s3') or []
self.s3_buckets = {bucket['name']: bucket['credentials'] for bucket in buckets}
self._empty_bucket_credentials = {
@@ -16,7 +16,7 @@ class CloudfoundryConfig:
@property
def database_url(self):
return os.environ.get('DATABASE_URL', '').replace('postgres://', 'postgresql://')
return getenv('DATABASE_URL', '').replace('postgres://', 'postgresql://')
@property
def redis_url(self):
@@ -26,7 +26,7 @@ class CloudfoundryConfig:
'rediss://'
)
except KeyError:
return os.environ.get('REDIS_URL')
return getenv('REDIS_URL')
def s3_credentials(self, service_name):
return self.s3_buckets.get(service_name) or self._empty_bucket_credentials