From 5861805dd4259ff6d6ada836e6217f4f87dbc87a Mon Sep 17 00:00:00 2001 From: Daniel Petti Date: Mon, 10 Aug 2015 09:56:00 -0700 Subject: [PATCH] Add config.py file to shared. Multiple apps use the same basic configuration information, so this seems reasonable. --- config.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..ed11806 --- /dev/null +++ b/config.py @@ -0,0 +1,38 @@ +import logging +import os + +from google.appengine.api import app_identity + + +""" Class for storing specific configuration parameters. """ +class Config(object): + # Mutually exclusive flags that specify whether the application is running on + # hd-events-hrd, dev_appserver, or local unit tests. + is_dev = False + is_prod = True + is_testing = False; + + def __init__(self): + try: + # Check if we are running on the local dev server. + software = os.environ["SERVER_SOFTWARE"] + Config.is_dev = software.startswith("Dev") and "testbed" not in software + except KeyError: + pass + + try: + self.APP_NAME = app_identity.get_application_id() + except AttributeError: + # We're calling code outside of GAE, so we must be testing. + self.APP_NAME = "testbed-test" + if self.APP_NAME == "testbed-test": + Config.is_testing = True + + Config.is_prod = not (Config.is_dev or Config.is_testing) + + if Config.is_testing: + logging.debug("Is testing.") + elif Config.is_dev: + logging.debug("Is dev server.") + else: + logging.debug("Is production server.")