Skip to content

Commit

Permalink
better error throwing if perl bot fails
Browse files Browse the repository at this point in the history
  • Loading branch information
BackSlasher committed May 16, 2023
1 parent 311461d commit ae8d03a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions djang/versions/services/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@


def exec(filename, inp):
out = subprocess.check_output(f"{bot_dir}/{filename}", input=inp.encode())
return out.decode()
path = f"{bot_dir}/{filename}"
sub = subprocess.Popen(
path,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)

out, err = sub.communicate(input=inp)
exit_code = sub.wait()

if exit_code:
raise Exception(f"process {filename} exited with {exit_code}. stderr: {err}")

return out


def syntax_law(data):
Expand Down

0 comments on commit ae8d03a

Please sign in to comment.