Spaces:
Sleeping
Sleeping
Push Bot
commited on
Commit
·
a8a5f7d
1
Parent(s):
b634c27
Debug: add image preview (first page) with PyMuPDF/pdfium; return PDF path from debug flows; chain .then to render image
Browse files
app.py
CHANGED
|
@@ -3989,17 +3989,17 @@ def debug_compile_last_pipeline_zip():
|
|
| 3989 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 3990 |
)
|
| 3991 |
_write_logs(LOG_PATH, logs)
|
| 3992 |
-
return html
|
| 3993 |
except Exception as e:
|
| 3994 |
logs.append(f"⚠️ preview failed: {e}")
|
| 3995 |
_write_logs(LOG_PATH, logs)
|
| 3996 |
-
return f"<div>Compiled but preview failed: {e}</div>"
|
| 3997 |
|
| 3998 |
def debug_compile_uploaded_zip(zip_file):
|
| 3999 |
-
"""Compile an uploaded poster zip (user-provided)
|
| 4000 |
logs = [f"🐞 Debug(upload) at {_now_str()}"]
|
| 4001 |
if not zip_file:
|
| 4002 |
-
return "<div style='color:#b00'>Please upload a .zip file first.</div>"
|
| 4003 |
# Prepare workspace
|
| 4004 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 4005 |
work_zip_dir = WORK_DIR / "zip_upload"
|
|
@@ -4011,7 +4011,7 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 4011 |
except Exception as e:
|
| 4012 |
logs.append(f"❌ save upload failed: {e}")
|
| 4013 |
_write_logs(LOG_PATH, logs)
|
| 4014 |
-
return "<div style='color:#b00'>Save upload failed.</div>"
|
| 4015 |
# Extract
|
| 4016 |
try:
|
| 4017 |
import zipfile as _zf
|
|
@@ -4020,7 +4020,7 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 4020 |
except Exception as e:
|
| 4021 |
logs.append(f"❌ unzip failed: {e}")
|
| 4022 |
_write_logs(LOG_PATH, logs)
|
| 4023 |
-
return "<div style='color:#b00'>Unzip failed.</div>"
|
| 4024 |
# Find tex
|
| 4025 |
tex_path = None
|
| 4026 |
for name in ("poster_output.tex", "poster.tex"):
|
|
@@ -4064,7 +4064,8 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 4064 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 4065 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 4066 |
+ "\n".join(logs)
|
| 4067 |
-
+ "</pre>"
|
|
|
|
| 4068 |
)
|
| 4069 |
try:
|
| 4070 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|
|
|
|
| 3989 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 3990 |
)
|
| 3991 |
_write_logs(LOG_PATH, logs)
|
| 3992 |
+
return html, str(pdf_path)
|
| 3993 |
except Exception as e:
|
| 3994 |
logs.append(f"⚠️ preview failed: {e}")
|
| 3995 |
_write_logs(LOG_PATH, logs)
|
| 3996 |
+
return f"<div>Compiled but preview failed: {e}</div>", None
|
| 3997 |
|
| 3998 |
def debug_compile_uploaded_zip(zip_file):
|
| 3999 |
+
"""Compile an uploaded poster zip (user-provided); return preview HTML + PDF path."""
|
| 4000 |
logs = [f"🐞 Debug(upload) at {_now_str()}"]
|
| 4001 |
if not zip_file:
|
| 4002 |
+
return "<div style='color:#b00'>Please upload a .zip file first.</div>", None
|
| 4003 |
# Prepare workspace
|
| 4004 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 4005 |
work_zip_dir = WORK_DIR / "zip_upload"
|
|
|
|
| 4011 |
except Exception as e:
|
| 4012 |
logs.append(f"❌ save upload failed: {e}")
|
| 4013 |
_write_logs(LOG_PATH, logs)
|
| 4014 |
+
return "<div style='color:#b00'>Save upload failed.</div>", None
|
| 4015 |
# Extract
|
| 4016 |
try:
|
| 4017 |
import zipfile as _zf
|
|
|
|
| 4020 |
except Exception as e:
|
| 4021 |
logs.append(f"❌ unzip failed: {e}")
|
| 4022 |
_write_logs(LOG_PATH, logs)
|
| 4023 |
+
return "<div style='color:#b00'>Unzip failed.</div>", None
|
| 4024 |
# Find tex
|
| 4025 |
tex_path = None
|
| 4026 |
for name in ("poster_output.tex", "poster.tex"):
|
|
|
|
| 4064 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 4065 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 4066 |
+ "\n".join(logs)
|
| 4067 |
+
+ "</pre>",
|
| 4068 |
+
None,
|
| 4069 |
)
|
| 4070 |
try:
|
| 4071 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|