Logger and config setup. Logger also pushes to elastic

This commit is contained in:
2021-10-03 18:51:10 +02:00
parent 63eb29c4c5
commit b75671e68c
3 changed files with 113 additions and 0 deletions

23
utils.py Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/usr/python3
import os
import yaml
import pytest
def loadYaml(filePath):
with open(filePath, "r") as stream:
try:
return yaml.safe_load(stream)
except yaml.YAMLError as exception:
print('Error: {} is unparsable'.format(filePath))
print(exception)
def getConfig():
pwd = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(pwd, 'config.yaml')
if not os.path.isfile(path):
print('Please fill out and rename config file. Check README for more info.')
exit(0)
return loadYaml(path)