1
|
from configparser import RawConfigParser
|
2
|
|
3
|
|
4
|
CONFIG_FILE = "config.ini"
|
5
|
|
6
|
usb_detector_section = "usb_detector"
|
7
|
server_section = "server"
|
8
|
logger_section = "logger"
|
9
|
cache_section = "cache"
|
10
|
|
11
|
config = RawConfigParser()
|
12
|
config.read(CONFIG_FILE)
|
13
|
|
14
|
scan_period_seconds = float(config[usb_detector_section]["scan_period_seconds"])
|
15
|
connected_devices_filename = config[usb_detector_section]["connected_devices_filename"]
|
16
|
|
17
|
server_url = config[server_section]["url"]
|
18
|
server_port = config[server_section]["port"]
|
19
|
server_endpoint = config[server_section]["end_point"]
|
20
|
|
21
|
logger_format = config[logger_section]["format"]
|
22
|
logger_level_str = config[logger_section]["level"]
|
23
|
logger_level = 0
|
24
|
|
25
|
if logger_level_str == "DEBUG":
|
26
|
logger_level = 10
|
27
|
elif logger_level_str == "INFO":
|
28
|
logger_level = 20
|
29
|
elif logger_level_str == "WARNING":
|
30
|
logger_level = 30
|
31
|
elif logger_level_str == "ERROR":
|
32
|
logger_level = 40
|
33
|
elif logger_level_str == "CRITICAL":
|
34
|
logger_level = 50
|