From 889213516093ade9cd225a473bdb550b86589f93 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Wed, 28 Jul 2021 18:42:02 -0400 Subject: [PATCH] Print date/time and if build was successful --- latty.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 + ".*"])