use abs paths

main
root 9 months ago
parent 76858070f5
commit 406d1473c1

@ -0,0 +1,14 @@
all.txt
log_2024-03-25_13:21:53.epub
log_2024-03-25_13:50:25.epub
log_2024-03-25_13:51:15.epub
log_2024-03-25_14:09:27-Copy1.epub
log_2024-03-25_14:09:27.epub
log_2024-03-25_14:25:33.epub
log_2024-03-25_14:33:25.epub
log_2024-03-25_14:38:03.epub
log_2024-03-25_14:57:36.epub
log_2024-03-25_15:50:29.epub
log_2024-03-25_162717.epub
log_2024-03-25_162734.epub
log_2024-03-25_163412.epub

@ -16,9 +16,9 @@ next_report = now + timedelta(hours=3)
log_file_name = "log_" + now.strftime("%Y-%m-%d_%H:%M:%S") + ".html" log_file_name = "log_" + now.strftime("%Y-%m-%d_%H:%M:%S") + ".html"
def create_all_logs_file(): 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) print(list_logs.stdout.decode('UTF-8').strip(), file=f)
# Execute a command on the command line. Based = used for piped commands # 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 # loading the jinja template environment
print("Filling the template"); 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) # loading the template (use template.jinja when generating the html webview)
template = env.get_template("book.jinja") template = env.get_template("book.jinja")
@ -97,15 +97,15 @@ output = template.render(
print("Output the files"); print("Output the files");
# Export the html as book.html, which is used as an input for pandoc # 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) 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") 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(); create_all_logs_file();
print("Finished"); print("Finished");
# At the moment, we are not storing logs in the log folder anymore # At the moment, we are not storing logs in the log folder anymore
# with open(log_file_name, "w") as f: # with open(log_file_name, "w") as f:
# print(output, file=f) # print(output, file=f)

Loading…
Cancel
Save