-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.py.sample
More file actions
70 lines (64 loc) · 2.53 KB
/
config.py.sample
File metadata and controls
70 lines (64 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
class Config:
"""
Configure Flask application from environment vars.
Preconfigured values are set from: RUNMODE=test or RUNMODE=production
Each parameter can be overriden directly by an environment variable.
"""
RUNMODE = os.environ.get("RUNMODE")
if RUNMODE == "production":
# WFCatalog MongoDB
MONGODB_HOST = "host.docker.internal"
MONGODB_PORT = 27017
MONGODB_USR = ""
MONGODB_PWD = ""
MONGODB_NAME = "wfrepo"
# FDSNWS-Station cache source
FDSNWS_STATION_URL = "https://orfeus-eu.org/fdsnws/station/1/query"
# Cache host (localhost or container name)
CACHE_HOST = "cache"
CACHE_PORT = 6379
CACHE_INVENTORY_KEY = "inventory"
CACHE_INVENTORY_PERIOD = 0
CACHE_RESP_PERIOD = 1200
elif RUNMODE == "test":
# WFCatalog MongoDB
MONGODB_HOST = "localhost"
MONGODB_PORT = 27017
MONGODB_USR = ""
MONGODB_PWD = ""
MONGODB_NAME = "wfrepo"
# FDSNWS-Station cache source
FDSNWS_STATION_URL = "https://orfeus-eu.org/fdsnws/station/1/query"
# Cache host (localhost or container name)
CACHE_HOST = "localhost"
CACHE_PORT = 6379
CACHE_INVENTORY_KEY = "inventory"
CACHE_INVENTORY_PERIOD = 0
CACHE_RESP_PERIOD = 1200
try:
MONGODB_HOST = os.environ.get("MONGODB_HOST") or MONGODB_HOST
MONGODB_PORT = os.environ.get("MONGODB_PORT") or MONGODB_PORT
MONGODB_USR = os.environ.get("MONGODB_USR") or MONGODB_USR
MONGODB_PWD = os.environ.get("MONGODB_PWD") or MONGODB_PWD
MONGODB_NAME = os.environ.get("MONGODB_NAME") or MONGODB_NAME
FDSNWS_STATION_URL = os.environ.get("FDSNWS_STATION_URL") or FDSNWS_STATION_URL
CACHE_HOST = os.environ.get("CACHE_HOST") or CACHE_HOST
CACHE_PORT = os.environ.get("CACHE_PORT") or CACHE_PORT
CACHE_INVENTORY_KEY = (
os.environ.get("CACHE_INVENTORY_KEY") or CACHE_INVENTORY_KEY
)
CACHE_INVENTORY_PERIOD = (
os.environ.get("CACHE_INVENTORY_PERIOD") or CACHE_INVENTORY_PERIOD
)
CACHE_RESP_PERIOD = (
os.environ.get("CACHE_SHORT_INV_PERIOD") or CACHE_RESP_PERIOD
)
# Sentry configuration (optional)
SENTRY_DSN = os.environ.get("SENTRY_DSN") or ""
SENTRY_TRACES_SAMPLE_RATE = float(
os.environ.get("SENTRY_TRACES_SAMPLE_RATE") or "1.0"
)
except NameError:
print("Missing environment variables.")
raise