|
|
|
@ -16,9 +16,9 @@ next_report = now + timedelta(hours=3)
|
|
|
|
|
log_file_name = "log_" + now.strftime("%Y-%m-%d_%H:%M:%S") + ".html"
|
|
|
|
|
|
|
|
|
|
def create_all_logs_file():
|
|
|
|
|
list_logs = subprocess.run(["ls", "log-books"], capture_output=True)
|
|
|
|
|
list_logs = subprocess.run(["ls", "/home/xpub/www/html/tl-dr/log-books"], capture_output=True)
|
|
|
|
|
|
|
|
|
|
with open("/log-books/all.txt", "w") as f:
|
|
|
|
|
with open("/home/xpub/www/html/tl-dr/log-books/all.txt", "w") as f:
|
|
|
|
|
print(list_logs.stdout.decode('UTF-8').strip(), file=f)
|
|
|
|
|
|
|
|
|
|
# Execute a command on the command line. Based = used for piped commands
|
|
|
|
@ -60,7 +60,7 @@ kitchen_services = run_command(["sudo", "journalctl", "-S", "today", "-u", "kitc
|
|
|
|
|
|
|
|
|
|
# loading the jinja template environment
|
|
|
|
|
print("Filling the template");
|
|
|
|
|
env = Environment(loader=FileSystemLoader("templates"))
|
|
|
|
|
env = Environment(loader=FileSystemLoader("/home/xpub/www/html/tl-dr/templates"))
|
|
|
|
|
|
|
|
|
|
# loading the template (use template.jinja when generating the html webview)
|
|
|
|
|
template = env.get_template("book.jinja")
|
|
|
|
@ -97,11 +97,11 @@ output = template.render(
|
|
|
|
|
|
|
|
|
|
print("Output the files");
|
|
|
|
|
# Export the html as book.html, which is used as an input for pandoc
|
|
|
|
|
with open("book.html", "w") as f:
|
|
|
|
|
with open("/home/xpub/www/html/tl-dr/book.html", "w") as f:
|
|
|
|
|
print(output, file=f)
|
|
|
|
|
subprocess.run(["pandoc", "book.html", "-o", "logged_book.epub", "-c", "print.css", "--metadata", "title="+log_file_name], capture_output=True)
|
|
|
|
|
subprocess.run(["pandoc", "/home/xpub/www/html/tl-dr/book.html", "-o", "logged_book.epub", "-c", "print.css", "--metadata", "title="+log_file_name], capture_output=True)
|
|
|
|
|
print("just generated a new book, also put it in the backlog of logs")
|
|
|
|
|
subprocess.run(["cp", "logged_book.epub", "log-books/log_" + now.strftime("%Y-%m-%d_%H%M%S") + ".epub"], capture_output=True)
|
|
|
|
|
subprocess.run(["cp", "/home/xpub/www/html/tl-dr/logged_book.epub", "/home/xpub/www/html/tl-dr/log-books/log_" + now.strftime("%Y-%m-%d_%H%M%S") + ".epub"], capture_output=True)
|
|
|
|
|
create_all_logs_file();
|
|
|
|
|
print("Finished");
|
|
|
|
|
|
|
|
|
|