enhanced execution engines

This commit is contained in:
Saifeddine ALOUI 2024-04-10 09:15:32 +02:00
parent bd2588d73a
commit b9a93a2d1b
2 changed files with 4 additions and 3 deletions

View File

@ -55,8 +55,9 @@ def execute_latex(code, client:Client, message_id):
# Check the return code of the pdflatex command
if result.returncode != 0:
error_message = result.stderr.strip()
std_mesasge = result.stdout.strip()
execution_time = time.time() - start_time
error_json = {"output": f"Error occurred while compiling LaTeX: {error_message}", "execution_time": execution_time}
error_json = {"output": f"Output:{std_mesasge}\nError occurred while compiling LaTeX:\n{error_message}", "execution_time": execution_time}
return error_json
# If the compilation is successful, you will get a PDF file
pdf_file = tmp_file.with_suffix('.pdf')

View File

@ -55,9 +55,9 @@ def execute_python(code, client:Client, message_id):
if process.returncode != 0:
# The child process threw an exception.
try:
error_message = f"Error executing Python code: {error.decode('utf8')}"
error_message = f"Output:{output.decode('utf-8', errors="ignore")}\nError executing Python code:\n{error.decode('utf-8', errors="ignore")}"
except:
error_message = f"Error executing Python code: {error}"
error_message = f"Error executing Python code:\n{error}"
error_json = {"output": "<div class='text-red-500'>"+error_message+"</div>", "execution_time": execution_time}
return error_json