Browse Source

move config to toml file

pull/6/head
Sophie Schiller 6 months ago
parent
commit
44293e9323
  1. 1
      .gitignore
  2. 11
      service.py

1
.gitignore

@ -136,3 +136,4 @@ dmypy.json
index.html
config.conf
config.toml

11
service.py

@ -2,7 +2,7 @@
import json
import requests
import configparser
import tomlkit
import urllib3
urllib3.disable_warnings()
@ -32,8 +32,8 @@ class StatusPage:
def prettify(self, text):
for search, replace in self.config['prettify'].items():
text = text.replace(search.upper(), replace)
for search, replace in self.config.get('prettify', {}).items():
text = text.replace(search, replace)
return text
@ -107,14 +107,13 @@ class StatusPage:
def __init__(self):
self.config = configparser.ConfigParser()
self.config = {}
self.config['icinga2_api'] = {
'baseurl': 'https://localhost:5665',
'username': 'root',
'password': 'foobar'
}
with open('config.conf', 'r') as configfile:
self.config.read('config.conf')
self.config.update(tomlkit.loads(open('config.toml').read()))
if __name__ == "__main__":
page = StatusPage()

Loading…
Cancel
Save