Skip to content

Commit 3c0f039

Browse files
committed
chown, chgrp, and invalid cache for robots.txt.
1 parent 3173336 commit 3c0f039

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

build_docs.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,18 @@ def build_venv(build_root, version):
492492
return venv_path
493493

494494

495-
def build_robots_txt(www_root):
495+
def build_robots_txt(www_root, group, skip_cache_invalidation):
496+
robots_file = os.path.join(www_root, "robots.txt")
496497
with open(HERE / "templates" / "robots.txt") as robots_txt_template_file:
497-
with open(os.path.join(www_root, "robots.txt"), "w") as robots_txt_file:
498+
with open(robots_file, "w") as robots_txt_file:
498499
template = jinja2.Template(robots_txt_template_file.read())
499500
robots_txt_file.write(
500501
template.render(languages=LANGUAGES, versions=VERSIONS) + "\n"
501502
)
503+
os.chmod(robots_file, 0o775)
504+
shell_out(["chgrp", group, robots_file])
505+
if not skip_cache_invalidation:
506+
shell_out(["curl", "-XPURGE", "https://docs.python.org/robots.txt"])
502507

503508

504509
def build_sitemap(www_root):
@@ -803,7 +808,7 @@ def main():
803808
if sentry_sdk:
804809
sentry_sdk.capture_exception(err)
805810
build_sitemap(args.www_root)
806-
build_robots_txt(args.www_root)
811+
build_robots_txt(args.www_root, args.group, args.skip_cache_invalidation)
807812

808813

809814
if __name__ == "__main__":

0 commit comments

Comments
 (0)