Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import platform
|
|
4 |
import locale
|
5 |
import logging
|
6 |
import tempfile
|
|
|
7 |
|
8 |
import torch
|
9 |
from transformers import MarianMTModel, MarianTokenizer
|
@@ -403,16 +404,16 @@ def boton_actualizar_fuentes(files):
|
|
403 |
fuentes_cache = cargar_fuentes_cache()
|
404 |
for file in files:
|
405 |
if file.name.lower().endswith('.ttf'):
|
406 |
-
destino = os.path.join(tempfile.gettempdir(),
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
|
|
411 |
fuentes_cache[nombre_fuente] = destino
|
412 |
logger.info(f"Fuente '{file.name}' subida y guardada en {destino}")
|
413 |
else:
|
414 |
logger.warning(f"Archivo '{file.name}' no es una fuente .ttf y ser谩 omitido.")
|
415 |
-
|
416 |
# Actualizar el cach茅
|
417 |
cache_path = os.path.join(tempfile.gettempdir(), 'fuentes_sistema.json')
|
418 |
with open(cache_path, 'w', encoding='utf-8') as f:
|
@@ -425,8 +426,6 @@ def boton_actualizar_fuentes(files):
|
|
425 |
return "Fuentes actualizadas exitosamente."
|
426 |
except Exception as e:
|
427 |
logger.error(f"Error al actualizar fuentes: {e}")
|
428 |
-
import traceback
|
429 |
-
traceback.print_exc() # This will print the full stack trace
|
430 |
return f"Error al actualizar fuentes: {e}"
|
431 |
|
432 |
def procesar_pdf(archivo_pdf, fuentes_subidas):
|
@@ -514,4 +513,4 @@ with gr.Blocks(
|
|
514 |
)
|
515 |
|
516 |
# Ejecutar la interfaz de usuario con la opci贸n de compartir p煤blicamente
|
517 |
-
iface.launch(share=True)
|
|
|
4 |
import locale
|
5 |
import logging
|
6 |
import tempfile
|
7 |
+
import shutil
|
8 |
|
9 |
import torch
|
10 |
from transformers import MarianMTModel, MarianTokenizer
|
|
|
404 |
fuentes_cache = cargar_fuentes_cache()
|
405 |
for file in files:
|
406 |
if file.name.lower().endswith('.ttf'):
|
407 |
+
destino = os.path.join(tempfile.gettempdir(), file.name)
|
408 |
+
|
409 |
+
# Copiar el archivo desde la ruta temporal a destino
|
410 |
+
shutil.copyfile(file.name, destino)
|
411 |
+
|
412 |
+
nombre_fuente = os.path.splitext(file.name)[0]
|
413 |
fuentes_cache[nombre_fuente] = destino
|
414 |
logger.info(f"Fuente '{file.name}' subida y guardada en {destino}")
|
415 |
else:
|
416 |
logger.warning(f"Archivo '{file.name}' no es una fuente .ttf y ser谩 omitido.")
|
|
|
417 |
# Actualizar el cach茅
|
418 |
cache_path = os.path.join(tempfile.gettempdir(), 'fuentes_sistema.json')
|
419 |
with open(cache_path, 'w', encoding='utf-8') as f:
|
|
|
426 |
return "Fuentes actualizadas exitosamente."
|
427 |
except Exception as e:
|
428 |
logger.error(f"Error al actualizar fuentes: {e}")
|
|
|
|
|
429 |
return f"Error al actualizar fuentes: {e}"
|
430 |
|
431 |
def procesar_pdf(archivo_pdf, fuentes_subidas):
|
|
|
513 |
)
|
514 |
|
515 |
# Ejecutar la interfaz de usuario con la opci贸n de compartir p煤blicamente
|
516 |
+
iface.launch(share=True)
|