docs: Docker tutorial with recorded demos (demo/docker)
- demo/docker/README.md (fr) and README.en.md: step-by-step tutorial, from the clone of the repository to Docker used in an unprivileged LXD instance - install and usage scenarios recorded with autocast, with their own hidden preamble (demo/docker/setup.sh) creating and removing what they need - demo/castfix.py: puts back the shell prompt autocast drops and squeezes the cloud-init progress dots - Tutorials section in the main READMEs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018inUJkPw1qcoCubeKqfffm
This commit is contained in:
1 parent
1333664688
commit
372bf5d84b
15 files changed
+2494
-2
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""Post-process an autocast recording (asciicast v2), in place.
|
||||
|
||||
- Scenarios with an empty autocast prompt rely on the shell's own prompt (PS1):
|
||||
autocast drops the very first one and the one a !Clear erases, so they are
|
||||
put back (at the start, and after each screen clear).
|
||||
- Progress dots (cloud-init status --wait prints one per second) are squeezed,
|
||||
so that a long wait does not take a minute of the animation.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
DOT_GAP = 0.05
|
||||
|
||||
path = sys.argv[1]
|
||||
with open(path, encoding="utf-8") as f:
|
||||
header, *events = (json.loads(line) for line in f if line.strip())
|
||||
|
||||
ps1 = header.get("env", {}).get("PS1", "")
|
||||
prompt = ps1.replace("AUTOCAST_PROMPT", "").replace("\\[", "").replace("\\]", "").replace("\\e", "\x1b")
|
||||
first = next((e for e in events if e[1] == "o"), None)
|
||||
if prompt and first and not first[2].startswith(prompt):
|
||||
events.insert(0, [0.0, "o", prompt])
|
||||
if prompt:
|
||||
for event in events:
|
||||
if event[1] == "o" and event[2].endswith("\x1b[2J\x1b[3J"):
|
||||
event[2] += prompt
|
||||
|
||||
shift, previous = 0.0, 0.0
|
||||
for event in events:
|
||||
time = event[0]
|
||||
gap = time - previous
|
||||
previous = time
|
||||
if event[1] == "o" and re.fullmatch(r"\.+", event[2]) and gap > DOT_GAP:
|
||||
shift += gap - DOT_GAP
|
||||
event[0] = round(time - shift, 6)
|
||||
if events:
|
||||
header["duration"] = events[-1][0]
|
||||
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
for record in (header, *events):
|
||||
f.write(json.dumps(record, ensure_ascii=False) + "\n")
|
||||
Reference in new issue
Block a user