jersonalvr commited on
Commit
1f32f4c
·
verified ·
1 Parent(s): aed0852

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -403,14 +403,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(), file.name)
 
407
  with open(destino, 'wb') as f_dest:
408
- f_dest.write(file.read())
409
- nombre_fuente = os.path.splitext(file.name)[0]
410
  fuentes_cache[nombre_fuente] = destino
411
  logger.info(f"Fuente '{file.name}' subida y guardada en {destino}")
412
  else:
413
  logger.warning(f"Archivo '{file.name}' no es una fuente .ttf y será omitido.")
 
414
  # Actualizar el caché
415
  cache_path = os.path.join(tempfile.gettempdir(), 'fuentes_sistema.json')
416
  with open(cache_path, 'w', encoding='utf-8') as f:
@@ -423,6 +425,8 @@ def boton_actualizar_fuentes(files):
423
  return "Fuentes actualizadas exitosamente."
424
  except Exception as e:
425
  logger.error(f"Error al actualizar fuentes: {e}")
 
 
426
  return f"Error al actualizar fuentes: {e}"
427
 
428
  def procesar_pdf(archivo_pdf, fuentes_subidas):
 
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(), os.path.basename(file.name))
407
+ # Use file.read() as bytes
408
  with open(destino, 'wb') as f_dest:
409
+ f_dest.write(file.read().read() if hasattr(file.read(), 'read') else file.read())
410
+ nombre_fuente = os.path.splitext(os.path.basename(file.name))[0]
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
  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):