Spaces:
Sleeping
Sleeping
Push Bot
commited on
Commit
·
74ad965
1
Parent(s):
d8d7ce9
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
|
@@ -3673,17 +3673,17 @@ def debug_compile_last_pipeline_zip():
|
|
| 3673 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 3674 |
)
|
| 3675 |
_write_logs(LOG_PATH, logs)
|
| 3676 |
-
return html
|
| 3677 |
except Exception as e:
|
| 3678 |
logs.append(f"⚠️ preview failed: {e}")
|
| 3679 |
_write_logs(LOG_PATH, logs)
|
| 3680 |
-
return f"<div>Compiled but preview failed: {e}</div>"
|
| 3681 |
|
| 3682 |
def debug_compile_uploaded_zip(zip_file):
|
| 3683 |
-
"""Compile an uploaded poster zip (user-provided)
|
| 3684 |
logs = [f"🐞 Debug(upload) at {_now_str()}"]
|
| 3685 |
if not zip_file:
|
| 3686 |
-
return "<div style='color:#b00'>Please upload a .zip file first.</div>"
|
| 3687 |
# Prepare workspace
|
| 3688 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 3689 |
work_zip_dir = WORK_DIR / "zip_upload"
|
|
@@ -3695,7 +3695,7 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 3695 |
except Exception as e:
|
| 3696 |
logs.append(f"❌ save upload failed: {e}")
|
| 3697 |
_write_logs(LOG_PATH, logs)
|
| 3698 |
-
return "<div style='color:#b00'>Save upload failed.</div>"
|
| 3699 |
# Extract
|
| 3700 |
try:
|
| 3701 |
import zipfile as _zf
|
|
@@ -3704,7 +3704,7 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 3704 |
except Exception as e:
|
| 3705 |
logs.append(f"❌ unzip failed: {e}")
|
| 3706 |
_write_logs(LOG_PATH, logs)
|
| 3707 |
-
return "<div style='color:#b00'>Unzip failed.</div>"
|
| 3708 |
# Find tex
|
| 3709 |
tex_path = None
|
| 3710 |
for name in ("poster_output.tex", "poster.tex"):
|
|
@@ -3748,7 +3748,8 @@ def debug_compile_uploaded_zip(zip_file):
|
|
| 3748 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 3749 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 3750 |
+ "\n".join(logs)
|
| 3751 |
-
+ "</pre>"
|
|
|
|
| 3752 |
)
|
| 3753 |
try:
|
| 3754 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|
|
|
|
| 3673 |
+ _pdf_to_iframe_html(pdf_path, height="700px")
|
| 3674 |
)
|
| 3675 |
_write_logs(LOG_PATH, logs)
|
| 3676 |
+
return html, str(pdf_path)
|
| 3677 |
except Exception as e:
|
| 3678 |
logs.append(f"⚠️ preview failed: {e}")
|
| 3679 |
_write_logs(LOG_PATH, logs)
|
| 3680 |
+
return f"<div>Compiled but preview failed: {e}</div>", None
|
| 3681 |
|
| 3682 |
def debug_compile_uploaded_zip(zip_file):
|
| 3683 |
+
"""Compile an uploaded poster zip (user-provided); return preview HTML + PDF path."""
|
| 3684 |
logs = [f"🐞 Debug(upload) at {_now_str()}"]
|
| 3685 |
if not zip_file:
|
| 3686 |
+
return "<div style='color:#b00'>Please upload a .zip file first.</div>", None
|
| 3687 |
# Prepare workspace
|
| 3688 |
run_id, WORK_DIR, LOG_PATH, _ = _prepare_workspace(logs)
|
| 3689 |
work_zip_dir = WORK_DIR / "zip_upload"
|
|
|
|
| 3695 |
except Exception as e:
|
| 3696 |
logs.append(f"❌ save upload failed: {e}")
|
| 3697 |
_write_logs(LOG_PATH, logs)
|
| 3698 |
+
return "<div style='color:#b00'>Save upload failed.</div>", None
|
| 3699 |
# Extract
|
| 3700 |
try:
|
| 3701 |
import zipfile as _zf
|
|
|
|
| 3704 |
except Exception as e:
|
| 3705 |
logs.append(f"❌ unzip failed: {e}")
|
| 3706 |
_write_logs(LOG_PATH, logs)
|
| 3707 |
+
return "<div style='color:#b00'>Unzip failed.</div>", None
|
| 3708 |
# Find tex
|
| 3709 |
tex_path = None
|
| 3710 |
for name in ("poster_output.tex", "poster.tex"):
|
|
|
|
| 3748 |
"<div style='color:#b00'><b>Compile failed.</b></div>"
|
| 3749 |
+ "<pre style='white-space:pre-wrap;background:#f7f7f8;padding:8px;border-radius:6px'>"
|
| 3750 |
+ "\n".join(logs)
|
| 3751 |
+
+ "</pre>",
|
| 3752 |
+
None,
|
| 3753 |
)
|
| 3754 |
try:
|
| 3755 |
b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
|