add decouple to config the system
This commit is contained in:
parent
bfb67b92dd
commit
ec671312db
|
@ -113,3 +113,6 @@ ENV/
|
||||||
.vscode/
|
.vscode/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/app.py
|
/app.py
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
.env
|
||||||
|
|
|
@ -37,6 +37,11 @@ Create a PostgreSQL database called *devicehub* by running
|
||||||
- In MacOS: ``bash examples/create-db.sh devicehub dhub``, and password
|
- In MacOS: ``bash examples/create-db.sh devicehub dhub``, and password
|
||||||
``ereuse``.
|
``ereuse``.
|
||||||
|
|
||||||
|
Configure project using environment file (you can use provided example as quickstart):
|
||||||
|
.. code:: bash
|
||||||
|
|
||||||
|
$ cp examples/env.example .env
|
||||||
|
|
||||||
Using the `dh` tool for set up with one or multiple inventories.
|
Using the `dh` tool for set up with one or multiple inventories.
|
||||||
Create the tables in the database by executing:
|
Create the tables in the database by executing:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
from decouple import config
|
||||||
|
|
||||||
from teal.auth import TokenAuth
|
from teal.auth import TokenAuth
|
||||||
from teal.config import Config
|
from teal.config import Config
|
||||||
|
@ -29,7 +30,16 @@ class DevicehubConfig(Config):
|
||||||
import_resource(versions)),
|
import_resource(versions)),
|
||||||
)
|
)
|
||||||
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
|
PASSWORD_SCHEMES = {'pbkdf2_sha256'} # type: Set[str]
|
||||||
SQLALCHEMY_DATABASE_URI = 'postgresql://dhub:ereuse@localhost/devicehub' # type: str
|
DB_USER = config('DB_USER', 'dhub')
|
||||||
|
DB_PASSWORD = config('DB_PASSWORD', 'ereuse')
|
||||||
|
DB_HOST = config('DB_HOST', 'localhost')
|
||||||
|
DB_DATABASE = config('DB_DATABASE', 'devicehub')
|
||||||
|
SQLALCHEMY_DATABASE_URI = 'postgresql://{user}:{pw}@{host}/{db}'.format(
|
||||||
|
user=DB_USER,
|
||||||
|
pw=DB_PASSWORD,
|
||||||
|
host=DB_HOST,
|
||||||
|
db=DB_DATABASE,
|
||||||
|
) # type: str
|
||||||
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
|
MIN_WORKBENCH = StrictVersion('11.0a1') # type: StrictVersion
|
||||||
"""The minimum version of ereuse.org workbench that this devicehub
|
"""The minimum version of ereuse.org workbench that this devicehub
|
||||||
accepts. we recommend not changing this value.
|
accepts. we recommend not changing this value.
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
DB_USER='dhub'
|
||||||
|
DB_PASSWORD='ereuse'
|
||||||
|
DB_HOST='localhost'
|
||||||
|
DB_DATABASE='devicehub'
|
|
@ -34,3 +34,5 @@ weasyprint==44
|
||||||
psycopg2-binary==2.8.3
|
psycopg2-binary==2.8.3
|
||||||
sortedcontainers==2.1.0
|
sortedcontainers==2.1.0
|
||||||
tqdm==4.32.2
|
tqdm==4.32.2
|
||||||
|
python-decouple==3.3
|
||||||
|
python-dotenv==0.14.0
|
||||||
|
|
Reference in New Issue