'''Pull all the default settings and then all overrides.

Created on Aug 19, 2010

@author: jnaous
'''
import sys, traceback

from expedient.clearinghouse.defaultsettings.django import *
from expedient.clearinghouse.defaultsettings.database import *
from expedient.clearinghouse.defaultsettings.admins import *
from expedient.clearinghouse.defaultsettings.email import *
from expedient.clearinghouse.defaultsettings.expedient import *
from expedient.clearinghouse.defaultsettings.logging import *
from expedient.clearinghouse.defaultsettings.gcf import *
from expedient.clearinghouse.defaultsettings.messaging import *
from expedient.clearinghouse.defaultsettings.openflow import *
from expedient.clearinghouse.defaultsettings.site import *
from expedient.clearinghouse.defaultsettings.xmlrpc import *
from expedient.clearinghouse.defaultsettings.openflowtests import *
from expedient.clearinghouse.defaultsettings.tests import *
# Add new default settings here

# Import the list of required variables
from expedient.clearinghouse.defaultsettings.required import REQUIRED_SETTINGS

# Delete all the default required settings
_modname = globals()['__name__']
_this_mod = sys.modules[_modname]
for item in REQUIRED_SETTINGS:
    for var in item[1]:
        delattr(_this_mod, var)
        
# Try getting importing the secret key from a secret_key module
try:
    from secret_key import SECRET_KEY
except ImportError:
    traceback.print_exc()
    print(
        "Error importing secret_key module. Using default insecure key."
        "Please run the 'create_secret_key' manage.py command to create "
        "a new secret key. Do this only after setting up your local settings."
    )

# Now import the local settings
from localsettings import *

# check that all the required settings are set
for item in REQUIRED_SETTINGS:
    for var in item[1]:
        if not hasattr(_this_mod, var):
            raise Exception(
                "Missing required setting %s. See the "
                "documentation for this setting at "
                "expedient.clearinghouse.defaultsettings.%s"
                % (var, item[0])
            )

# Logging
from expedient.common import loggingconf
import logging
if DEBUG:
    loggingconf.set_up(logging.DEBUG, LOGGING_LEVELS)
else:
    loggingconf.set_up(logging.INFO, LOGGING_LEVELS)

@@ -1080,214 +1080,8 @@
 GS%0A%0A
-# Delete all the default required settings%0A_modname = globals()%5B'__name__'%5D%0A_this_mod = sys.modules%5B_modname%5D%0Afor item in REQUIRED_SETTINGS:%0A    for var in item%5B1%5D:%0A        delattr(_this_mod, var)%0A        %0A
 # Tr
@@ -1509,37 +1509,439 @@
 ngs%0A
-from localsettings import *%0A%0A
+try:%0A    # do the import here to check that the path exists before doing anything%0A    from localsettings import *%0A%0A    # Delete all the default required settings%0A    _modname = globals()%5B'__name__'%5D%0A    _this_mod = sys.modules%5B_modname%5D%0A    for item in REQUIRED_SETTINGS:%0A        for var in item%5B1%5D:%0A            delattr(_this_mod, var)%0A%0A    # now import again to re-insert the deleted settings%0A    from localsettings import *%0A%0A    
 # ch
@@ -1983,16 +1983,20 @@
 are set%0A
+    
 for item
@@ -2014,24 +2014,28 @@
 D_SETTINGS:%0A
+    
     for var 
@@ -2054,16 +2054,20 @@
         
+  
+  
 if not h
@@ -2102,16 +2102,20 @@
         
+    
 raise Ex
@@ -2139,16 +2139,20 @@
         
+ 
+   
 %22Missing
@@ -2199,16 +2199,20 @@
         
+   
+ 
 %22documen
@@ -2240,16 +2240,20 @@
 ng at %22%0A
+    
         
@@ -2321,16 +2321,20 @@
         
+    
 %25 (var, 
@@ -2342,24 +2342,439 @@
 tem%5B0%5D)%0A    
+            )%0A%0Aexcept ImportError as e:%0A    if %22No module named localsettings%22 in %22%25s%22 %25 e:%0A        print(%0A            %22ERROR: No localsettings module defined. Please run the %22%0A            %22 'bootstrap_local_settings' command if you have not yet %22%0A            %22created a localsettings module and add the parent %22%0A            %22directory to your PYTHONPATH. Proceeding with missing %22%0A            %22required settings.%22%0A
         )%0A%0A#

allow ignoring missing localsettings file for bootstrapping