DE-Lib 0.0.20__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DE_Lib/Cloud/__init__.py +0 -0
- DE_Lib/DataBase/Azure.py +44 -0
- DE_Lib/DataBase/Cache.py +74 -0
- DE_Lib/DataBase/Firebird.py +45 -0
- DE_Lib/DataBase/Informix.py +37 -0
- DE_Lib/DataBase/Metadata.py +62 -0
- DE_Lib/DataBase/MsSql.py +39 -0
- DE_Lib/DataBase/MySql.py +42 -0
- DE_Lib/DataBase/Oracle.py +111 -0
- DE_Lib/DataBase/Postgres.py +39 -0
- DE_Lib/DataBase/RedShift.py +42 -0
- DE_Lib/DataBase/SQCipher.py +42 -0
- DE_Lib/DataBase/SQLite.py +48 -0
- DE_Lib/DataBase/__init__.py +0 -0
- DE_Lib/Files/Avro.py +23 -0
- DE_Lib/Files/Csv.py +64 -0
- DE_Lib/Files/JSon.py +64 -0
- DE_Lib/Files/Parquet.py +31 -0
- DE_Lib/Files/Txt.py +64 -0
- DE_Lib/Files/Xlsx.py +55 -0
- DE_Lib/Files/__init__.py +0 -0
- DE_Lib/Log/DE_LogEventos.py +533 -0
- DE_Lib/Log/Level.py +77 -0
- DE_Lib/Log/Log.py +470 -0
- DE_Lib/Log/__init__.py +0 -0
- DE_Lib/Utils/Cipher/Aes.py +65 -0
- DE_Lib/Utils/Cipher/Argon.py +37 -0
- DE_Lib/Utils/Cipher/Base64.py +48 -0
- DE_Lib/Utils/Cipher/Cipher.py +300 -0
- DE_Lib/Utils/Cipher/Fernet.py +81 -0
- DE_Lib/Utils/Cipher/Gcm.py +78 -0
- DE_Lib/Utils/Cipher/Pbkdf2.py +43 -0
- DE_Lib/Utils/Cipher/Rsa.py +140 -0
- DE_Lib/Utils/Cipher/__init__.py +0 -0
- DE_Lib/Utils/Colors.py +203 -0
- DE_Lib/Utils/DateUtils.py +215 -0
- DE_Lib/Utils/Generic.py +249 -0
- DE_Lib/Utils/SQL.py +34 -0
- DE_Lib/Utils/System.py +50 -0
- DE_Lib/Utils/WebHook.py +18 -0
- DE_Lib/Utils/__init__.py +0 -0
- DE_Lib/__init__.py +0 -0
- de_lib-0.0.20.dist-info/LICENCE +21 -0
- de_lib-0.0.20.dist-info/METADATA +68 -0
- de_lib-0.0.20.dist-info/RECORD +47 -0
- de_lib-0.0.20.dist-info/WHEEL +5 -0
- de_lib-0.0.20.dist-info/top_level.txt +1 -0
@@ -0,0 +1,533 @@
|
|
1
|
+
import datetime as dt
|
2
|
+
import json
|
3
|
+
import os
|
4
|
+
import platform as so
|
5
|
+
import socket as skt
|
6
|
+
|
7
|
+
class LOG:
|
8
|
+
def __init__(self, **kwargs):
|
9
|
+
try:
|
10
|
+
self._PROCESSO = kwargs
|
11
|
+
self._CR = True # Carriage_Return
|
12
|
+
#
|
13
|
+
if (self._PROCESSO["device_out"] is None) or (len(self._PROCESSO["device_out"]) == 0):
|
14
|
+
self._PROCESSO["device_out"] = ["screen"]
|
15
|
+
if "database" in self._PROCESSO["device_out"] and "memory" in self._PROCESSO["device_out"]:
|
16
|
+
del(self._PROCESSO["device_out"][self._PROCESSO["device_out"].index("memory")])
|
17
|
+
#
|
18
|
+
if self._PROCESSO["nome_tabela_log"] is None:
|
19
|
+
self._PROCESSO["nome_tabela_log"] = "LOG"
|
20
|
+
if self._PROCESSO["nome_tabela_log_evento"] is None:
|
21
|
+
self._PROCESSO["nome_tabela_log_evento"] = "LOG_EVENTO"
|
22
|
+
#
|
23
|
+
self._CONEXAO = self._PROCESSO["conexao_log"]
|
24
|
+
self._TABLE_LOG = self._PROCESSO["nome_tabela_log"]
|
25
|
+
self._TABLE_EVENT = self._PROCESSO["nome_tabela_log_evento"]
|
26
|
+
self._DEVICE_OUT = self._PROCESSO["device_out"]
|
27
|
+
|
28
|
+
self._filename_absolute = os.path.splitext(self._PROCESSO["file"])[0]+".json"
|
29
|
+
self._CORES = self._cores_ansi()
|
30
|
+
self._HASH_LOG = self._hash()
|
31
|
+
self._FILE_LOG_EVENT = []
|
32
|
+
except Exception as error:
|
33
|
+
print(error)
|
34
|
+
raise Exception("Classe LOGGING não foi instanciada")
|
35
|
+
|
36
|
+
def Inicializa(self) -> object:
|
37
|
+
file_handler, body_json, cor, msg, result = None, None, None, None, []
|
38
|
+
try:
|
39
|
+
cor = self.Preto_Fore + self.Cyan_Claro_Back
|
40
|
+
if "screen" in self._DEVICE_OUT:
|
41
|
+
msg = f"""LOG Inicializado!"""
|
42
|
+
if "file" in self._DEVICE_OUT:
|
43
|
+
msg = f"""LOG Inicializado ({self._filename_absolute})"""
|
44
|
+
file_handler = open(self._filename_absolute, "w", encoding='utf-8')
|
45
|
+
text = """{"body": \n\t{ "content": \n\t\t{ """ + f""" "File": "{self._filename_absolute}",""" + f""" \n\t\t"datalog": "{dt.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}",""" + f"""\n\t\t "payload":[ \n\t\t\t"""
|
46
|
+
self._print_file(file_handler, text)
|
47
|
+
if "database" in self._DEVICE_OUT:
|
48
|
+
msg = f"""LOG Inicializado"""
|
49
|
+
self._print_db_new(payload=self._PROCESSO, nome_tabela=self._TABLE_LOG)
|
50
|
+
if "memory" in self._DEVICE_OUT:
|
51
|
+
msg = f"""LOG Inicializado"""
|
52
|
+
self._print_memory(nome_tabela=self._TABLE_LOG, payload=self._PROCESSO)
|
53
|
+
except Exception as error:
|
54
|
+
msg = f"""Falha do tentar inicializar o LOG ({self._filename_absolute})"""
|
55
|
+
cor = self.Branco_Fore + self.Verde_Claro_Back
|
56
|
+
finally:
|
57
|
+
msg = f"""{cor} {msg} [{",".join(self._DEVICE_OUT)}] {self.Reset}"""
|
58
|
+
self._print_screen(msg)
|
59
|
+
return file_handler
|
60
|
+
|
61
|
+
def Popula(self, logger, level, content, function_name: str = "", cor: str = "", lf: bool = True, onscreen: bool = True) -> None:
|
62
|
+
payload = None
|
63
|
+
try:
|
64
|
+
# Construindo o Payload para insert na tabela
|
65
|
+
payload = self._payload_event(content=content, function=function_name)
|
66
|
+
self._LOG_LEVEL_COLOR = self._LOG_LEVEL_COLOR + cor
|
67
|
+
|
68
|
+
if self._CR:
|
69
|
+
msg = f"""{self._LOG_LEVEL_COLOR}{dt.datetime.now()} - {self._LOG_LEVEL_CODE}-{self._LOG_LEVEL_NAME} - {function_name} - {content}"""
|
70
|
+
if not lf:
|
71
|
+
self._Carriage_Return()
|
72
|
+
else:
|
73
|
+
msg = f""": {self._LOG_LEVEL_COLOR}{content}"""
|
74
|
+
if lf:
|
75
|
+
self._Carriage_Return()
|
76
|
+
# if not lf:
|
77
|
+
# msg = f""": {content}"""
|
78
|
+
# ----------------------------------------------
|
79
|
+
if "screen" in self._DEVICE_OUT:
|
80
|
+
self._print_screen(msg, lf, onscreen)
|
81
|
+
if "file" in self._DEVICE_OUT:
|
82
|
+
texto = json.dumps(payload, indent=15) + ","
|
83
|
+
self._print_file(logger, texto)
|
84
|
+
if "database" in self._DEVICE_OUT:
|
85
|
+
self._print_db_new(payload=payload, nome_tabela=self._TABLE_EVENT)
|
86
|
+
if "memory" in self._DEVICE_OUT:
|
87
|
+
self._print_memory(nome_tabela=self._TABLE_EVENT, payload=payload)
|
88
|
+
self._LOG_LEVEL_COLOR = self.Reset
|
89
|
+
except Exception as error:
|
90
|
+
print(self.Vermelho_Claro_Fore + error + self.Reset)
|
91
|
+
finally:
|
92
|
+
return payload
|
93
|
+
|
94
|
+
def Finaliza(self, logger: object) -> None:
|
95
|
+
cor, msg, result, result = None, None, None, None
|
96
|
+
try:
|
97
|
+
cor = self.Reset + self.Preto_Fore + self.Cyan_Claro_Back
|
98
|
+
msg = f"""LOG Finalizado!"""
|
99
|
+
if "screen" in self._DEVICE_OUT:
|
100
|
+
pass
|
101
|
+
if "file" in self._DEVICE_OUT:
|
102
|
+
text = "]}}}"
|
103
|
+
self._print_file(logger, text)
|
104
|
+
logger.close()
|
105
|
+
if "database" in self._DEVICE_OUT:
|
106
|
+
self._CONEXAO.close()
|
107
|
+
if "memory" in self._DEVICE_OUT:
|
108
|
+
result = [self._FILE_LOG, self._FILE_LOG_EVENT]
|
109
|
+
except Exception as error:
|
110
|
+
msg = f"""Erro ao tentar fechar o arquivo de LOG. Erro {error}"""
|
111
|
+
cor = self.Branco_Fore + self.Vermelho_Claro_Back
|
112
|
+
#result = msg
|
113
|
+
finally:
|
114
|
+
msg = f"""{cor} {msg} [{",".join(self._DEVICE_OUT)}] {self.Reset}"""
|
115
|
+
self._print_screen(msg)
|
116
|
+
return result
|
117
|
+
|
118
|
+
def _payload_header(self, processo: dict) -> None:
|
119
|
+
result = None
|
120
|
+
try:
|
121
|
+
now = dt.datetime.now()
|
122
|
+
binds = {}
|
123
|
+
binds.update(processo)
|
124
|
+
binds.update(self.OS_INFO)
|
125
|
+
# Consistindo se colunas existem no dicionario
|
126
|
+
if "timestamp" not in binds.keys(): binds["timestamp"] = now.strftime("%Y-%m-%d %H:%M:%S.%f")
|
127
|
+
if "hash" not in binds.keys(): binds["hash"] = self._HASH_LOG
|
128
|
+
if "versao" not in binds.keys(): binds["versao"] = None
|
129
|
+
del binds["conexao_log"]
|
130
|
+
del binds["nome_tabela_log"]
|
131
|
+
del binds["nome_tabela_log_evento"]
|
132
|
+
del binds["device_out"]
|
133
|
+
result = binds
|
134
|
+
except Exception as error:
|
135
|
+
print(error)
|
136
|
+
finally:
|
137
|
+
return result
|
138
|
+
|
139
|
+
def _payload_event(self, content: str, function: str):
|
140
|
+
try:
|
141
|
+
now = dt.datetime.now()
|
142
|
+
payload = {"hash": self._hash(str(self._HASH_LOG)),
|
143
|
+
"hash_log": self._HASH_LOG,
|
144
|
+
"timestamp": now.strftime("%Y-%m-%d %H:%M:%S.%f"),
|
145
|
+
"level_code": self._LOG_LEVEL_CODE,
|
146
|
+
"level_name": self._LOG_LEVEL_NAME,
|
147
|
+
"function_name": function,
|
148
|
+
"content": content
|
149
|
+
}
|
150
|
+
except Exception as error:
|
151
|
+
print(error)
|
152
|
+
finally:
|
153
|
+
return payload
|
154
|
+
|
155
|
+
def _hash(self, complemento: str = ""):
|
156
|
+
hora = dt.datetime.now().strftime("%Y%m%d%H%M%S%f")
|
157
|
+
return abs(hash(hora+complemento))
|
158
|
+
|
159
|
+
def _print_screen(self, msg, lf: bool = True, onscreen: bool = True):
|
160
|
+
if onscreen:
|
161
|
+
if lf:
|
162
|
+
print(msg)
|
163
|
+
else:
|
164
|
+
print(msg, end="")
|
165
|
+
|
166
|
+
def _print_file(self, logger, msg):
|
167
|
+
logger.write(msg)
|
168
|
+
|
169
|
+
def _print_db_new(self, payload: dict, nome_tabela: str):
|
170
|
+
msg = False
|
171
|
+
try:
|
172
|
+
cur = self._CONEXAO.cursor()
|
173
|
+
if nome_tabela == self._PROCESSO["nome_tabela_log_evento"]:
|
174
|
+
sql = f"""
|
175
|
+
Insert into {self._PROCESSO["nome_tabela_log_evento"]}
|
176
|
+
(hash,
|
177
|
+
hash_log,
|
178
|
+
timestamp,
|
179
|
+
level_code,
|
180
|
+
level_name,
|
181
|
+
function_name,
|
182
|
+
content)
|
183
|
+
VALUES(:hash,
|
184
|
+
:hash_log,
|
185
|
+
:timestamp,
|
186
|
+
:level_code,
|
187
|
+
:level_name,
|
188
|
+
:function_name,
|
189
|
+
:content)
|
190
|
+
"""
|
191
|
+
else:
|
192
|
+
payload = self._payload_header(payload)
|
193
|
+
sql = f"""
|
194
|
+
Insert into {self._PROCESSO["nome_tabela_log"]}
|
195
|
+
(nom_rotina,
|
196
|
+
nom_subrotina,
|
197
|
+
descricao,
|
198
|
+
file,
|
199
|
+
user_os,
|
200
|
+
user_db,
|
201
|
+
local_ip,
|
202
|
+
local_name,
|
203
|
+
processor,
|
204
|
+
so_platafor,
|
205
|
+
so_system,
|
206
|
+
so_version,
|
207
|
+
timestamp,
|
208
|
+
hash,
|
209
|
+
versao)
|
210
|
+
VALUES(:nom_rotina,
|
211
|
+
:nom_subrotina,
|
212
|
+
:descricao,
|
213
|
+
:file,
|
214
|
+
:user_os,
|
215
|
+
:user_db,
|
216
|
+
:local_ip,
|
217
|
+
:local_name,
|
218
|
+
:processor,
|
219
|
+
:so_platafor,
|
220
|
+
:so_system,
|
221
|
+
:so_version,
|
222
|
+
:timestamp,
|
223
|
+
:hash,
|
224
|
+
:versao)
|
225
|
+
"""
|
226
|
+
cur.execute(sql, payload)
|
227
|
+
self._CONEXAO.commit()
|
228
|
+
msg = "Registro de LOG criado!"
|
229
|
+
except Exception as error:
|
230
|
+
msg = f"""Falha ao tentar inserir um registro na tabela LOG. Erro: {error}"""
|
231
|
+
finally:
|
232
|
+
return msg
|
233
|
+
|
234
|
+
def _print_memory(self, nome_tabela: str, payload: dict):
|
235
|
+
msg = False
|
236
|
+
try:
|
237
|
+
if nome_tabela == self._PROCESSO["nome_tabela_log_evento"]:
|
238
|
+
self._FILE_LOG_EVENT.append(payload)
|
239
|
+
else:
|
240
|
+
payload = self._payload_header(payload)
|
241
|
+
self._FILE_LOG = payload
|
242
|
+
|
243
|
+
msg = "Registro de LOG criado!"
|
244
|
+
except Exception as error:
|
245
|
+
msg = f"""Falha ao tentar inserir um registro na tabela LOG. Erro: {error}"""
|
246
|
+
finally:
|
247
|
+
return msg
|
248
|
+
|
249
|
+
def Foreground(self, nome_cor):
|
250
|
+
cores = self.CORES
|
251
|
+
nome_cor = nome_cor.title()
|
252
|
+
return cores[nome_cor][0]
|
253
|
+
|
254
|
+
def Background(self, nome_cor):
|
255
|
+
cores = self.CORES
|
256
|
+
nome_cor = nome_cor.title()
|
257
|
+
return cores[nome_cor][1]
|
258
|
+
|
259
|
+
def _Carriage_Return(self):
|
260
|
+
self._CR = not self._CR
|
261
|
+
return self._CR
|
262
|
+
|
263
|
+
@property
|
264
|
+
def OS_INFO(self) -> dict:
|
265
|
+
return self._os_info()
|
266
|
+
|
267
|
+
@property
|
268
|
+
def CORES(self):
|
269
|
+
return self._CORES
|
270
|
+
|
271
|
+
@property
|
272
|
+
def NOTSET(self):
|
273
|
+
self._LOG_LEVEL_CODE = 0
|
274
|
+
self._LOG_LEVEL_NAME = "NOTSET"
|
275
|
+
self._LOG_LEVEL_COLOR = self.Branco_Fore
|
276
|
+
return self._LOG_LEVEL_CODE
|
277
|
+
|
278
|
+
@property
|
279
|
+
def WARNING(self):
|
280
|
+
self._LOG_LEVEL_CODE = 10
|
281
|
+
self._LOG_LEVEL_NAME = "WARNING"
|
282
|
+
self._LOG_LEVEL_COLOR = self.Amarelo_Claro_Fore
|
283
|
+
return self._LOG_LEVEL_CODE
|
284
|
+
|
285
|
+
@property
|
286
|
+
def DEBUG(self):
|
287
|
+
self._LOG_LEVEL_CODE = 20
|
288
|
+
self._LOG_LEVEL_NAME = "DEBUG"
|
289
|
+
self._LOG_LEVEL_COLOR = self.Verde_Claro_Fore
|
290
|
+
return self._LOG_LEVEL_CODE
|
291
|
+
|
292
|
+
@property
|
293
|
+
def ERROR(self):
|
294
|
+
self._LOG_LEVEL_CODE = 30
|
295
|
+
self._LOG_LEVEL_NAME = "ERROR"
|
296
|
+
self._LOG_LEVEL_COLOR = self.Vermelho_Claro_Fore
|
297
|
+
return self._LOG_LEVEL_CODE
|
298
|
+
|
299
|
+
@property
|
300
|
+
def INFO(self):
|
301
|
+
self._LOG_LEVEL_CODE = 40
|
302
|
+
self._LOG_LEVEL_NAME = "INFO"
|
303
|
+
self._LOG_LEVEL_COLOR = self.Cinza_Claro_Fore
|
304
|
+
return self._LOG_LEVEL_CODE
|
305
|
+
|
306
|
+
@property
|
307
|
+
def CRITICAL(self):
|
308
|
+
self._LOG_LEVEL_CODE = 50
|
309
|
+
self._LOG_LEVEL_NAME = "CRITICAL"
|
310
|
+
self._LOG_LEVEL_COLOR = self.Vermelho_Fore + self.Preto_Back
|
311
|
+
return self._LOG_LEVEL_CODE
|
312
|
+
|
313
|
+
@property
|
314
|
+
def DESTAQUE(self):
|
315
|
+
self._LOG_LEVEL_CODE = 50
|
316
|
+
self._LOG_LEVEL_NAME = "DESTAQUE"
|
317
|
+
self._LOG_LEVEL_COLOR = self.Cyan_Fore
|
318
|
+
return self._LOG_LEVEL_CODE
|
319
|
+
|
320
|
+
@property
|
321
|
+
def ENFASE(self):
|
322
|
+
self._LOG_LEVEL_CODE = 50
|
323
|
+
self._LOG_LEVEL_NAME = "ENFASE"
|
324
|
+
self._LOG_LEVEL_COLOR = self.Branco_Fore + self.Negrito + self.Sublinhado
|
325
|
+
return self._LOG_LEVEL_CODE
|
326
|
+
|
327
|
+
@property
|
328
|
+
def Preto_Fore(self):
|
329
|
+
return self.Foreground("Preto")
|
330
|
+
|
331
|
+
@property
|
332
|
+
def Vermelho_Fore(self):
|
333
|
+
return self.Foreground("Vermelho")
|
334
|
+
|
335
|
+
@property
|
336
|
+
def Verde_Fore(self):
|
337
|
+
return self.Foreground("Verde")
|
338
|
+
|
339
|
+
@property
|
340
|
+
def Amarelo_Fore(self):
|
341
|
+
return self.Foreground("Amarelo")
|
342
|
+
|
343
|
+
@property
|
344
|
+
def Azul_Fore(self):
|
345
|
+
return self.Foreground("Azul")
|
346
|
+
|
347
|
+
@property
|
348
|
+
def Magenta_Fore(self):
|
349
|
+
return self.Foreground("Magenta")
|
350
|
+
|
351
|
+
@property
|
352
|
+
def Cyan_Fore(self):
|
353
|
+
return self.Foreground("Cyan")
|
354
|
+
|
355
|
+
@property
|
356
|
+
def Cinza_Claro_Fore(self):
|
357
|
+
return self.Foreground("Cinza Claro")
|
358
|
+
|
359
|
+
@property
|
360
|
+
def Cinza_Escuro_Fore(self):
|
361
|
+
return self.Foreground("Cinza Escuro")
|
362
|
+
|
363
|
+
@property
|
364
|
+
def Vermelho_Claro_Fore(self):
|
365
|
+
return self.Foreground("Vermelho Claro")
|
366
|
+
|
367
|
+
@property
|
368
|
+
def Verde_Claro_Fore(self):
|
369
|
+
return self.Foreground("Verde Claro")
|
370
|
+
|
371
|
+
@property
|
372
|
+
def Amarelo_Claro_Fore(self):
|
373
|
+
return self.Foreground("Amarelo Claro")
|
374
|
+
|
375
|
+
@property
|
376
|
+
def Azul_Claro_Fore(self):
|
377
|
+
return self.Foreground("Azul Claro")
|
378
|
+
|
379
|
+
@property
|
380
|
+
def Magenta_Claro_Fore(self):
|
381
|
+
return self.Foreground("Magenta Claro")
|
382
|
+
|
383
|
+
@property
|
384
|
+
def Cyan_Claro_Fore(self):
|
385
|
+
return self.Foreground("Cyan Claro")
|
386
|
+
|
387
|
+
@property
|
388
|
+
def Branco_Fore(self):
|
389
|
+
return self.Foreground("Branco")
|
390
|
+
|
391
|
+
@property
|
392
|
+
def Preto_Back(self):
|
393
|
+
return self.Background("Preto")
|
394
|
+
|
395
|
+
@property
|
396
|
+
def Vermelho_Back(self):
|
397
|
+
return self.Background("Vermelho")
|
398
|
+
|
399
|
+
@property
|
400
|
+
def Verde_Back(self):
|
401
|
+
return self.Background("Verde")
|
402
|
+
|
403
|
+
@property
|
404
|
+
def Amarelo_Back(self):
|
405
|
+
return self.Background("Amarelo")
|
406
|
+
|
407
|
+
@property
|
408
|
+
def Azul_Back(self):
|
409
|
+
return self.Background("Azul")
|
410
|
+
|
411
|
+
@property
|
412
|
+
def Magenta_Back(self):
|
413
|
+
return self.Background("Magenta")
|
414
|
+
|
415
|
+
@property
|
416
|
+
def Cyan_Back(self):
|
417
|
+
return self.Background("Cyan")
|
418
|
+
|
419
|
+
@property
|
420
|
+
def Cinza_Claro_Back(self):
|
421
|
+
return self.Background("Cinza Claro")
|
422
|
+
|
423
|
+
@property
|
424
|
+
def Cinza_Escuro_Back(self):
|
425
|
+
return self.Background("Cinza Escuro")
|
426
|
+
|
427
|
+
@property
|
428
|
+
def Vermelho_Claro_Back(self):
|
429
|
+
return self.Background("Vermelho Claro")
|
430
|
+
|
431
|
+
@property
|
432
|
+
def Verde_Claro_Back(self):
|
433
|
+
return self.Background("Verde Claro")
|
434
|
+
|
435
|
+
@property
|
436
|
+
def Amarelo_Claro_Back(self):
|
437
|
+
return self.Background("Amarelo Claro")
|
438
|
+
|
439
|
+
@property
|
440
|
+
def Azul_Claro_Back(self):
|
441
|
+
return self.Background("Azul Claro")
|
442
|
+
|
443
|
+
@property
|
444
|
+
def Magenta_Claro_Back(self):
|
445
|
+
return self.Background("Magenta Claro")
|
446
|
+
|
447
|
+
@property
|
448
|
+
def Cyan_Claro_Back(self):
|
449
|
+
return self.Background("Cyan Claro")
|
450
|
+
|
451
|
+
@property
|
452
|
+
def Branco_Back(self):
|
453
|
+
return self.Background("Branco")
|
454
|
+
|
455
|
+
@property
|
456
|
+
def Negrito(self):
|
457
|
+
return self.Foreground("Negrito")
|
458
|
+
|
459
|
+
@property
|
460
|
+
def Italico(self):
|
461
|
+
return self.Foreground("Italico")
|
462
|
+
|
463
|
+
@property
|
464
|
+
def Sublinhado(self):
|
465
|
+
return self.Foreground("Sublinhado")
|
466
|
+
|
467
|
+
@property
|
468
|
+
def Riscado(self):
|
469
|
+
return self.Foreground("Riscado")
|
470
|
+
|
471
|
+
@property
|
472
|
+
def Inverte(self):
|
473
|
+
return self.Foreground("Inverte")
|
474
|
+
|
475
|
+
@property
|
476
|
+
def Reverse(self):
|
477
|
+
return self.Foreground("Reverse")
|
478
|
+
|
479
|
+
@property
|
480
|
+
def Reset(self):
|
481
|
+
return self.Foreground("Reset")
|
482
|
+
|
483
|
+
@staticmethod
|
484
|
+
def _cores_ansi() -> dict:
|
485
|
+
file_json, cores = None, None
|
486
|
+
try:
|
487
|
+
#cor = foreground , background
|
488
|
+
#Exemplo: Fore = Vermelho, back = amarelo --> cores["Vermelho"][0]+cores["Amarelo"][1]
|
489
|
+
# 0 = Cor da fonte, 1 = Cor do fundo
|
490
|
+
# json_file = open("cores_ansi.json")
|
491
|
+
# cores = json.load(json_file)
|
492
|
+
cores = {"Preto": ["\033[1;30m", "\033[1;40m"],
|
493
|
+
"Vermelho": ["\033[1;31m", "\033[1;41m"],
|
494
|
+
"Verde": ["\033[1;32m", "\033[1;42m"],
|
495
|
+
"Amarelo": ["\033[1;33m", "\033[1;43m"],
|
496
|
+
"Azul": ["\033[1;34m", "\033[1;44m"],
|
497
|
+
"Magenta": ["\033[1;35m", "\033[1;45m"],
|
498
|
+
"Cyan": ["\033[1;36m", "\033[1;46m"],
|
499
|
+
"Cinza Claro": ["\033[1;37m", "\033[1;47m"],
|
500
|
+
"Cinza Escuro": ["\033[1;90m", "\033[1;100m"],
|
501
|
+
"Vermelho Claro": ["\033[1;91m", "\033[1;101m"],
|
502
|
+
"Verde Claro": ["\033[1;92m", "\033[1;102m"],
|
503
|
+
"Amarelo Claro": ["\033[1;93m", "\033[1;103m"],
|
504
|
+
"Azul Claro": ["\033[1;94m", "\033[1;104m"],
|
505
|
+
"Magenta Claro": ["\033[1;95m", "\033[1;105m"],
|
506
|
+
"Cyan Claro": ["\033[1;96m", "\033[1;106m"],
|
507
|
+
"Branco": ["\033[1;97m", "\033[1;107m"],
|
508
|
+
"Negrito": ["\033[;1m", None],
|
509
|
+
"Italico": ["\033[;3m", None],
|
510
|
+
"Sublinhado": ["\033[;4m", None],
|
511
|
+
"Riscado": ["\033[;9m", None],
|
512
|
+
"Inverte": ["\033[;7m", None],
|
513
|
+
"Reverse": ["\033[;17m", None],
|
514
|
+
"Reset": ["\033[0;0m", None]
|
515
|
+
}
|
516
|
+
except Exception as error:
|
517
|
+
print(error)
|
518
|
+
finally:
|
519
|
+
#son_file.close()
|
520
|
+
return cores
|
521
|
+
|
522
|
+
@staticmethod
|
523
|
+
def _os_info() -> dict:
|
524
|
+
os_info = {"user_os": os.getlogin(),
|
525
|
+
"user_db": None,
|
526
|
+
"local_ip": skt.gethostbyname(skt.gethostname()),
|
527
|
+
"local_name": skt.gethostname(),
|
528
|
+
"processor": so.machine(),
|
529
|
+
"so_platafor": so.platform(),
|
530
|
+
"so_system": so.system(),
|
531
|
+
"so_version": so.version()
|
532
|
+
}
|
533
|
+
return os_info
|
DE_Lib/Log/Level.py
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
from source.Utils import Colors as COR
|
2
|
+
|
3
|
+
cor = COR.Colors()
|
4
|
+
|
5
|
+
|
6
|
+
class Level:
|
7
|
+
def __init__(self):
|
8
|
+
self.__log__level__ = {"code":None, "name": None, "color": None}
|
9
|
+
self.__logEvent = {}
|
10
|
+
|
11
|
+
# region Level
|
12
|
+
@property
|
13
|
+
def NOTSET(self):
|
14
|
+
self.__log__level__["code"] = 0
|
15
|
+
self.__log__level__["name"] = "NOTSET"
|
16
|
+
self.__log__level__["color"] = cor.green_light_fore
|
17
|
+
return self.__log__level__
|
18
|
+
|
19
|
+
@property
|
20
|
+
def WARNING(self):
|
21
|
+
self.__log__level__["code"] = 10
|
22
|
+
self.__log__level__["name"] = "WARNING"
|
23
|
+
self.__log__level__["color"] = cor.yellow_light_fore
|
24
|
+
return self.__log__level__
|
25
|
+
|
26
|
+
@property
|
27
|
+
def DEBUG(self):
|
28
|
+
self.__log__level__["code"] = 20
|
29
|
+
self.__log__level__["name"] = "DEBUG"
|
30
|
+
self.__log__level__["color"] = cor.green_light_fore
|
31
|
+
return self.__log__level__
|
32
|
+
|
33
|
+
@property
|
34
|
+
def ERROR(self):
|
35
|
+
self.__log__level__["code"] = 30
|
36
|
+
self.__log__level__["name"] = "ERROR"
|
37
|
+
self.__log__level__["color"] = cor.red_light_fore
|
38
|
+
return self.__log__level__
|
39
|
+
|
40
|
+
@property
|
41
|
+
def INFO(self):
|
42
|
+
self.__log__level__["code"] = 40
|
43
|
+
self.__log__level__["name"] = "INFO"
|
44
|
+
self.__log__level__["color"] = cor.gray_light_fore
|
45
|
+
return self.__log__level__
|
46
|
+
|
47
|
+
@property
|
48
|
+
def CRITICAL(self):
|
49
|
+
self.__log__level__["code"] = 50
|
50
|
+
self.__log__level__["name"] = "CRITICAL"
|
51
|
+
self.__log__level__["color"] = cor.red_fore + cor.white_back
|
52
|
+
return self.__log__level__
|
53
|
+
|
54
|
+
@property
|
55
|
+
def DESTAQUE(self):
|
56
|
+
self.__log__level__["code"] = 50
|
57
|
+
self.__log__level__["name"] = "DESTAQUE"
|
58
|
+
self.__log__level__["color"] = cor.cyan_fore
|
59
|
+
return self.__log__level__
|
60
|
+
|
61
|
+
@property
|
62
|
+
def ENFASE(self):
|
63
|
+
self.__log__level__["code"] = 50
|
64
|
+
self.__log__level__["name"] = "ENFASE"
|
65
|
+
self.__log__level__["color"] = cor.white_fore + cor.bold + cor.underline
|
66
|
+
return self.__log__level__
|
67
|
+
|
68
|
+
@property
|
69
|
+
def LOG_LEVEL(self):
|
70
|
+
result = {"code": self.__log__level__["code"],
|
71
|
+
"name": self.__log__level__["name"],
|
72
|
+
"color": self.__log__level__["color"]
|
73
|
+
}
|
74
|
+
self.__logEvent[result["name"]] = {"code":result["code"], "color": result["color"]}
|
75
|
+
return result
|
76
|
+
# endregion
|
77
|
+
|