Initial project version
This commit is contained in:
30
store/__init__.py
Executable file
30
store/__init__.py
Executable file
@@ -0,0 +1,30 @@
|
||||
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']
|
||||
Reference in New Issue
Block a user