-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple apps use the same basic configuration information, so this seems reasonable.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |