SECRET_KEY = config('SECRET_KEY', 'this must be changed!!') # If you intend to run WITHOUT HTTPS, such as local development, # then set this to False SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE', True, cast=bool) # By default, use HTTPONLY cookies SESSION_COOKIE_HTTPONLY = config('SESSION_COOKIE_HTTPONLY', True, cast=bool) # By default, we don't want to be inside a frame. # If you need to override this you can use the # `django.views.decorators.clickjacking.xframe_options_sameorigin` # decorator on specific views that can be in a frame. X_FRAME_OPTIONS = config('X_FRAME_OPTIONS', 'DENY') SOCORRO_REVISION = get_version() # Comma-separated list of urls that serve version information in JSON format OVERVIEW_VERSION_URLS = config('OVERVIEW_VERSION_URLS', '') # Raven sends errors to Sentry. # The release is optional. raven_dsn = config('RAVEN_DSN', '') if raven_dsn: RAVEN_CONFIG = { 'dsn': raven_dsn, 'release': SOCORRO_REVISION, # Defines keys to be sanitized by SanitizeKeysProcessor 'sanitize_keys': [
def run(cls, config_path=None, values_source_list=None): # NOTE(willkg): This is a classmethod, so we need a different logger. mylogger = logging.getLogger(__name__ + "." + cls.__name__) if config_path is None: config_path = os.environ.get("DEFAULT_SOCORRO_CONFIG_PATH", "./config") if values_source_list is None: values_source_list = [ # pull in any configuration file ConfigFileFutureProxy, # get values from the environment environment, # use the command line to get the final overriding values command_line, ] # Pull base set of defaults from the config module if it is specified if cls.config_defaults is not None: values_source_list.insert(0, cls.config_defaults) config_definition = cls.get_required_config() if "application" not in config_definition: # FIXME(mkelly): We used to have a SocorroWelcomeApp that defined an # "application" option. We no longer have that. This section should # get reworked possibly as part of getting rid of application # defaults. application_config = Namespace() application_config.add_option( "application", doc="the fully qualified classname of the app to run", default=cls_to_pypath(cls), # the following setting means this option will NOT be # commented out when configman generates a config file likely_to_be_changed=True, from_string_converter=str_to_python_object, ) config_definition = application_config config_manager = ConfigurationManager( config_definition, app_name=cls.app_name, app_version=cls.app_version, app_description=cls.app_description, values_source_list=values_source_list, options_banned_from_help=[], config_pathname=config_path, ) def fix_exit_code(code): # some apps don't return a code so you might get None # which isn't good enough to send to sys.exit() if code is None: return 0 return code with config_manager.context() as config: setup_logging(config) setup_metrics(config) # Log revision information revision_data = get_revision_data() revision_items = sorted(revision_data.items()) mylogger.info( "version.json: {%s}", ", ".join( ["%r: %r" % (key, val) for key, val in revision_items]), ) config_manager.log_config(mylogger) # Add version to crash reports version = get_version(revision_data) setup_crash_reporting(config, version) # we finally know what app to actually run, instantiate it app_to_run = cls(config) app_to_run.config_manager = config_manager # whew, finally run the app that we wanted return_code = fix_exit_code(app_to_run.main()) return return_code
def get_client(dsn): return raven.Client(dsn=dsn, release=get_version())
SECRET_KEY = config('SECRET_KEY', 'this must be changed!!') # If you intend to run WITHOUT HTTPS, such as local development, # then set this to False SESSION_COOKIE_SECURE = config('SESSION_COOKIE_SECURE', True, cast=bool) # By default, use HTTPONLY cookies SESSION_COOKIE_HTTPONLY = config('SESSION_COOKIE_HTTPONLY', True, cast=bool) # By default, we don't want to be inside a frame. # If you need to override this you can use the # `django.views.decorators.clickjacking.xframe_options_sameorigin` # decorator on specific views that can be in a frame. X_FRAME_OPTIONS = config('X_FRAME_OPTIONS', 'DENY') SOCORRO_REVISION = get_version() # Comma-separated list of urls that serve version information in JSON format OVERVIEW_VERSION_URLS = config('OVERVIEW_VERSION_URLS', '') # Raven sends errors to Sentry. # The release is optional. raven_dsn = config('RAVEN_DSN', '') if raven_dsn: RAVEN_CONFIG = { 'dsn': raven_dsn, 'release': SOCORRO_REVISION, # Defines keys to be sanitized by SanitizeKeysProcessor 'sanitize_keys': [ 'sessionid', 'csrftoken',