Add timeout and use text mode

master
Kevin Zheng 2022-06-04 13:10:29 -07:00
parent 894a6a6504
commit 0a6853964f
1 changed files with 12 additions and 5 deletions

View File

@ -30,10 +30,17 @@ Report: {DESC}
msg["From"] = "crossfire" msg["From"] = "crossfire"
msg["Subject"] = "Crossfire issue report" msg["Subject"] = "Crossfire issue report"
result = subprocess.run(['sendmail', recipient], input=msg.as_bytes()) try:
result = subprocess.run(['sendmail', recipient], universal_newlines=True, input=msg.as_string(), timeout=2)
if result.returncode == 0: if result.returncode == 0:
pl.Message("Thank you for your report.") pl.Message("Thank you for your report.")
else: else:
pl.Message("There was an error reporting your problem. Please contact a Dungeon Master to report your problem.") error(pl)
except subprocess.TimeoutExpired:
error(pl)
Crossfire.Log(Crossfire.LogError, "Timed out while reporting a problem")
def error(pl):
pl.Message("There was an error reporting your problem. Please try again or contact a Dungeon Master to report your problem.")
report(Crossfire.WhoAmI()) report(Crossfire.WhoAmI())