diff --git a/latty.py b/latty.py index a7b6d46..838528c 100644 --- a/latty.py +++ b/latty.py @@ -9,9 +9,13 @@ from flask import send_from_directory def get_unique(): import uuid unique = str(uuid.uuid1().hex) - print("Unique ID: " + unique) return unique +def get_datetime(): + from datetime import datetime + now = datetime.now() + return now.strftime("%Y-%m-%d %H:%M:%S") + @dataclass class CLData(): username: str @@ -49,10 +53,15 @@ class CLData(): output_arg="-jobname=outputs/" + unique_id + " " + unique_file com = "pdflatex -halt-on-error " + output_arg - print("COM: '" + com + "'") - result = subprocess.run(['bash', '-c', com], stdout=subprocess.PIPE, text=True) + build_text = "[" + get_datetime() + "] Building for " + unique_id + " " + result = subprocess.run( + ['bash', '-c', com], + stdout=subprocess.PIPE, + text=True + ) if result.returncode == 0: + print(build_text + "[SUCCESS]") threading.Timer(60 * 30, cleanup, [output_dir + unique_id]).start() return (send_from_directory( @@ -62,11 +71,12 @@ class CLData(): as_attachment=True ), None) else: + print(build_text + "[FAIL]") + # Collect output but delete boilerplate text errors = result.stdout.split("\n") del errors[:13] del errors[-2:] return (None, errors) def cleanup(unique): - print(unique) subprocess.run(['bash', '-c', "rm " + unique + ".*"])