GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — kafka/docker/extract_docker_official_image_artifact.py at trunk · coderbruis/kafka Expand file tree/ Copy pathextract_docker_official_image_artifact.pyMore file actions 77 lines (67 loc) · 3.4 KB / Copy pathextract_docker_official_image_artifact.pyFile metadata and controls77 lines (67 loc) · 3.4 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 #!/usr/bin/env python # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Python script to extract docker official images artifact and give it executable permissions This script is used to extract docker official images artifact and give it executable permissions Usage: extract_docker_official_image_artifact.py --help Get detailed description of each option Example command:- extract_docker_official_image_artifact.py --path_to_downloaded_artifact <artifact_path> This command will build an extract the downloaded artifact, and copy the contents to the docker_official_images directory. If the extracted artifact contents already exist in the docker_official_images directory , they will be overwritten, else they will be created. """ import os import argparse import zipfile import shutil from pathlib import Path def set_executable_permissions(directory): for root, _, files in os.walk(directory): for file in files: path = os.path.join(root, file) os.chmod(path, os.stat(path).st_mode | 0o111) def extract_artifact(artifact_path): docker_official_images_dir = Path(os.path.dirname(os.path.realpath(__file__)), "docker_official_images") temp_dir = Path('temp_extracted') try: if temp_dir.exists(): shutil.rmtree(temp_dir) temp_dir.mkdir() with zipfile.ZipFile(artifact_path, 'r') as zip_ref: zip_ref.extractall(temp_dir) artifact_version_dirs = list(temp_dir.iterdir()) if len(artifact_version_dirs) != 1: raise Exception("Unexpected contents in the artifact. Exactly one version directory is expected.") artifact_version_dir = artifact_version_dirs[0] target_version_dir = Path(os.path.join(docker_official_images_dir, artifact_version_dir.name)) target_version_dir.mkdir(parents=True, exist_ok=True) for image_type_dir in artifact_version_dir.iterdir(): target_image_type_dir = Path(os.path.join(target_version_dir, image_type_dir.name)) if target_image_type_dir.exists(): shutil.rmtree(target_image_type_dir) shutil.copytree(image_type_dir, target_image_type_dir) set_executable_permissions(target_image_type_dir) finally: if temp_dir.exists(): shutil.rmtree(temp_dir) if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument("--path_to_downloaded_artifact", "-artifact_path", required=True, dest="artifact_path", help="Path to zipped artifacy downloaded from github actions workflow.") args = parser.parse_args() extract_artifact(args.artifact_path) |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |