Skip to content

Commit

Permalink
Add config.py file to shared.
Browse files Browse the repository at this point in the history
Multiple apps use the same basic configuration information, so
this seems reasonable.
  • Loading branch information
djpetti committed Aug 10, 2015
1 parent e988bcb commit 5861805
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -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.")

0 comments on commit 5861805

Please sign in to comment.