servextools 0.1.0__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Servextex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: servextools
3
+ Version: 0.1.0
4
+ Summary: Herramientas para Servextex
5
+ Home-page: https://github.com/Servextex/ServexTools
6
+ Author: Servextex
7
+ Author-email: Servextex <info@servextex.com.do>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Servextex
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+
30
+ Requires-Python: >=3.8
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: flask
34
+ Requires-Dist: pymongo
35
+ Requires-Dist: pytz
36
+ Requires-Dist: PyJWT
37
+ Requires-Dist: httpx
38
+ Requires-Dist: eventlet
39
+ Requires-Dist: flask-socketio
40
+ Requires-Dist: tqdm
41
+ Requires-Dist: bson
42
+ Dynamic: author
43
+ Dynamic: home-page
44
+ Dynamic: license-file
45
+ Dynamic: requires-python
46
+
47
+ # ServexTools
48
+
49
+ Herramientas para Servextex: utilidades para manejo de datos, logs, fechas, sockets y replicación MongoDB.
50
+
51
+ ## Instalación
52
+
53
+ ```sh
54
+ pip install servextools
55
+ ```
56
+
57
+ ## Uso básico
58
+
59
+ ```python
60
+ from ServexTools import Tools
61
+
62
+ # Ejemplo de uso
63
+ dato = Tools.FormatearValor(123.45)
64
+ print(dato)
65
+ ```
66
+
67
+ ## Licencia
68
+
69
+ MIT
@@ -0,0 +1,23 @@
1
+ # ServexTools
2
+
3
+ Herramientas para Servextex: utilidades para manejo de datos, logs, fechas, sockets y replicación MongoDB.
4
+
5
+ ## Instalación
6
+
7
+ ```sh
8
+ pip install servextools
9
+ ```
10
+
11
+ ## Uso básico
12
+
13
+ ```python
14
+ from ServexTools import Tools
15
+
16
+ # Ejemplo de uso
17
+ dato = Tools.FormatearValor(123.45)
18
+ print(dato)
19
+ ```
20
+
21
+ ## Licencia
22
+
23
+ MIT
@@ -0,0 +1,7 @@
1
+ class TipoMensaje:
2
+ ALT = "ALT"
3
+ MSJ = "MSJ"
4
+
5
+ class Metodo:
6
+ GET = "GET"
7
+ POST = "POST"
@@ -0,0 +1,155 @@
1
+ from datetime import datetime
2
+ import os
3
+ import ServexTools.Tools as Tools
4
+ from ServexTools.GetTime import CalDias
5
+
6
+ def GetDirectorio():
7
+ return Tools.OptenerRutaApp()
8
+
9
+
10
+ def EscribirLog(texto, tipo="Error"):
11
+
12
+ try:
13
+ dia = datetime.now().day
14
+ mes = datetime.now().month
15
+ year = datetime.now().year
16
+ Hora = str(datetime.now().hour) + ":" + str(datetime.now().minute)
17
+ tiempo = str(dia) + "/" + str(mes) + "/" + str(year) + " " + Hora
18
+ Directorio=GetDirectorio()+"Log"
19
+ if Tools.ExisteDirectorio(Directorio)==False:
20
+ os.mkdir(Directorio)
21
+ mensajeActual = ""
22
+ Url = Directorio+"/Success.log" if tipo != "Error" else Directorio+"/Error.log"
23
+ try:
24
+ if Tools.ExistFile(Url):
25
+ creados=Tools.OptenerFechaArchivo(Url)
26
+ if CalDias(fechaInicial=creados)>=30:
27
+ Tools.DeleteFile(Url)
28
+ else:
29
+ zise=os.path.getsize(Url)
30
+ numero,medida=Tools.convert_size(zise)
31
+ if medida=="MB" and numero>10.0:
32
+ Tools.DeleteFile(Url)
33
+ except Exception as e:
34
+ print(str(e))
35
+
36
+ if Tools.ExistFile(Url):
37
+ mensajeActual = Tools.ReadFile(Url)
38
+
39
+
40
+ mensaje=tiempo + ": " + texto + "\n" + mensajeActual
41
+ msjprint=tiempo + ": " + texto + "\n"
42
+ print(msjprint)
43
+ Tools.WriteFile(Url,mensaje)
44
+ except Exception as e:
45
+ print(str(e))
46
+
47
+ def EscribirConsola(texto):
48
+ try:
49
+ dia = datetime.now().day
50
+ mes = datetime.now().month
51
+ year = datetime.now().year
52
+ Hora = str(datetime.now().hour) + ":" + str(datetime.now().minute)
53
+ tiempo = str(dia) + "/" + str(mes) + "/" + str(year) + " " + Hora
54
+ Directorio=GetDirectorio()+"Log"
55
+ if Tools.ExisteDirectorio(Directorio)==False:
56
+ os.mkdir(Directorio)
57
+ mensajeActual = ""
58
+ Url = Directorio+"/Consola.log"
59
+ try:
60
+ if Tools.ExistFile(Url):
61
+ creados=Tools.OptenerFechaArchivo(Url)
62
+ if CalDias(fechaInicial=creados)>=30:
63
+ Tools.DeleteFile(Url)
64
+ else:
65
+ zise=os.path.getsize(Url)
66
+ numero,medida=Tools.convert_size(zise)
67
+ if medida=="MB" and numero>10.0:
68
+ Tools.DeleteFile(Url)
69
+ except Exception as e:
70
+ print(str(e))
71
+
72
+ if Tools.ExistFile(Url):
73
+ mensajeActual = Tools.ReadFile(Url)
74
+
75
+
76
+ mensaje=tiempo + ": " + texto + "\n" + mensajeActual
77
+ msjprint=tiempo + ": " + texto + "\n"
78
+ # mensaje="******" + tiempo + "******\n" + texto + "\n******************\n" + mensajeActual
79
+ # msjprint="******" + tiempo + "******\n" + texto + "\n******************\n"
80
+ print(msjprint)
81
+ Tools.WriteFile(Url,mensaje)
82
+ except Exception as e:
83
+ print(str(e))
84
+
85
+ def EscribirProcesos(texto):
86
+ try:
87
+ dia = datetime.now().day
88
+ mes = datetime.now().month
89
+ year = datetime.now().year
90
+ Hora = str(datetime.now().hour) + ":" + str(datetime.now().minute)
91
+ tiempo = str(dia) + "/" + str(mes) + "/" + str(year) + " " + Hora
92
+ Directorio=GetDirectorio()+"Log"
93
+ if Tools.ExisteDirectorio(Directorio)==False:
94
+ os.mkdir(Directorio)
95
+ mensajeActual = ""
96
+ Url = Directorio+"/Procesos.log"
97
+
98
+ try:
99
+ if Tools.ExistFile(Url):
100
+ creados=Tools.OptenerFechaArchivo(Url)
101
+ if CalDias(fechaInicial=creados)>=30:
102
+ Tools.DeleteFile(Url)
103
+ else:
104
+ zise=os.path.getsize(Url)
105
+ numero,medida=Tools.convert_size(zise)
106
+ if medida=="MB" and numero>10.0:
107
+ Tools.DeleteFile(Url)
108
+ except Exception as e:
109
+ print(str(e))
110
+
111
+ if Tools.ExistFile(Url):
112
+ mensajeActual = Tools.ReadFile(Url)
113
+
114
+
115
+ mensaje=tiempo + ": " + texto + "\n" + mensajeActual
116
+ Tools.WriteFile(Url,mensaje)
117
+ except Exception as e:
118
+ print(str(e))
119
+
120
+ def EscribirUpdate(texto):
121
+ try:
122
+ from app import socketio as io
123
+ dia = datetime.now().day
124
+ mes = datetime.now().month
125
+ year = datetime.now().year
126
+ Hora = str(datetime.now().hour) + ":" + str(datetime.now().minute)
127
+ tiempo = str(dia) + "/" + str(mes) + "/" + str(year) + " " + Hora
128
+ Directorio=GetDirectorio()+"Log"
129
+ if Tools.ExisteDirectorio(Directorio)==False:
130
+ os.mkdir(Directorio)
131
+ mensajeActual = ""
132
+ Url = Directorio+"/Update.log"
133
+ try:
134
+ if Tools.ExistFile(Url):
135
+ creados=Tools.OptenerFechaArchivo(Url)
136
+ if CalDias(fechaInicial=creados)>=30:
137
+ Tools.DeleteFile(Url)
138
+ else:
139
+ zise=os.path.getsize(Url)
140
+ numero,medida=Tools.convert_size(zise)
141
+ if medida=="MB" and numero>10.0:
142
+ Tools.DeleteFile(Url)
143
+ except Exception as e:
144
+ print(str(e))
145
+
146
+ if Tools.ExistFile(Url):
147
+ mensajeActual = Tools.ReadFile(Url)
148
+
149
+
150
+ mensaje=tiempo + ": " + texto + "\n" + mensajeActual
151
+ Tools.WriteFile(Url,mensaje)
152
+ io.emit("EscribirEnConsola",mensaje)
153
+ EscribirConsola(texto)
154
+ except Exception as e:
155
+ print(str(e))
@@ -0,0 +1,62 @@
1
+ from datetime import datetime
2
+ import math
3
+
4
+ def CalDias(fechaInicial,FechaActual=datetime.now(),tiempoGratis=0):
5
+ days=0
6
+ diff_date = FechaActual - fechaInicial
7
+ if diff_date.total_seconds() > ((tiempoGratis+1)*60):
8
+ days = math.ceil(diff_date.total_seconds()/86400)
9
+ return days
10
+
11
+ def CalDiasExactos(fechaInicial):
12
+ FechaActual=datetime.now()
13
+ diff_date = FechaActual - fechaInicial
14
+ return diff_date.days
15
+
16
+ def CalHoras(fechaInicial,FechaActual=datetime.now(),tiempoGratis=0,redondear=True):
17
+ horas=0
18
+ diff_date = FechaActual - fechaInicial
19
+ if diff_date.total_seconds() > ((tiempoGratis+1)*60):
20
+ if redondear:
21
+ horas = math.ceil(diff_date.total_seconds()/3600)
22
+ else:
23
+ return CalMinutos(fechaInicial,FechaActual,tiempoGratis)
24
+ return horas
25
+
26
+ def CalMinutos(fechaInicial,FechaActual=datetime.now(),tiempoGratis=0):
27
+ minutos=0
28
+ diff_date = FechaActual - fechaInicial
29
+ if diff_date.total_seconds() > ((tiempoGratis+1)*60):
30
+ minutos = math.ceil(diff_date.total_seconds()/60)
31
+ return minutos
32
+
33
+ def CalSegundos(fechaInicial):
34
+ FechaActual=datetime.now()
35
+ diff_date = FechaActual - fechaInicial
36
+ return diff_date.total_seconds()
37
+
38
+ def CalHolaYMinutos(fechaInicial,fechaFinal=datetime.now()):
39
+ horas=0
40
+ diff_date = fechaFinal-fechaInicial
41
+ tim=str(diff_date).split(':')
42
+
43
+ horas=tim[0]
44
+ minutos=tim[1]
45
+ horasYminutos=tim[0]+':'+tim[1]
46
+ #return horas,minutos,horasYminutos
47
+ return horasYminutos
48
+
49
+
50
+ def CalMinutosTransc(fechaInicial):
51
+ try:
52
+ horas=0
53
+ diff_date = datetime.now()-fechaInicial
54
+ tim=str(diff_date).split(':')
55
+
56
+ horas=tim[0]
57
+ minutos=tim[1]
58
+ horasYminutos=tim[0]+tim[1]
59
+ #return horas,minutos,horasYminutos
60
+ return int(horasYminutos)
61
+ except Exception as e:
62
+ return 10