-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathantiscorm.py
59 lines (40 loc) · 1.22 KB
/
antiscorm.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
50
51
52
53
54
55
56
57
58
59
from enum import Enum
from natsort import natsorted
import interface
import time
import json
import os
VERSION = "1.0.0"
class ExecMode(Enum):
FULL = "Totalmente automático"
SEMI = "Semi-automático"
class Logger:
__instance = None
class LoggerHandler:
def __init__(self):
self.arq = open("log.txt", "a")
def __del__(self):
self.arq.close()
def write_log(self, text):
self.arq.write(text)
class LogType(Enum):
INFO = "[INFO] "
ERROR = "[ERRO] "
@classmethod
def log(cls, text: str, type: LogType = LogType.INFO):
if Logger.__instance is None:
Logger.__instance = Logger.LoggerHandler()
t = time.localtime()
current_time = time.strftime("%d/%m/%Y %H:%M:%S ", t)
Logger.__instance.write_log(f"[{current_time}]{type.value}{text}")
def save_config(config):
with open("config.json", "w") as arq:
json.dump(config, arq)
def get_sorted_folder(path):
return natsorted(os.listdir(path))
if __name__ == "__main__":
# Load config file
with open("config.json", "r") as arq:
config = json.load(arq)
# Initialize GUI
interface.GraphicInterface(config)