DE-Lib 0.0.20__py3-none-any.whl → 0.0.36__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/DataBase/Azure.py +22 -11
- DE_Lib/DataBase/Cache.py +8 -2
- DE_Lib/DataBase/Firebird.py +15 -6
- DE_Lib/DataBase/Informix.py +14 -4
- DE_Lib/DataBase/Metadata.py +1 -1
- DE_Lib/DataBase/MsSql.py +12 -6
- DE_Lib/DataBase/MySql.py +37 -11
- DE_Lib/DataBase/Oracle.py +105 -8
- DE_Lib/DataBase/OracleDDL.py +89 -0
- DE_Lib/DataBase/Postgres.py +15 -7
- DE_Lib/DataBase/RedShift.py +15 -7
- DE_Lib/DataBase/SQCipher.py +15 -11
- DE_Lib/DataBase/SQLite.py +38 -14
- DE_Lib/Files/Zip.py +119 -0
- DE_Lib/Log/Level.py +13 -13
- DE_Lib/Log/Log.py +61 -40
- DE_Lib/Utils/Cipher/Fernet.py +26 -5
- DE_Lib/Utils/Colors.py +1 -1
- DE_Lib/Utils/DateUtils.py +3 -3
- DE_Lib/Utils/Generic.py +30 -9
- DE_Lib/Utils/Sql.py +78 -0
- DE_Lib/Utils/System.py +53 -0
- DE_Lib/Utils/WebHook.py +3 -2
- {de_lib-0.0.20.dist-info → de_lib-0.0.36.dist-info}/METADATA +3 -2
- de_lib-0.0.36.dist-info/RECORD +49 -0
- {de_lib-0.0.20.dist-info → de_lib-0.0.36.dist-info}/WHEEL +1 -1
- DE_Lib/Utils/SQL.py +0 -34
- de_lib-0.0.20.dist-info/RECORD +0 -47
- {de_lib-0.0.20.dist-info → de_lib-0.0.36.dist-info/licenses}/LICENCE +0 -0
- {de_lib-0.0.20.dist-info → de_lib-0.0.36.dist-info}/top_level.txt +0 -0
DE_Lib/DataBase/SQCipher.py
CHANGED
@@ -1,29 +1,33 @@
|
|
1
|
+
import os
|
2
|
+
import json
|
1
3
|
|
4
|
+
from DE_Lib.Utils import Generic
|
2
5
|
|
3
|
-
|
6
|
+
gen = Generic.GENERIC()
|
7
|
+
|
8
|
+
class SQCIPHER:
|
4
9
|
def __init__(self):
|
5
10
|
self._connection_is_valid = None
|
6
11
|
self._nome_database = None
|
7
12
|
self._cnn = None
|
8
13
|
self.__database_error = None
|
9
14
|
|
10
|
-
def Connect(self,
|
15
|
+
def Connect(self, string_connect:dict, password):
|
11
16
|
DATABASE_NAME, result, msg, conn = None, False, None, None
|
12
17
|
try:
|
13
|
-
if os.path.isfile(
|
18
|
+
if os.path.isfile(os.path.join(string_connect["host"], string_connect["instance"])):
|
14
19
|
#conn = sqch.connect(database, password=password)
|
15
20
|
self._connection_is_valid = True
|
16
|
-
self._nome_database =
|
17
|
-
self._cnn =
|
18
|
-
|
19
|
-
msg = f"""SQLITE [{database}]- Não existe no local informado!"""
|
20
|
-
raise Exception(msg)
|
21
|
+
self._nome_database = gen.nvl(string_connect["database"], "")
|
22
|
+
self._cnn = result
|
23
|
+
self.__database_error = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nConexao bem sucedida!"""
|
21
24
|
except Exception as error:
|
22
|
-
|
25
|
+
msg = f"""{json.dumps(string_connect, indent=4).replace(string_connect["password"], "******")}\nFalha ao tentar se conectar com o banco de dados ORACLE\nException Error: {error} """
|
26
|
+
result = msg
|
23
27
|
self._connection_is_valid = False
|
24
|
-
self.
|
28
|
+
self.__database_error = msg
|
25
29
|
finally:
|
26
|
-
return
|
30
|
+
return result
|
27
31
|
|
28
32
|
@property
|
29
33
|
def CONNECTION(self):
|
DE_Lib/DataBase/SQLite.py
CHANGED
@@ -1,33 +1,49 @@
|
|
1
1
|
import sqlite3 as sq3
|
2
|
+
import sqlalchemy as sqa
|
2
3
|
import os
|
4
|
+
import json
|
3
5
|
|
4
|
-
|
6
|
+
from DE_Lib.Utils import Generic
|
7
|
+
|
8
|
+
gen = Generic.GENERIC()
|
9
|
+
|
10
|
+
class SQLITE:
|
5
11
|
def __init__(self):
|
6
12
|
self._connection_is_valid = None
|
7
13
|
self._nome_database = None
|
8
14
|
self._cnn = None
|
9
15
|
self.__database_error = None
|
10
16
|
|
11
|
-
def Connect(self,
|
12
|
-
|
17
|
+
def Connect(self, conn: dict, **kwargs):
|
18
|
+
msg, result = None, True
|
13
19
|
try:
|
14
|
-
|
20
|
+
__file = os.path.join(conn["host"], conn["instance"])
|
21
|
+
if os.path.isfile(__file):
|
15
22
|
if "check_same_thread" in kwargs.keys():
|
16
23
|
__check_same_thread = kwargs.get("check_same_thread")
|
17
24
|
else:
|
18
25
|
__check_same_thread = True
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
|
27
|
+
__conn = None
|
28
|
+
if not conn["driver_conexao"]:
|
29
|
+
__conn = sq3.connect(__file, check_same_thread=__check_same_thread)
|
30
|
+
elif conn["driver_conexao"].upper() == "SQLALCHEMY":
|
31
|
+
engine = sqa.create_engine(f"""sqlite:///{__file}""")
|
32
|
+
__conn = engine.connect()
|
33
|
+
else:
|
34
|
+
...
|
35
|
+
# driver nativo sqlite
|
36
|
+
|
37
|
+
self._connection_is_valid = True
|
38
|
+
self._cnn = __conn
|
39
|
+
self._nome_database = gen.nvl(conn["database"], "SQLite")
|
40
|
+
self.__database_driver = conn["driver_conexao"]
|
41
|
+
self.__database_error = result
|
26
42
|
except Exception as error:
|
27
|
-
msg = f"""
|
43
|
+
msg = f"""{json.dumps(conn, indent=4).replace(conn["password"], "******")}\nFalha ao tentar se conectar com o banco de dados SQLite\nException Error: {error} """
|
28
44
|
result = msg
|
29
45
|
self._connection_is_valid = False
|
30
|
-
self.__database_error = msg
|
46
|
+
self.__database_error = msg
|
31
47
|
finally:
|
32
48
|
return result
|
33
49
|
|
@@ -45,4 +61,12 @@ class SQLite:
|
|
45
61
|
|
46
62
|
@property
|
47
63
|
def DATABASE_ERROR(self):
|
48
|
-
return self.__database_error
|
64
|
+
return self.__database_error
|
65
|
+
|
66
|
+
@property
|
67
|
+
def DATABASE_DRIVER(self):
|
68
|
+
return self.__database_driver
|
69
|
+
|
70
|
+
@DATABASE_DRIVER.setter
|
71
|
+
def DATABASE_DRIVER(self, value):
|
72
|
+
self._DATABASE_DRIVER = value
|
DE_Lib/Files/Zip.py
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
import zipfile
|
2
|
+
from zipfile import ZipFile
|
3
|
+
import shutil
|
4
|
+
import os
|
5
|
+
|
6
|
+
|
7
|
+
class ZIP:
|
8
|
+
def __init__(self):
|
9
|
+
self.__read = ("r")
|
10
|
+
self.__write = "w"
|
11
|
+
self.__append = "a"
|
12
|
+
self.__moving = "MOVING"
|
13
|
+
self.__delete = "DELETE"
|
14
|
+
self.__nothing = "NOTHING"
|
15
|
+
self.__modo = None
|
16
|
+
|
17
|
+
# ---------------------------------
|
18
|
+
def ZipFiles(self):
|
19
|
+
msg, result = None, True
|
20
|
+
try:
|
21
|
+
...
|
22
|
+
except Exception as error:
|
23
|
+
msg = error
|
24
|
+
result = msg
|
25
|
+
finally:
|
26
|
+
return result
|
27
|
+
|
28
|
+
|
29
|
+
# ---------------------------------
|
30
|
+
def zip(self, files:list, zipfile: str, modo:str="w", action:str="NOTHING", moving:str=""):
|
31
|
+
msg, result = None, True
|
32
|
+
try:
|
33
|
+
# modo
|
34
|
+
with ZipFile(zipfile, modo) as zfh:
|
35
|
+
#zfh = ZipFile(file=zipfile, mode="w")
|
36
|
+
for file in files:
|
37
|
+
zfh.write(filename=file)
|
38
|
+
|
39
|
+
# action
|
40
|
+
if action == self.NOTHING:
|
41
|
+
pass
|
42
|
+
elif action == self.DELETE:
|
43
|
+
for file in files:
|
44
|
+
os.remove(file)
|
45
|
+
elif action == self.MOVING:
|
46
|
+
if os.path.isdir(moving):
|
47
|
+
shutil.move(file, moving)
|
48
|
+
except Exception as error:
|
49
|
+
msg = error
|
50
|
+
result = msg
|
51
|
+
finally:
|
52
|
+
return result
|
53
|
+
|
54
|
+
# ---------------------------------
|
55
|
+
def unzip(self, zipfile:str, outputfolder:str):
|
56
|
+
msg, result = None, True
|
57
|
+
try:
|
58
|
+
zfh = ZipFile(zipfile, self.READ)
|
59
|
+
zfh.extractall(outputfolder)
|
60
|
+
except Exception as error:
|
61
|
+
msg = error
|
62
|
+
result = msg
|
63
|
+
finally:
|
64
|
+
return result
|
65
|
+
|
66
|
+
|
67
|
+
@property
|
68
|
+
def NOTHING(self):
|
69
|
+
return self.__nothing
|
70
|
+
|
71
|
+
@NOTHING.setter
|
72
|
+
def NOTHING(self, value):
|
73
|
+
self.__nothing = value
|
74
|
+
|
75
|
+
|
76
|
+
@property
|
77
|
+
def DELETE(self):
|
78
|
+
return self.__delete
|
79
|
+
|
80
|
+
@DELETE.setter
|
81
|
+
def DELETE(self, value):
|
82
|
+
self.__delete = value
|
83
|
+
|
84
|
+
@property
|
85
|
+
def MOVING(self):
|
86
|
+
return self.__moving
|
87
|
+
|
88
|
+
@MOVING.setter
|
89
|
+
def MOVING(self, value):
|
90
|
+
self.__moving = value
|
91
|
+
|
92
|
+
|
93
|
+
@property
|
94
|
+
def APPEND(self):
|
95
|
+
return self.__append
|
96
|
+
|
97
|
+
@APPEND.setter
|
98
|
+
def APPEND(self, value):
|
99
|
+
self.__append = value
|
100
|
+
|
101
|
+
|
102
|
+
@property
|
103
|
+
def WRITE(self):
|
104
|
+
return self.__write
|
105
|
+
|
106
|
+
@WRITE.setter
|
107
|
+
def WRITE(self, value):
|
108
|
+
self.__write = value
|
109
|
+
|
110
|
+
|
111
|
+
@property
|
112
|
+
def READ(self):
|
113
|
+
return self.__read
|
114
|
+
|
115
|
+
@READ.setter
|
116
|
+
def READ(self, value):
|
117
|
+
self.__read = value
|
118
|
+
|
119
|
+
|
DE_Lib/Log/Level.py
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from DE_Lib.Utils import Colors
|
2
2
|
|
3
|
-
|
3
|
+
colors = Colors.COLORS()
|
4
4
|
|
5
5
|
|
6
|
-
class
|
6
|
+
class LEVEL:
|
7
7
|
def __init__(self):
|
8
8
|
self.__log__level__ = {"code":None, "name": None, "color": None}
|
9
9
|
self.__logEvent = {}
|
@@ -13,56 +13,56 @@ class Level:
|
|
13
13
|
def NOTSET(self):
|
14
14
|
self.__log__level__["code"] = 0
|
15
15
|
self.__log__level__["name"] = "NOTSET"
|
16
|
-
self.__log__level__["color"] =
|
16
|
+
self.__log__level__["color"] = colors.green_light_fore
|
17
17
|
return self.__log__level__
|
18
18
|
|
19
19
|
@property
|
20
20
|
def WARNING(self):
|
21
21
|
self.__log__level__["code"] = 10
|
22
22
|
self.__log__level__["name"] = "WARNING"
|
23
|
-
self.__log__level__["color"] =
|
23
|
+
self.__log__level__["color"] = colors.yellow_light_fore
|
24
24
|
return self.__log__level__
|
25
25
|
|
26
26
|
@property
|
27
27
|
def DEBUG(self):
|
28
28
|
self.__log__level__["code"] = 20
|
29
29
|
self.__log__level__["name"] = "DEBUG"
|
30
|
-
self.__log__level__["color"] =
|
30
|
+
self.__log__level__["color"] = colors.green_light_fore
|
31
31
|
return self.__log__level__
|
32
32
|
|
33
33
|
@property
|
34
34
|
def ERROR(self):
|
35
35
|
self.__log__level__["code"] = 30
|
36
36
|
self.__log__level__["name"] = "ERROR"
|
37
|
-
self.__log__level__["color"] =
|
37
|
+
self.__log__level__["color"] = colors.red_light_fore
|
38
38
|
return self.__log__level__
|
39
39
|
|
40
40
|
@property
|
41
41
|
def INFO(self):
|
42
42
|
self.__log__level__["code"] = 40
|
43
43
|
self.__log__level__["name"] = "INFO"
|
44
|
-
self.__log__level__["color"] =
|
44
|
+
self.__log__level__["color"] = colors.gray_light_fore
|
45
45
|
return self.__log__level__
|
46
46
|
|
47
47
|
@property
|
48
48
|
def CRITICAL(self):
|
49
49
|
self.__log__level__["code"] = 50
|
50
50
|
self.__log__level__["name"] = "CRITICAL"
|
51
|
-
self.__log__level__["color"] =
|
51
|
+
self.__log__level__["color"] = colors.red_fore + colors.white_back
|
52
52
|
return self.__log__level__
|
53
53
|
|
54
54
|
@property
|
55
55
|
def DESTAQUE(self):
|
56
|
-
self.__log__level__["code"] =
|
56
|
+
self.__log__level__["code"] = 60
|
57
57
|
self.__log__level__["name"] = "DESTAQUE"
|
58
|
-
self.__log__level__["color"] =
|
58
|
+
self.__log__level__["color"] = colors.cyan_fore
|
59
59
|
return self.__log__level__
|
60
60
|
|
61
61
|
@property
|
62
62
|
def ENFASE(self):
|
63
|
-
self.__log__level__["code"] =
|
63
|
+
self.__log__level__["code"] = 70
|
64
64
|
self.__log__level__["name"] = "ENFASE"
|
65
|
-
self.__log__level__["color"] =
|
65
|
+
self.__log__level__["color"] = colors.white_fore + colors.bold + colors.underline
|
66
66
|
return self.__log__level__
|
67
67
|
|
68
68
|
@property
|
DE_Lib/Log/Log.py
CHANGED
@@ -1,29 +1,25 @@
|
|
1
1
|
#region Imports
|
2
|
-
import sys
|
3
|
-
|
4
|
-
from source.Log import Level as LVL
|
5
|
-
from source.DataBase import SQLite as SLT
|
6
|
-
from source.Utils import DateUtils as DTU
|
7
|
-
from source.Utils import Generic as GEN
|
8
|
-
from source.Utils import System as SOP
|
9
|
-
from source.Utils import Colors as COR
|
10
2
|
import inspect
|
11
3
|
import os
|
12
4
|
import json
|
13
5
|
import datetime as dt
|
6
|
+
|
7
|
+
from DE_Lib.Log import Level
|
8
|
+
from DE_Lib.DataBase import SQLite as SLT
|
9
|
+
from DE_Lib.Utils import DateUtils, Generic, System, Colors
|
14
10
|
#endregion
|
15
11
|
|
16
12
|
#region Instancias
|
17
|
-
lvl =
|
18
|
-
slt = SLT.
|
19
|
-
dtu =
|
20
|
-
gen =
|
21
|
-
sop =
|
22
|
-
cor =
|
13
|
+
lvl = Level.LEVEL() # biblioteca LOG - Trata os niveis do log
|
14
|
+
slt = SLT.SQLITE() # biblioteca DataBase - Driver SQLite
|
15
|
+
dtu = DateUtils.DATEUTILS() # bibliotaca Utils.DateUtils - Tratamento de dadas
|
16
|
+
gen = Generic.GENERIC() # biblioteda Utils.Generic - diversas funcionalidades
|
17
|
+
sop = System.SO() # biblioteca Utils.SO - Diversar funcoes do sistema operacional
|
18
|
+
cor = Colors.COLORS() # biblioteca Utils.Colors - represantação de cores (utilizada na LOG)
|
23
19
|
#endregion
|
24
20
|
|
25
21
|
|
26
|
-
class
|
22
|
+
class LOG:
|
27
23
|
def __init__(self):
|
28
24
|
self.__processo = None
|
29
25
|
self.__list_log_detail = []
|
@@ -33,6 +29,8 @@ class Log:
|
|
33
29
|
def setInit(self, processo: dict):
|
34
30
|
msg, result = None, True
|
35
31
|
try:
|
32
|
+
self.TABLE_LOG = processo["table"]
|
33
|
+
self.TABLE_EVENT = processo["event"]
|
36
34
|
self.__processo = processo
|
37
35
|
self.__call_origin = self.__getCALLFUNCTION()
|
38
36
|
self.__log_header = self.__setLogHeader()
|
@@ -70,9 +68,9 @@ class Log:
|
|
70
68
|
print(self.__setPrintFinalizacao())
|
71
69
|
|
72
70
|
rst = self.setInsertLOG()
|
73
|
-
print(rst)
|
71
|
+
#print(rst)
|
74
72
|
rst = self.setInsertEVENT()
|
75
|
-
print(rst)
|
73
|
+
#print(rst)
|
76
74
|
|
77
75
|
#print(json.dumps(__log, indent=4))
|
78
76
|
except Exception as error:
|
@@ -91,16 +89,16 @@ class Log:
|
|
91
89
|
"nom_rotina": self.PROCESSO["processo"],
|
92
90
|
"nom_subrotina": self.CALL_FUNCTION,
|
93
91
|
"descricao": self.PROCESSO["descricao"],
|
94
|
-
"
|
95
|
-
"user_db": "",
|
92
|
+
"filename": self.FILELOG,
|
96
93
|
"os_user": sop.OSINFO["os_user"],
|
94
|
+
"user_db": "",
|
97
95
|
"local_ip": sop.OSINFO["local_ip"],
|
98
96
|
"local_name": sop.OSINFO["local_name"],
|
99
97
|
"processor": sop.OSINFO["processor"],
|
100
98
|
"so_platform": sop.OSINFO["so_platform"],
|
101
99
|
"so_system": sop.OSINFO["so_system"],
|
102
100
|
"so_version": sop.OSINFO["so_version"],
|
103
|
-
"
|
101
|
+
"datahoralog": dt.datetime.now().strftime(dtu.MILLISECONDS_FORMAT_PYTHON),
|
104
102
|
"versao": sop.OSINFO["so_version"]
|
105
103
|
}
|
106
104
|
result = __header
|
@@ -115,7 +113,7 @@ class Log:
|
|
115
113
|
try:
|
116
114
|
__detail = {"hash": gen.build_key(),
|
117
115
|
"hash_parent": self.LOG_HEADER["hash"],
|
118
|
-
"
|
116
|
+
"datahoralog": dt.datetime.now().strftime(dtu.MILLISECONDS_FORMAT_PYTHON),
|
119
117
|
"level_code": level["code"],
|
120
118
|
"level_name": level["name"],
|
121
119
|
"function_name": self.CALL_FUNCTION,
|
@@ -178,7 +176,7 @@ class Log:
|
|
178
176
|
def __setPrintScreen(self, level, lf: bool = True, onscreen: bool = True):
|
179
177
|
if onscreen:
|
180
178
|
__log = self.LOG_DETAIL[-1]
|
181
|
-
__text = f"""{cor.reset}{__log["
|
179
|
+
__text = f"""{cor.reset}{__log["datahoralog"]}-{level["color"]}{__log["level_name"].ljust(10)}{cor.reset}: {level["color"]}{__log["event_content"]}{cor.reset}"""
|
182
180
|
if lf:
|
183
181
|
print(__text)
|
184
182
|
else:
|
@@ -193,7 +191,7 @@ class Log:
|
|
193
191
|
msg, result = None, True
|
194
192
|
try:
|
195
193
|
# Foi passado um nome de arquivo de log
|
196
|
-
if self.PROCESSO["
|
194
|
+
if self.PROCESSO["filename"] is None:
|
197
195
|
if not os.path.isdir(os.path.dirname(self.FILELOG)):
|
198
196
|
# se o diretorio informado não existir sera utilizado o diretorio local
|
199
197
|
if os.path.basename(self.FILELOG) is None:
|
@@ -211,7 +209,7 @@ class Log:
|
|
211
209
|
def __getCALLFUNCTION(self, value = inspect.stack()):
|
212
210
|
msg, result = None, True
|
213
211
|
try:
|
214
|
-
result = {"
|
212
|
+
result = {"filename":value[1].filename,
|
215
213
|
"line": value[1].lineno,
|
216
214
|
"function": value[1].function,
|
217
215
|
"code_context": value[1].code_context[0].strip(),
|
@@ -226,7 +224,7 @@ class Log:
|
|
226
224
|
def __setFileName(self, value):
|
227
225
|
msg, result = None, True
|
228
226
|
try:
|
229
|
-
self.__processo["
|
227
|
+
self.__processo["filename"] = value
|
230
228
|
except Exception as error:
|
231
229
|
msg = error
|
232
230
|
result = msg
|
@@ -255,7 +253,7 @@ class Log:
|
|
255
253
|
|
256
254
|
@property
|
257
255
|
def CALL_FILE(self):
|
258
|
-
return self.__call_origin["
|
256
|
+
return self.__call_origin["filename"]
|
259
257
|
|
260
258
|
@property
|
261
259
|
def CALL_CONTEXT(self):
|
@@ -287,28 +285,28 @@ class Log:
|
|
287
285
|
try:
|
288
286
|
owner = ""
|
289
287
|
stmt = f"""
|
290
|
-
Insert into {
|
288
|
+
Insert into {self.TABLE_LOG}
|
291
289
|
(HASH
|
292
290
|
,NOM_ROTINA
|
293
291
|
,NOM_SUBROTINA
|
294
292
|
,DESCRICAO
|
295
|
-
,FILE
|
296
|
-
,OS_USER
|
297
|
-
,USER_DB
|
293
|
+
,"FILE"
|
294
|
+
,"OS_USER"
|
295
|
+
,"USER_DB"
|
298
296
|
,LOCAL_IP
|
299
297
|
,LOCAL_NAME
|
300
298
|
,PROCESSOR
|
301
299
|
,SO_PLATFORM
|
302
300
|
,SO_SYSTEM
|
303
301
|
,SO_VERSION
|
304
|
-
,TIMESTAMP
|
302
|
+
,"TIMESTAMP"
|
305
303
|
,VERSAO
|
306
304
|
)
|
307
305
|
VALUES(:hash
|
308
306
|
,:nom_rotina
|
309
307
|
,:nom_subrotina
|
310
308
|
,:descricao
|
311
|
-
,:
|
309
|
+
,:filename
|
312
310
|
,:os_user
|
313
311
|
,:user_db
|
314
312
|
,:local_ip
|
@@ -317,18 +315,22 @@ class Log:
|
|
317
315
|
,:so_platform
|
318
316
|
,:so_system
|
319
317
|
,:so_version
|
320
|
-
|
318
|
+
,to_timestamp(:datahoralog, '{dtu.MILLISECONDS_FORMAT_SQL}')
|
321
319
|
,:versao
|
322
320
|
)
|
323
321
|
"""
|
324
322
|
if self.CONN is not None:
|
325
323
|
__head = self.LOG_HEADER
|
326
324
|
del(__head["event_content"])
|
327
|
-
self.CONN.
|
325
|
+
cur = self.CONN.cursor()
|
326
|
+
cur.execute(stmt, __head)
|
328
327
|
self.CONN.commit()
|
328
|
+
cur.close()
|
329
|
+
#self.CONN.close()
|
329
330
|
result = "Log HEADER criado!"
|
330
331
|
else:
|
331
|
-
|
332
|
+
...
|
333
|
+
#raise Exception("Não foi fornecido uma conexao com banco de dados!")
|
332
334
|
except Exception as error:
|
333
335
|
msg = error
|
334
336
|
result = msg
|
@@ -341,10 +343,10 @@ class Log:
|
|
341
343
|
try:
|
342
344
|
owner = ""
|
343
345
|
stmt = f"""
|
344
|
-
Insert into {
|
346
|
+
Insert into {self.TABLE_EVENT}
|
345
347
|
(HASH
|
346
348
|
,HASH_PARENT
|
347
|
-
,TIMESTAMP
|
349
|
+
,"TIMESTAMP"
|
348
350
|
,LEVEL_CODE
|
349
351
|
,LEVEL_NAME
|
350
352
|
,FUNCTION_NAME
|
@@ -356,7 +358,7 @@ class Log:
|
|
356
358
|
)
|
357
359
|
VALUES(:hash
|
358
360
|
,:hash_parent
|
359
|
-
|
361
|
+
,to_timestamp(:datahoralog, '{dtu.MILLISECONDS_FORMAT_SQL}')
|
360
362
|
,:level_code
|
361
363
|
,:level_name
|
362
364
|
,:function_name
|
@@ -369,11 +371,15 @@ class Log:
|
|
369
371
|
"""
|
370
372
|
if self.CONN is not None:
|
371
373
|
__detail = self.LOG_DETAIL
|
372
|
-
self.CONN.
|
374
|
+
cur = self.CONN.cursor()
|
375
|
+
cur.executemany(stmt, (__detail))
|
373
376
|
self.CONN.commit()
|
377
|
+
cur.close()
|
378
|
+
#self.CONN.close()
|
374
379
|
result = "Log DETAIL criado!"
|
375
380
|
else:
|
376
|
-
|
381
|
+
...
|
382
|
+
#raise Exception("Não foi fornecido uma conexao com banco de dados!")
|
377
383
|
except Exception as error:
|
378
384
|
msg = error
|
379
385
|
result = msg
|
@@ -468,3 +474,18 @@ class Log:
|
|
468
474
|
return result
|
469
475
|
#endregion
|
470
476
|
|
477
|
+
@property
|
478
|
+
def TABLE_LOG(self):
|
479
|
+
return self.__TABLE_LOG
|
480
|
+
|
481
|
+
@TABLE_LOG.setter
|
482
|
+
def TABLE_LOG(self, value):
|
483
|
+
self.__TABLE_LOG = value
|
484
|
+
|
485
|
+
@property
|
486
|
+
def TABLE_EVENT(self):
|
487
|
+
return self.__TABLE_EVENT
|
488
|
+
|
489
|
+
@TABLE_EVENT.setter
|
490
|
+
def TABLE_EVENT(self, value):
|
491
|
+
self.__TABLE_EVENT = value
|
DE_Lib/Utils/Cipher/Fernet.py
CHANGED
@@ -8,11 +8,11 @@ class FERNET:
|
|
8
8
|
self.__cipher = None
|
9
9
|
|
10
10
|
# -----------------------------------
|
11
|
-
def encrypt(self, word:str
|
11
|
+
def encrypt(self, word:str):
|
12
12
|
msg, result = None, None
|
13
13
|
try:
|
14
14
|
#x = Fernet(key)
|
15
|
-
result = self.CIPHER.encrypt(word.encode())
|
15
|
+
result = self.CIPHER.encrypt(word.encode()).hex()
|
16
16
|
except Exception as error:
|
17
17
|
msg = error
|
18
18
|
result = msg
|
@@ -23,7 +23,8 @@ class FERNET:
|
|
23
23
|
def decrypt(self, word):
|
24
24
|
msg, result = None, True
|
25
25
|
try:
|
26
|
-
|
26
|
+
bytes_word = bytes.fromhex(word).decode()
|
27
|
+
result = self.CIPHER.decrypt(bytes_word).decode()
|
27
28
|
except Exception as error:
|
28
29
|
msg = error
|
29
30
|
result = msg
|
@@ -39,7 +40,7 @@ class FERNET:
|
|
39
40
|
# serao perdidas.
|
40
41
|
msg, result = None, True
|
41
42
|
try:
|
42
|
-
self.__token = Fernet.generate_key()
|
43
|
+
self.__token = Fernet.generate_key().hex()
|
43
44
|
result = self.TOKEN
|
44
45
|
except Exception as error:
|
45
46
|
msg = error
|
@@ -51,7 +52,7 @@ class FERNET:
|
|
51
52
|
def setToken(self, token):
|
52
53
|
msg, result = None, True
|
53
54
|
try:
|
54
|
-
self.__token = token
|
55
|
+
self.__token = bytes.fromhex(token)
|
55
56
|
except Exception as error:
|
56
57
|
msg = error
|
57
58
|
result = msg
|
@@ -79,3 +80,23 @@ class FERNET:
|
|
79
80
|
def CIPHER(self):
|
80
81
|
return Fernet(self.TOKEN)
|
81
82
|
|
83
|
+
|
84
|
+
if __name__ == "__main__":
|
85
|
+
x = FERNET()
|
86
|
+
token = x.setBuildToken()
|
87
|
+
|
88
|
+
# __token = "cXBRJulOb_arFkWjsOZF0JprhAb0FjsC5xRTcn63WQE="
|
89
|
+
# x.setToken(__token)
|
90
|
+
# print("Token: ",x.TOKEN)
|
91
|
+
#
|
92
|
+
# __root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..",".."))
|
93
|
+
# __file = os.path.join(__root, "config", "tokens", "base_conexao.json")
|
94
|
+
# __buffer = open(__file, "r").read()
|
95
|
+
# __word = __buffer
|
96
|
+
#
|
97
|
+
# #__word = "teste "*1000
|
98
|
+
# print("__word:" ,__word)
|
99
|
+
# __ENCRYPT = x.encrypt(word=__word)
|
100
|
+
# print("Encrypt: ",__ENCRYPT)
|
101
|
+
# __DECRYPT = x.decrypt(__ENCRYPT)
|
102
|
+
# print("Decrypt: ", __DECRYPT)
|
DE_Lib/Utils/Colors.py
CHANGED
DE_Lib/Utils/DateUtils.py
CHANGED
@@ -2,7 +2,7 @@ import datetime as dt
|
|
2
2
|
from datetime import timedelta
|
3
3
|
from dateutil.relativedelta import relativedelta
|
4
4
|
|
5
|
-
class
|
5
|
+
class DATEUTILS:
|
6
6
|
def __init__(self):
|
7
7
|
...
|
8
8
|
|
@@ -187,7 +187,7 @@ class DateUtils:
|
|
187
187
|
|
188
188
|
@property
|
189
189
|
def MILLISECONDS_FORMAT_PYTHON(self):
|
190
|
-
return "%Y-%m-%d %H:%M:%S
|
190
|
+
return "%Y-%m-%d %H:%M:%S.%f"
|
191
191
|
|
192
192
|
@property
|
193
193
|
def TIME_FORMAT_PYTHON(self):
|
@@ -203,7 +203,7 @@ class DateUtils:
|
|
203
203
|
|
204
204
|
@property
|
205
205
|
def MILLISECONDS_FORMAT_SQL(self):
|
206
|
-
return "YYYY-MM-DD HH24:MI:SS
|
206
|
+
return "YYYY-MM-DD HH24:MI:SS.FF6"
|
207
207
|
|
208
208
|
@property
|
209
209
|
def TIME_FORMAT_SQL(self):
|