-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
44 lines (38 loc) · 1.54 KB
/
config.py
File metadata and controls
44 lines (38 loc) · 1.54 KB
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
41
42
43
44
import configparser
import os
class CleanFileConfig:
def __int__(self):
self.age = 10
self.base_path = ""
self.config_path = ""
self.telegram_token =""
self.telegram_conversation_id = -1
self.cpu_threshold = 50.0
self.memory_threshold = 50.0
self.disk_threshold = 50.0
self.db_master =""
self.db_master_db=""
self.db_master_port= 5432
self.db_master_user= ""
self.db_master_password = ""
self.db_slaves = ""
# Create a ConfigParser object
config = configparser.ConfigParser()
# Read the properties file
CONFIG = CleanFileConfig()
script_dir = os.path.dirname(os.path.abspath(__file__))
CONFIG.config_path = f'{script_dir}/config.properties'
config.read(CONFIG.config_path)
CONFIG.age = int(config['settings']['age'])
CONFIG.base_path = config['settings']['clean_path']
CONFIG.telegram_token = config["telegram"]["token"]
CONFIG.telegram_conversation_id = config["telegram"]["conversation_id"]
CONFIG.cpu_threshold = float(config["monitor"]["cpu_threshold"])
CONFIG.memory_threshold = float(config["monitor"]["memory_threshold"])
CONFIG.disk_threshold = float(config["monitor"]["disk_threshold"])
CONFIG.db_master = config["postgres"]["db_master"]
CONFIG.db_master_user = config["postgres"]["db_master_user"]
CONFIG.db_master_password = config["postgres"]["db_master_password"]
CONFIG.db_master_port = int(config["postgres"]["db_master_port"])
CONFIG.db_master_db= config["postgres"]["db_master_db"]
CONFIG.db_slaves = config["postgres"]["db_slaves"]