mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
Upgrade slide generator to python3; generate a zip file too
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -8,6 +8,7 @@ slides/*.yml.html
|
||||
slides/autopilot/state.yaml
|
||||
slides/index.html
|
||||
slides/past.html
|
||||
slides/slides.zip
|
||||
node_modules
|
||||
|
||||
### macOS ###
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.9
|
||||
RUN apk add --no-cache entr py-pip git
|
||||
FROM alpine:3.11
|
||||
RUN apk add --no-cache entr py3-pip git zip
|
||||
COPY requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
@@ -14,6 +14,7 @@ once)
|
||||
./appendcheck.py $YAML.html
|
||||
done
|
||||
fi
|
||||
zip -qr slides.zip . && echo "Created slides.zip archive."
|
||||
;;
|
||||
|
||||
forever)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
|
||||
FLAGS=dict(
|
||||
@@ -132,13 +132,13 @@ TEMPLATE="""<html>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>""".decode("utf-8")
|
||||
</html>"""
|
||||
|
||||
import datetime
|
||||
import jinja2
|
||||
import yaml
|
||||
|
||||
items = yaml.load(open("index.yaml"))
|
||||
items = yaml.safe_load(open("index.yaml"))
|
||||
|
||||
# Items with a date correspond to scheduled sessions.
|
||||
# Items without a date correspond to self-paced content.
|
||||
@@ -187,10 +187,10 @@ with open("index.html", "w") as f:
|
||||
past_workshops=past_workshops,
|
||||
self_paced=self_paced,
|
||||
recorded_workshops=recorded_workshops
|
||||
).encode("utf-8"))
|
||||
))
|
||||
|
||||
with open("past.html", "w") as f:
|
||||
f.write(template.render(
|
||||
title="Container Training",
|
||||
all_past_workshops=past_workshops
|
||||
).encode("utf-8"))
|
||||
))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
# transforms a YAML manifest into a HTML workshop file
|
||||
|
||||
import glob
|
||||
@@ -20,12 +20,19 @@ def anchor(title):
|
||||
return "toc-" + title
|
||||
|
||||
|
||||
def interstitials_generator():
|
||||
images = [url.strip() for url in open("interstitials.txt") if url.strip()]
|
||||
while True:
|
||||
for image in images:
|
||||
yield image
|
||||
interstitials = interstitials_generator()
|
||||
class Interstitials(object):
|
||||
|
||||
def __init__(self):
|
||||
self.index = 0
|
||||
self.images = [url.strip() for url in open("interstitials.txt") if url.strip()]
|
||||
|
||||
def next(self):
|
||||
index = self.index % len(self.images)
|
||||
index += 1
|
||||
return self.images[index]
|
||||
|
||||
|
||||
interstitials = Interstitials()
|
||||
|
||||
|
||||
def insertslide(markdown, title):
|
||||
@@ -154,8 +161,6 @@ def gentoc(tree, path=()):
|
||||
# Returns: (epxandedmarkdown,[list of titles])
|
||||
# The list of titles can be nested.
|
||||
def processchapter(chapter, filename):
|
||||
if isinstance(chapter, unicode):
|
||||
return processchapter(chapter.encode("utf-8"), filename)
|
||||
if isinstance(chapter, str):
|
||||
if "\n" in chapter:
|
||||
titles = re.findall("^# (.*)", chapter, re.MULTILINE)
|
||||
@@ -179,14 +184,14 @@ try:
|
||||
if "REPOSITORY_URL" in os.environ:
|
||||
repo = os.environ["REPOSITORY_URL"]
|
||||
else:
|
||||
repo = subprocess.check_output(["git", "config", "remote.origin.url"])
|
||||
repo = subprocess.check_output(["git", "config", "remote.origin.url"]).decode("ascii")
|
||||
repo = repo.strip().replace("git@github.com:", "https://github.com/")
|
||||
if "BRANCH" in os.environ:
|
||||
branch = os.environ["BRANCH"]
|
||||
else:
|
||||
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"])
|
||||
branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode("ascii")
|
||||
branch = branch.strip()
|
||||
base = subprocess.check_output(["git", "rev-parse", "--show-prefix"])
|
||||
base = subprocess.check_output(["git", "rev-parse", "--show-prefix"]).decode("ascii")
|
||||
base = base.strip().strip("/")
|
||||
urltemplate = ("{repo}/tree/{branch}/{base}/{filename}"
|
||||
.format(repo=repo, branch=branch, base=base, filename="{}"))
|
||||
@@ -194,12 +199,12 @@ except:
|
||||
logging.exception("Could not generate repository URL; generating local URLs instead.")
|
||||
urltemplate = "file://{pwd}/{filename}".format(pwd=os.environ["PWD"], filename="{}")
|
||||
try:
|
||||
commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
|
||||
commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).decode("ascii")
|
||||
except:
|
||||
logging.exception("Could not figure out HEAD commit.")
|
||||
commit = "??????"
|
||||
try:
|
||||
dirtyfiles = subprocess.check_output(["git", "status", "--porcelain"])
|
||||
dirtyfiles = subprocess.check_output(["git", "status", "--porcelain"]).decode("ascii")
|
||||
except:
|
||||
logging.exception("Could not figure out repository cleanliness.")
|
||||
dirtyfiles = "?? git status --porcelain failed"
|
||||
|
||||
1
slides/runtime.txt
Normal file
1
slides/runtime.txt
Normal file
@@ -0,0 +1 @@
|
||||
3.7
|
||||
Reference in New Issue
Block a user