Updated publish script to use rsync and juptyer-nbconvert. Also moved html to separate directory.

This commit is contained in:
2018-05-20 15:25:07 -04:00
parent 9ad9b1de27
commit cca688f829
82 changed files with 465062 additions and 12679 deletions

View File

@@ -1,6 +1,7 @@
import jinja2
import os
import subprocess
import shutil
from operator import itemgetter
from collections import namedtuple
from os.path import getmtime
@@ -36,38 +37,30 @@ def get_solution_list(directory="./"):
return l
def convert_solutions_to_html(solutions):
for s in solutions:
if getmtime(s.html) < getmtime(s.ipynb):
args = ["ipython", "nbconvert", s.ipynb]
subprocess.call(args)
def render_solutions(solutions):
loader = jinja2.FileSystemLoader(searchpath="./")
env = jinja2.Environment(loader=loader)
template = env.get_template("template.html")
d = {"solutions": solutions}
with open("index.html", 'w') as f:
with open("html/index.html", 'w') as f:
f.write(template.render(**d))
def convert_solutions_to_html(solutions):
for s in solutions:
if not os.path.isfile(s.html) or getmtime(s.html) < getmtime(s.ipynb):
args = ["ipython", "nbconvert", s.ipynb]
html = os.path.join("html", s.html)
if not os.path.isfile(html) or getmtime(html) < getmtime(s.ipynb):
args = ["jupyter-nbconvert", s.ipynb, "--output-dir=html"]
subprocess.call(args)
def ship_to_failx():
for f in os.listdir():
if f.endswith(".html"):
args = ["scp", f, "failx@felixm.de:~/html/euler/"]
subprocess.call(args)
args = ["rsync", "-r", "html/", "failx@felixm.de:/home/failx/html/euler"]
subprocess.call(args)
if __name__ == "__main__":
solutions = get_solution_list()
convert_solutions_to_html(solutions)
render_solutions(solutions)
#ship_to_failx()
ship_to_failx()