Config   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
dl 0
loc 7
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A init_app() 0 6 1
1
import json
2
import logging
3
import os
4
5
6
basedir = os.path.abspath(os.path.dirname(__file__))
7
8
9
class Config:
10
    @classmethod
11
    def init_app(cls, app):
12
        """Send logs to stdout."""
13
        file_handler = logging.StreamHandler()
14
        file_handler.setLevel(logging.WARNING)
15
        app.logger.addHandler(file_handler)
16
17
18
class DevelopmentConfig(Config):
19
    DEBUG = True
20
    HOST = "0.0.0.0"
21
    PORT = 5000
22
    DEBUG = True
23
24
25
class UnitTestingConfig(Config):
26
    TESTING = True
27
    HOST = "0.0.0.0"
28
    PORT = 5000
29
    DEBUG = True
30
31
32
class ProductionConfig(Config):
33
    DEBUG = True  # TODO: remove
34
    if os.getenv("VCAP_SERVICES"):
35
        services = json.loads(os.getenv("VCAP_SERVICES"))
36
        if "p-redis" in services:
37
            redis_env = services["p-redis"][0]["credentials"]
38
            REDIS_URL = "redis://:" + redis_env["password"] + "@" + redis_env["host"] + ":" + str(redis_env["port"]) + "/0"
39
        else:
40
            redis_env = services["rediscloud"][0]["credentials"]
41
            REDIS_URL = "redis://:" + redis_env["password"] + "@" + redis_env["hostname"] + ":" + str(redis_env["port"]) + "/0"
42
43
44
config = {
45
    "development": DevelopmentConfig,
46
    "unit_testing": UnitTestingConfig,
47
    "production": ProductionConfig,
48
    "default": DevelopmentConfig
49
}
50