mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
disable exc masking
This commit is contained in:
+8
-4
@@ -21,6 +21,7 @@ class LatexModule(commands.Cog):
|
||||
def __init__(self, bot: commands.Bot, logger_name: str):
|
||||
self.bot = bot
|
||||
self.logger = logging.getLogger(logger_name)
|
||||
self.logger_name = logger_name
|
||||
|
||||
# -------- /tex (PDF + diagnoza; log -> debug logger) --------
|
||||
@commands.hybrid_command(
|
||||
@@ -44,7 +45,7 @@ class LatexModule(commands.Cog):
|
||||
try:
|
||||
data = await att.read()
|
||||
self.logger.info("LaTeX read %s bytes from %s", len(data), att.filename)
|
||||
res = await compile_single_tex_bytes(data, att.filename, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger)
|
||||
res = await compile_single_tex_bytes(data, att.filename, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger_name)
|
||||
self.logger.info("LaTeX result for %s: %s", att.filename, res)
|
||||
self.logger.info("LaTeX log (%s)\n%s", att.filename, (res["log_text"] or "")[-2000:])
|
||||
if res["ok"] and res["pdf_bytes"]:
|
||||
@@ -61,11 +62,13 @@ class LatexModule(commands.Cog):
|
||||
excerpt = data.decode("utf-8", errors="ignore")[:4000]
|
||||
except Exception:
|
||||
excerpt = ""
|
||||
advice = await ask_openai_diagnosis(res["log_text"] or "", excerpt, OPENAI_MODEL, logger=self.logger)
|
||||
advice = await ask_openai_diagnosis(res["log_text"] or "", excerpt, OPENAI_MODEL, logger=self.logger_name)
|
||||
parts.append(f"❌ `{att.filename}` — błąd kompilacji.\nDiagnoza:\n{advice}")
|
||||
raise
|
||||
except Exception as e:
|
||||
self.logger.info("Exception %s: %s", att.filename, e)
|
||||
parts.append(f"⚠️ `{att.filename}` — wyjątek (szczegóły w logu).")
|
||||
raise
|
||||
|
||||
content = f"**LaTeX** — {len(atts)} plik(ów). Model: `{OPENAI_MODEL}`\n\n" + "\n\n".join(parts)
|
||||
await ctx.reply(content if len(content)<1900 else content[:1900]+"…", files=files, mention_author=False)
|
||||
@@ -90,7 +93,7 @@ class LatexModule(commands.Cog):
|
||||
for att in atts:
|
||||
try:
|
||||
data = await att.read()
|
||||
res = await compile_single_tex_bytes(data, att.filename, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger)
|
||||
res = await compile_single_tex_bytes(data, att.filename, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger_name)
|
||||
self.logger.debug("LaTeX CLEAN (%s)\n%s", att.filename, (res["log_text"] or "")[-2000:])
|
||||
if res["ok"] and res["pdf_bytes"]:
|
||||
b = io.BytesIO(res["pdf_bytes"])
|
||||
@@ -103,6 +106,7 @@ class LatexModule(commands.Cog):
|
||||
except Exception as e:
|
||||
self.logger.debug("CLEAN exception %s: %s", att.filename, e)
|
||||
parts.append(f"⚠️ `{att.filename}` — wyjątek (log w debug).")
|
||||
raise
|
||||
|
||||
await ctx.reply("**LaTeX clean** — " + ", ".join(parts), files=files, mention_author=False)
|
||||
|
||||
@@ -121,7 +125,7 @@ class LatexModule(commands.Cog):
|
||||
return await interaction.followup.send(f"ZIP > {LATEX_MAX_ZIP_MB} MiB — za duży.", ephemeral=True)
|
||||
|
||||
data = await archive.read()
|
||||
out_zip_bytes, failed = await compile_zip_to_zip(data, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger)
|
||||
out_zip_bytes, failed = await compile_zip_to_zip(data, LATEX_TEX_ENGINE, LATEX_MAX_COMPILE_SECONDS, logger=self.logger_name)
|
||||
if not out_zip_bytes and failed:
|
||||
return await interaction.followup.send("Brak PDF-ów. " + "; ".join(failed[:10]), ephemeral=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user