Spaces:
Sleeping
Sleeping
Integración Firebase
Browse files- archivos/last_timestamp.txt +1 -1
- archivos/seconds_available.txt +1 -1
- herramientas.py +11 -5
- pruebas_firebase.py +3 -3
archivos/last_timestamp.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
1747155744
|
archivos/seconds_available.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
294
|
herramientas.py
CHANGED
|
@@ -3,14 +3,18 @@ import time
|
|
| 3 |
import socket
|
| 4 |
from datetime import datetime
|
| 5 |
from datetime import datetime, date, timedelta
|
|
|
|
| 6 |
|
| 7 |
def obtenAccesoHF():
|
| 8 |
if local_check():
|
| 9 |
print("Estoy en entorno Local...")
|
| 10 |
import bridges
|
|
|
|
| 11 |
llave = bridges.llave
|
|
|
|
| 12 |
else:
|
| 13 |
print("Estoy en entorno Remoto...")
|
|
|
|
| 14 |
llave = os.getenv("llave")
|
| 15 |
return llave
|
| 16 |
|
|
@@ -33,9 +37,11 @@ def obtenUltimoTimestamp():
|
|
| 33 |
Obtiene el último timestamp de renovación guardado.
|
| 34 |
"""
|
| 35 |
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
try:
|
|
|
|
| 39 |
with open(archivo_ruta, 'r') as archivo:
|
| 40 |
contenido = archivo.readline().strip()
|
| 41 |
ultimo_timestamp = int(contenido)
|
|
@@ -46,6 +52,8 @@ def obtenUltimoTimestamp():
|
|
| 46 |
except ValueError:
|
| 47 |
print(f"Error: El contenido del archivo '{archivo_ruta}' no es un número entero válido.")
|
| 48 |
return
|
|
|
|
|
|
|
| 49 |
|
| 50 |
def esNuevoDia():
|
| 51 |
"""
|
|
@@ -54,8 +62,7 @@ def esNuevoDia():
|
|
| 54 |
"""
|
| 55 |
|
| 56 |
timestamp_original = obtenUltimoTimestamp()
|
| 57 |
-
timestamp_actual = int(time.time())
|
| 58 |
-
|
| 59 |
|
| 60 |
try:
|
| 61 |
segundos_en_24_horas = 24 * 60 * 60
|
|
@@ -70,9 +77,8 @@ def obtenSegundosDisponibles():
|
|
| 70 |
if esDiaSiguiente() == True:
|
| 71 |
renuevaSegundosDisponibles()
|
| 72 |
|
| 73 |
-
archivo_ruta = "archivos/seconds_available.txt"
|
| 74 |
-
|
| 75 |
try:
|
|
|
|
| 76 |
# Leer el número actual de segundos disponibles
|
| 77 |
with open(archivo_ruta, 'r') as archivo:
|
| 78 |
contenido = archivo.readline().strip()
|
|
|
|
| 3 |
import socket
|
| 4 |
from datetime import datetime
|
| 5 |
from datetime import datetime, date, timedelta
|
| 6 |
+
import conexion_firebase
|
| 7 |
|
| 8 |
def obtenAccesoHF():
|
| 9 |
if local_check():
|
| 10 |
print("Estoy en entorno Local...")
|
| 11 |
import bridges
|
| 12 |
+
#Acceso a HF
|
| 13 |
llave = bridges.llave
|
| 14 |
+
#Acceso a Firebase
|
| 15 |
else:
|
| 16 |
print("Estoy en entorno Remoto...")
|
| 17 |
+
#Acceso a HF
|
| 18 |
llave = os.getenv("llave")
|
| 19 |
return llave
|
| 20 |
|
|
|
|
| 37 |
Obtiene el último timestamp de renovación guardado.
|
| 38 |
"""
|
| 39 |
|
| 40 |
+
resultado = conexion_firebase.obtenDato('nowme', 'huggingface', 'last_timestamp')
|
| 41 |
+
print("El last_timestamp de firebase es: ", resultado)
|
| 42 |
|
| 43 |
try:
|
| 44 |
+
archivo_ruta = "archivos/last_timestamp.txt"
|
| 45 |
with open(archivo_ruta, 'r') as archivo:
|
| 46 |
contenido = archivo.readline().strip()
|
| 47 |
ultimo_timestamp = int(contenido)
|
|
|
|
| 52 |
except ValueError:
|
| 53 |
print(f"Error: El contenido del archivo '{archivo_ruta}' no es un número entero válido.")
|
| 54 |
return
|
| 55 |
+
|
| 56 |
+
|
| 57 |
|
| 58 |
def esNuevoDia():
|
| 59 |
"""
|
|
|
|
| 62 |
"""
|
| 63 |
|
| 64 |
timestamp_original = obtenUltimoTimestamp()
|
| 65 |
+
timestamp_actual = int(time.time())
|
|
|
|
| 66 |
|
| 67 |
try:
|
| 68 |
segundos_en_24_horas = 24 * 60 * 60
|
|
|
|
| 77 |
if esDiaSiguiente() == True:
|
| 78 |
renuevaSegundosDisponibles()
|
| 79 |
|
|
|
|
|
|
|
| 80 |
try:
|
| 81 |
+
archivo_ruta = "archivos/seconds_available.txt"
|
| 82 |
# Leer el número actual de segundos disponibles
|
| 83 |
with open(archivo_ruta, 'r') as archivo:
|
| 84 |
contenido = archivo.readline().strip()
|
pruebas_firebase.py
CHANGED
|
@@ -3,7 +3,7 @@ import conexion_firebase as cf
|
|
| 3 |
#dato el el nombre del documento.
|
| 4 |
#info es la info de ese dato que estás buscando, como token.
|
| 5 |
#obtenDato(coleccion, dato, info):
|
| 6 |
-
resultado = cf.obtenDato('nowme', 'huggingface', 'segundos')
|
| 7 |
-
print(resultado)
|
| 8 |
|
| 9 |
-
resultado = cf.editaDato('nowme', 'huggingface', 'segundos')
|
|
|
|
| 3 |
#dato el el nombre del documento.
|
| 4 |
#info es la info de ese dato que estás buscando, como token.
|
| 5 |
#obtenDato(coleccion, dato, info):
|
| 6 |
+
#resultado = cf.obtenDato('nowme', 'huggingface', 'segundos')
|
| 7 |
+
#print(resultado)
|
| 8 |
|
| 9 |
+
resultado = cf.editaDato('nowme', 'huggingface', 'segundos', 200)
|