-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservices.py
49 lines (43 loc) · 1.61 KB
/
services.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
41
42
43
44
45
46
47
48
49
import json
# ------------------------------------------------------------------------------- #
#
# ------------------------------------------------------------------------------- #
class services():
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def __init__(self):
""" Init """
self.log_path = "logs/{}.txt"
self.config_env = None
self.config_load()
self.is_log = self.get_config()["log"]
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def logs(self, msg, file_name):
"""
"""
if self.is_log:
url = self.log_path.format(file_name)
with open(url, 'a') as file:
print(msg, file=file)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def config_load(self):
"""
"""
with open("config_env.json") as json_file:
self.config_env = json.load(json_file)
# --------------------------------------------------------------------------- #
#
# --------------------------------------------------------------------------- #
def get_config(self):
"""
"""
if self.config_env:
return self.config_env
else:
self.config_load()
return self.config_env