Commit 2107bcbe authored by Jonathan Schaeffer's avatar Jonathan Schaeffer

Configuration class

parent 49cc5565
import gnupg
import re
import datetime
import random
......@@ -9,8 +8,10 @@ from hashlib import md5
from flask import Flask, request, Response
import psycopg2
import gnupg
from config import Configurator
from version import __version__
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s')
logger = logging.getLogger(__name__)
if os.getenv('RUNMODE') == 'production':
......@@ -25,48 +26,7 @@ else:
application = Flask(__name__)
# For convenience, prepare configuration for RESIF RUNMODE
if os.getenv('RUNMODE') == 'production':
application.config['RESIFINV_PGUSER'] = "eidawsauth"
application.config['RESIFINV_PGHOST'] = "resif-pgprod.u-ga.fr"
application.config['RESIFINV_PGPORT'] = 5432
application.config['RESIFINV_PGDATABASE'] = "resifInv-Prod"
application.config['RESIFAUTH_PGUSER'] = "eidawsauth"
application.config['RESIFAUTH_PGHOST'] = "resif-pgprod.u-ga.fr"
application.config['RESIFAUTH_PGPORT'] = 5432
application.config['RESIFAUTH_PGDATABASE'] = "resifAuth"
elif os.getenv('RUNMODE') == 'preprod':
application.config['RESIFINV_PGUSER'] = "eidawsauth"
application.config['RESIFINV_PGHOST'] = "resif-pgpreprod.u-ga.fr"
application.config['RESIFINV_PGPORT'] = 5432
application.config['RESIFINV_PGDATABASE'] = "resifInv-Preprod"
application.config['RESIFAUTH_PGUSER'] = "eidawsauth"
application.config['RESIFAUTH_PGHOST'] = "resif-pgpreprod.u-ga.fr"
application.config['RESIFAUTH_PGPORT'] = 5432
application.config['RESIFAUTH_PGDATABASE'] = "resifAuth"
else:
application.config['RESIFINV_PGUSER'] = os.getenv('RESIFINV_PGUSER')
application.config['RESIFINV_PGHOST'] = os.getenv('RESIFINV_PGHOST')
application.config['RESIFINV_PGPORT'] = os.getenv('RESIFINV_PGPORT')
application.config['RESIFINV_PGDATABASE'] = os.getenv('RESIFINV_PGDATABASE')
application.config['RESIFAUTH_PGUSER'] = os.getenv('RESIFAUTH_PGUSER')
application.config['RESIFAUTH_PGHOST'] = os.getenv('RESIFAUTH_PGHOST')
application.config['RESIFAUTH_PGPORT'] = os.getenv('RESIFAUTH_PGPORT')
application.config['RESIFAUTH_PGDATABASE'] = os.getenv('RESIFAUTH_PGDATABASE')
# if PGPASS is provided, then use it for both database connection
if 'PGPASS' in os.environ:
application.config['RESIFINV_PGPASS'] = os.getenv('PGPASS')
application.config['RESIAUTH_PGPASS'] = os.getenv('PGPASS')
else:
application.config['RESIFINV_PGPASS'] = os.getenv('RESIFINV_PGPASS')
application.config['RESIAUTH_PGPASS'] = os.getenv('RESIAUTH_PGPASS')
application.config['GNUPG_HOMEDIR'] = os.getenv('GNUPG_HOMEDIR', '/gpghome')
application.config['SUPPORT_EMAIL'] = os.getenv('SUPPORT_EMAIL', 'resif-dc@univ-grenoble-alpes.fr')
application.config['EPOS_FDSN_MAP'] = {'/epos/alparray': {'networkcode':'Z3', 'startyear':2015, 'endyear': 2022}}
# Are we there now ?
application.config.from_object(Configurator)
def wsshash(login, password):
......@@ -88,7 +48,7 @@ def parse_input_data(data):
logging.debug(token)
d = dict([i for i in kv.split(':',1)] for kv in token.replace('"','').replace(' ','').split(','))
logging.debug("Transformed to dictionary : "+str(d))
logging.debug("Transformed to dictionary : %s", d)
return d
def register_login(login, password):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment