Skip to content

Commit 971ce47

Browse files
committed
Refactor duplicate code
1 parent 63942dd commit 971ce47

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

run_release.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -809,25 +809,23 @@ def execute_command(command: str) -> None:
809809
if channel.recv_exit_status() != 0:
810810
raise ReleaseException(channel.recv_stderr(1000))
811811

812-
execute_command(f"mkdir -p {destination}")
813-
execute_command(f"cp {source}/downloads/* {destination}")
814-
execute_command(f"chgrp downloads {destination}")
815-
execute_command(f"chmod 775 {destination}")
816-
execute_command(f"find {destination} -type f -exec chmod 664 {{}} \\;")
817-
818-
# Docs
819-
820-
release_tag = db["release"]
821-
if release_tag.is_final or release_tag.is_release_candidate:
822-
source = f"/home/psf-users/{db['ssh_user']}/{db['release']}"
823-
destination = f"/srv/www.python.org/ftp/python/doc/{release_tag}"
824-
812+
def copy_and_set_permissions(source_glob: str, destination: str) -> None:
825813
execute_command(f"mkdir -p {destination}")
826-
execute_command(f"cp {source}/docs/* {destination}")
814+
execute_command(f"cp {source_glob} {destination}")
827815
execute_command(f"chgrp downloads {destination}")
828816
execute_command(f"chmod 775 {destination}")
829817
execute_command(f"find {destination} -type f -exec chmod 664 {{}} \\;")
830818

819+
copy_and_set_permissions(f"{source}/downloads/*", destination)
820+
821+
# Docs
822+
release_tag = db["release"]
823+
if release_tag.is_final or release_tag.is_release_candidate:
824+
copy_and_set_permissions(
825+
f"{source}/docs/*",
826+
f"/srv/www.python.org/ftp/python/doc/{release_tag}",
827+
)
828+
831829

832830
def upload_docs_to_the_docs_server(db: ReleaseShelf) -> None:
833831
release_tag: release_mod.Tag = db["release"]

0 commit comments

Comments
 (0)