31 lines
982 B
Python
Executable File
31 lines
982 B
Python
Executable File
import os
|
|
import configparser
|
|
import socket
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read([
|
|
os.path.join(os.path.dirname(__file__), 'store.cfg'),
|
|
os.path.expanduser('~/.store.cfg'),
|
|
os.environ.get('STORE_CONFIG', '')
|
|
])
|
|
|
|
#PGPASS = '/nfsopt/mdevaluate/pgpass'
|
|
#if os.path.exists(PGPASS):
|
|
# with open(PGPASS) as f:
|
|
# for pgpass in f:
|
|
# hostname, *_, username, password = pgpass.split(':')
|
|
# if hostname == 'db.cluster' and username == 'store':
|
|
# config['store']['pg_password'] = password.strip()
|
|
|
|
# we sometimes have problems with the internal DNS, therefore try to resolve
|
|
# the database host in advance and use IP directly
|
|
try:
|
|
config['store']['pg_host'] = socket.gethostbyname(config['store']['pg_host'])
|
|
except OSError:
|
|
pass
|
|
|
|
|
|
from .store import get, update, delete, init_db, observables, systems, merge, dump_db
|
|
|
|
__all__ = ['get', 'update', 'delete', 'init_db', 'observables', 'systems', 'merge', 'dump_db']
|