-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add deploy script for deployment flexibility
- Loading branch information
jcferrei
committed
Nov 30, 2023
1 parent
03cca47
commit cd8a763
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ Thumbs.db | |
venv | ||
/.luarc.json | ||
|
||
#log files | ||
*.log | ||
|
||
#drawio | ||
*.drawio.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import re | ||
import shutil | ||
import subprocess | ||
|
||
log_file_path = "quarto_logs.log" | ||
quarto_command = "quarto render &> "+log_file_path | ||
|
||
def trydeploy(): | ||
subprocess.run(quarto_command, shell=True) | ||
try: | ||
with open(log_file_path, "a+") as log_file: | ||
log_file.seek(0) | ||
lines = log_file.readlines() | ||
last_line = next((line.strip() for line in reversed(lines) if line.strip()), None) | ||
|
||
if last_line == "Output created: _site/index.html": | ||
print("Quarto render successful!") | ||
else: | ||
pattern = re.compile(r'\[\d+/\d+\] .+\.qmd') | ||
error_path = re.sub(r'\[\d+/\d+\]\s*', '', next((line.strip() for line in reversed(lines) if pattern.match(line)), None)) | ||
|
||
if error_path: | ||
error_folder = os.path.dirname(error_path.split(".qmd")[0]) | ||
underscored_path = os.path.join(os.path.dirname(error_folder), "_" + os.path.basename(error_folder)) | ||
shutil.move(error_folder, underscored_path) | ||
trydeploy() | ||
else: | ||
print("Quarto render failed. Check logs for details.") | ||
|
||
except Exception as e: | ||
print(f"An unexpected error occurred: {e}") | ||
|
||
trydeploy() |
This file was deleted.
Oops, something went wrong.