-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
40 lines (33 loc) · 1.27 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import configparser
import platform
system = platform.system()
class Config(object):
SQLALCHEMY_TRACK_MODIFICATIONS = False
OIDC_SCOPES = ["openid", "email", "profile"]
TREAT_AS_BOOLEAN = ["oidc_cookie_secure", "ldap_require_valid_cert", "sccm_show_button"]
VERSION = "0.1e"
@classmethod
def read_config(cls):
if system == 'Windows':
dir_path = os.path.dirname(os.path.realpath(__file__))
config_file = dir_path + "/config.ini"
else:
config_file = "/etc/pacs/config.ini"
try:
f = open(config_file, "r")
content = f.read()
except:
print("Could not open configuration file " + config_file)
exit(0)
config = configparser.ConfigParser()
config.read_string(content)
for section in config.sections():
for option in config.options(section):
if option not in Config.TREAT_AS_BOOLEAN:
value = config.get(section, option)
if value.isnumeric():
value = int(value)
else:
value = config.getboolean(section, option)
setattr(cls, option.upper(), value)