Print date/time and if build was successful
This commit is contained in:
parent
e200399366
commit
8892135160
18
latty.py
18
latty.py
|
@ -9,9 +9,13 @@ from flask import send_from_directory
|
||||||
def get_unique():
|
def get_unique():
|
||||||
import uuid
|
import uuid
|
||||||
unique = str(uuid.uuid1().hex)
|
unique = str(uuid.uuid1().hex)
|
||||||
print("Unique ID: " + unique)
|
|
||||||
return unique
|
return unique
|
||||||
|
|
||||||
|
def get_datetime():
|
||||||
|
from datetime import datetime
|
||||||
|
now = datetime.now()
|
||||||
|
return now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CLData():
|
class CLData():
|
||||||
username: str
|
username: str
|
||||||
|
@ -49,10 +53,15 @@ class CLData():
|
||||||
|
|
||||||
output_arg="-jobname=outputs/" + unique_id + " " + unique_file
|
output_arg="-jobname=outputs/" + unique_id + " " + unique_file
|
||||||
com = "pdflatex -halt-on-error " + output_arg
|
com = "pdflatex -halt-on-error " + output_arg
|
||||||
print("COM: '" + com + "'")
|
build_text = "[" + get_datetime() + "] Building for " + unique_id + " "
|
||||||
result = subprocess.run(['bash', '-c', com], stdout=subprocess.PIPE, text=True)
|
result = subprocess.run(
|
||||||
|
['bash', '-c', com],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
text=True
|
||||||
|
)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
|
print(build_text + "[SUCCESS]")
|
||||||
threading.Timer(60 * 30, cleanup, [output_dir + unique_id]).start()
|
threading.Timer(60 * 30, cleanup, [output_dir + unique_id]).start()
|
||||||
|
|
||||||
return (send_from_directory(
|
return (send_from_directory(
|
||||||
|
@ -62,11 +71,12 @@ class CLData():
|
||||||
as_attachment=True
|
as_attachment=True
|
||||||
), None)
|
), None)
|
||||||
else:
|
else:
|
||||||
|
print(build_text + "[FAIL]")
|
||||||
|
# Collect output but delete boilerplate text
|
||||||
errors = result.stdout.split("\n")
|
errors = result.stdout.split("\n")
|
||||||
del errors[:13]
|
del errors[:13]
|
||||||
del errors[-2:]
|
del errors[-2:]
|
||||||
return (None, errors)
|
return (None, errors)
|
||||||
|
|
||||||
def cleanup(unique):
|
def cleanup(unique):
|
||||||
print(unique)
|
|
||||||
subprocess.run(['bash', '-c', "rm " + unique + ".*"])
|
subprocess.run(['bash', '-c', "rm " + unique + ".*"])
|
||||||
|
|
Loading…
Reference in New Issue