move config to toml file
This commit is contained in:
parent
f899e6e13b
commit
44293e9323
2 changed files with 6 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -136,3 +136,4 @@ dmypy.json
|
|||
index.html
|
||||
|
||||
config.conf
|
||||
config.toml
|
||||
|
|
11
service.py
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…
Reference in a new issue