5454import re
5555import shlex
5656import shutil
57+ import stat
5758import subprocess
5859import sys
5960import venv
@@ -744,18 +745,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
744745 group = self .group ,
745746 recursive = True ,
746747 )
747- run (["chmod" , "-R" , "o+r" , self .checkout / "Doc" / "build" / "html" ])
748- run ([
749- "find" ,
750- self .checkout / "Doc" / "build" / "html" ,
751- "-type" ,
752- "d" ,
753- "-exec" ,
754- "chmod" ,
755- "o+x" ,
756- "{}" ,
757- ";" ,
758- ])
748+ chmod_make_readable (self .checkout / "Doc" / "build" / "html" )
759749 run ([
760750 "rsync" ,
761751 "-a" ,
@@ -770,12 +760,7 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
770760 # Copy archive files to /archives/
771761 logging .debug ("Copying dist files." )
772762 chgrp (self .checkout / "Doc" / "dist" , group = self .group , recursive = True )
773- run ([
774- "chmod" ,
775- "-R" ,
776- "o+r" ,
777- self .checkout / "Doc" / "dist" ,
778- ])
763+ chmod_make_readable (self .checkout / "Doc" / "dist" )
779764 run (["mkdir" , "-m" , "o+rx" , "-p" , target / "archives" ])
780765 chgrp (target / "archives" , group = self .group )
781766 run ([
@@ -907,6 +892,18 @@ def chgrp(
907892 logging .warning ("Can't change group of %s: %s" , path , str (err ))
908893
909894
895+ def chmod_make_readable (path : Path , / , mode : int = stat .S_IROTH ) -> None :
896+ if not path .is_dir ():
897+ raise ValueError
898+
899+ path .chmod (path .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH ) # o+rx
900+ for p in path .rglob ("*" ):
901+ if p .is_dir ():
902+ p .chmod (p .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH ) # o+rx
903+ else :
904+ p .chmod (p .stat ().st_mode | stat .S_IROTH ) # o+r
905+
906+
910907def format_seconds (seconds : float ) -> str :
911908 hours , remainder = divmod (seconds , 3600 )
912909 minutes , seconds = divmod (remainder , 60 )
0 commit comments