Repository URL to install this package:
|
Version:
0.9.8 ▾
|
postgis-import
/
config.py
|
|---|
import os
import pandas as pd
import uuid
class Config():
"""Holds various (configurable) constants"""
# The uuid-namespace is used as seed for the positions.id.
# Create your own e.g. using uuid.uuid1() but do not change if search by uuid is required.
NAMESPACE_UUID = uuid.UUID('ccfe7905-77e0-11e9-a18d-f45c899fb76f')
DB_HOST = os.environ.get('DB_HOST') or 'dm-pgsql-node1.geomar.de'
DB_NAME = os.environ.get('DB_NAME') or 'geomar_spatial'
DB_SCHEMA = os.environ.get('DB_SCHEMA') or 'moses_eddies_geosrv'
DB_USER = os.environ.get('DB_USER') or 'postgis_import'
DB_POSITIONS_TABLE = os.environ.get('DB_POSITIONS_TABLE') or 'positions_platforms'
DB_PLATFORMS_TABLE = os.environ.get('DB_PLATFORMS_TABLE') or 'platforms'
# redis conf
CACHE_HOST = os.environ.get('CACHE_HOST') or 'rlite' # use rlite as backend by default
CACHE_PORT = os.environ.get('CACHE_HOST') or '6379'
CACHE_DB = os.environ.get('CACHE_DB') or 'ocean_eddies_postgis'
__pwd = ''
# TODO pwd handling is not nice. psycopg2 has some automagic to use pgpass, figure out how to use for root
pgpass_file = os.path.join(os.getcwd(), ".pgpass") # look in current working directory first
if not (os.path.exists(pgpass_file)): # look in unser home later
homedir = os.path.expanduser('~')
pgpass_file = os.path.join(homedir, '.pgpass')
if os.path.exists(pgpass_file):
__df_db = pd.read_csv('~/.pgpass', sep=':', names=['host', 'port', '', 'usr', 'pwd'])
__pwd = __df_db[(__df_db.host.str.startswith(DB_HOST)) & (__df_db.usr == DB_USER)].iloc[0].pwd
DB_PASSWD = os.environ.get('DB_PASSWD') or __pwd