Initial project version

This commit is contained in:
sebastiankloth
2022-04-11 10:59:06 +02:00
commit 4fb80d9d44
58 changed files with 33879 additions and 0 deletions

30
store/__init__.py Executable file
View 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']