From b6f59b09448ef51ff06bf9961a008ab6cf4cb40e Mon Sep 17 00:00:00 2001 From: Shankari Date: Mon, 12 Aug 2024 08:50:46 -0700 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Access=20the=20environm?= =?UTF-8?q?ent=20variables=20from=20the=20config=20using=20`.get`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that we can get a full list of the environment variable by grepping properly ``` $ grep -r 'config.get("[A-Z]' emission/ emission//net/ext_service/push/notify_interface_impl/firebase.py: self.server_auth_token = push_config.get("PUSH_SERVER_AUTH_TOKEN") emission//net/ext_service/push/notify_interface_impl/firebase.py: self.app_package_name = push_config.get("PUSH_APP_PACKAGE_NAME") emission//net/ext_service/push/notify_interface_impl/firebase.py: self.is_fcm_format = push_config.get("PUSH_IOS_TOKEN_FORMAT") == "fcm" emission//net/ext_service/push/notify_interface.py: return NotifyInterfaceFactory.getNotifyInterface(push_config.get("PUSH_PROVIDER")) emission//net/api/cfc_webapp.py:server_port = config.get("WEBSERVER_PORT", 8080) emission//net/api/cfc_webapp.py:socket_timeout = config.get("WEBSERVER_TIMEOUT", 3600) emission//net/api/cfc_webapp.py:auth_method = config.get("WEBSERVER_AUTH", "skip") emission//net/api/cfc_webapp.py:aggregate_call_auth = config.get("WEBSERVER_AGGREGATE_CALL_AUTH", "no_auth") emission//net/api/cfc_webapp.py:not_found_redirect = config.get("WEBSERVER_NOT_FOUND_REDIRECT", "https://nrel.gov/openpath") emission//core/get_database.py:url = config.get("DB_HOST", "localhost") emission//core/get_database.py:result_limit = config.get("DB_RESULT_LIMIT", 250000) ``` --- emission/net/ext_service/push/notify_interface.py | 2 +- .../net/ext_service/push/notify_interface_impl/firebase.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/emission/net/ext_service/push/notify_interface.py b/emission/net/ext_service/push/notify_interface.py index b8080bc74..8363011e1 100644 --- a/emission/net/ext_service/push/notify_interface.py +++ b/emission/net/ext_service/push/notify_interface.py @@ -30,7 +30,7 @@ class NotifyInterfaceFactory(object): @staticmethod def getDefaultNotifyInterface(): - return NotifyInterfaceFactory.getNotifyInterface(push_config["PUSH_PROVIDER"]) + return NotifyInterfaceFactory.getNotifyInterface(push_config.get("PUSH_PROVIDER")) @staticmethod def getNotifyInterface(pushProvider): diff --git a/emission/net/ext_service/push/notify_interface_impl/firebase.py b/emission/net/ext_service/push/notify_interface_impl/firebase.py index 6ce7eb8e3..a33824349 100644 --- a/emission/net/ext_service/push/notify_interface_impl/firebase.py +++ b/emission/net/ext_service/push/notify_interface_impl/firebase.py @@ -21,13 +21,13 @@ def get_interface(push_config): class FirebasePush(pni.NotifyInterface): def __init__(self, push_config): - self.server_auth_token = push_config["PUSH_SERVER_AUTH_TOKEN"] + self.server_auth_token = push_config.get("PUSH_SERVER_AUTH_TOKEN") if "PUSH_APP_PACKAGE_NAME" in push_config: - self.app_package_name = push_config["PUSH_APP_PACKAGE_NAME"] + self.app_package_name = push_config.get("PUSH_APP_PACKAGE_NAME") else: logging.warning("No package name specified, defaulting to embase") self.app_package_name = "edu.berkeley.eecs.embase" - self.is_fcm_format = push_config["PUSH_IOS_TOKEN_FORMAT"] == "fcm" + self.is_fcm_format = push_config.get("PUSH_IOS_TOKEN_FORMAT") == "fcm" def get_and_invalidate_entries(self): # Need to figure out how to do this on firebase