Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import re
import shlex
import shutil
import stat
import subprocess
import sys
import venv
Expand Down Expand Up @@ -744,18 +745,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
group=self.group,
recursive=True,
)
run(["chmod", "-R", "o+r", self.checkout / "Doc" / "build" / "html"])
run([
"find",
self.checkout / "Doc" / "build" / "html",
"-type",
"d",
"-exec",
"chmod",
"o+x",
"{}",
";",
])
chmod_make_readable(self.checkout / "Doc" / "build" / "html")
run([
"rsync",
"-a",
Expand All @@ -770,12 +760,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
# Copy archive files to /archives/
logging.debug("Copying dist files.")
chgrp(self.checkout / "Doc" / "dist", group=self.group, recursive=True)
run([
"chmod",
"-R",
"o+r",
self.checkout / "Doc" / "dist",
])
chmod_make_readable(self.checkout / "Doc" / "dist")
run(["mkdir", "-m", "o+rx", "-p", target / "archives"])
chgrp(target / "archives", group=self.group)
run([
Expand Down Expand Up @@ -907,6 +892,18 @@ def chgrp(
logging.warning("Can't change group of %s: %s", path, str(err))


def chmod_make_readable(path: Path, /, mode: int = stat.S_IROTH) -> None:
if not path.is_dir():
raise ValueError

path.chmod(path.stat().st_mode | stat.S_IROTH | stat.S_IXOTH) # o+rx
for p in path.rglob("*"):
if p.is_dir():
p.chmod(p.stat().st_mode | stat.S_IROTH | stat.S_IXOTH) # o+rx
else:
p.chmod(p.stat().st_mode | stat.S_IROTH) # o+r


def format_seconds(seconds: float) -> str:
hours, remainder = divmod(seconds, 3600)
minutes, seconds = divmod(remainder, 60)
Expand Down