Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print executor cmdline on exception #286

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sinol_make/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sinol_make.task_type.interactive import InteractiveTaskType # noqa


__version__ = "1.9.7"
__version__ = "1.9.8"


def configure_parsers():
Expand Down
14 changes: 10 additions & 4 deletions src/sinol_make/executors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
from typing import List, Tuple, Union

from sinol_make import util
from sinol_make.structs.status_structs import ExecutionResult, Status


Expand Down Expand Up @@ -46,10 +47,15 @@ def execute(self, command: List[str], time_limit, hard_time_limit, memory_limit,

command = self._wrap_command(command, result_file_path, time_limit, memory_limit)
cmdline = " ".join(command)
tle, mle, return_code, proc_stderr = self._execute(cmdline, time_limit, hard_time_limit, memory_limit,
result_file_path, executable, execution_dir, stdin, stdout,
stderr, fds_to_close, *args, **kwargs)
result = self._parse_result(tle, mle, return_code, result_file_path)
try:
tle, mle, return_code, proc_stderr = self._execute(cmdline, time_limit, hard_time_limit, memory_limit,
result_file_path, executable, execution_dir, stdin, stdout,
stderr, fds_to_close, *args, **kwargs)
result = self._parse_result(tle, mle, return_code, result_file_path)
except Exception as e:
print(util.error(f"Failed to run executor command:\n\t{cmdline}\n"))
raise

result.Cmdline = cmdline
if not result.Stderr:
result.Stderr = proc_stderr
Expand Down
19 changes: 8 additions & 11 deletions src/sinol_make/executors/sio2jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import signal
import subprocess
import sys
import traceback
from typing import List, Tuple, Union

from sinol_make import util
Expand Down Expand Up @@ -54,19 +53,17 @@ def _parse_memory(self, memory_str):
def _parse_result(self, _, mle, return_code, result_file_path) -> ExecutionResult:
result = ExecutionResult()
with open(result_file_path, "r") as result_file:
lines = result_file.readlines()

output_lines = result_file.readlines()
try:
result.stderr = lines[:-2]
status, code, time_ms, _, memory_kb, _ = lines[-2].strip().split()
message = lines[-1].strip()
result.stderr = output_lines[-2]
status, code, time_ms, _, memory_kb, _ = output_lines[-2].strip().split()
message = output_lines[-1].strip()
result.Time = int(time_ms)
result.Memory = int(memory_kb)
except:
output = "".join(lines)
util.exit_with_error("Could not parse sio2jail output:"
f"\n---\n{output}"
f"\n---\n{traceback.format_exc()}")
except Exception as e:
output = "\t" + "\t".join(output_lines)
raise Exception(f"Failed to parse sio2jail output:\n{output}") from e


# ignoring `status` is weird, but sio2 does it this way
if message == 'ok':
Expand Down