Best Python code snippet using localstack_python
images.py
Source:images.py  
...46            ecr_session=session,47            **kwargs,48        )49    return images50def get_docker_image_details(51    repostory_name: str,52    image_tag: str,53    image_digest: str = None,54    registry_id: str = None,55    session: Session = None,56):57    """58    Function to retrieve the image information59    """60    session = get_session(session)61    client = session.client("ecr")62    image_q = {}63    if not image_digest and not image_tag:64        raise KeyError("You must specify at least one of image_digest or image_tag")65    if image_digest:66        image_q["imageDigest"] = image_digest67    if image_tag:68        image_q["imageTag"] = image_tag69    image_manifest_r = client.batch_get_image(70        registryId=registry_id,71        repositoryName=repostory_name,72        imageIds=[73            image_q,74        ],75    )76    if not keyisset("images", image_manifest_r) and keyisset(77        "failures", image_manifest_r78    ):79        print(image_manifest_r["failures"])80        return None81    return image_manifest_r["images"]82def get_all_images_details(83    repo_name: str,84    registry_id: str = None,85    ecr_session: Session = None,86) -> list:87    session = get_session(ecr_session)88    if registry_id is None:89        registry_id = session.client("sts").get_caller_identity()["Account"]90    repo_images = list_all_images(repo_name, ecr_session=session)91    images_details = []92    client = session.client("ecr")93    for images in chunked_iterable(repo_images, 10):94        images_details_r = client.batch_get_image(95            registryId=registry_id,96            repositoryName=repo_name,97            imageIds=images,98        )99        if keyisset("images", images_details_r):100            images_details += images_details_r["images"]101    return images_details102def retag_image(103    repostory_name: str,104    new_tag: str,105    image_tag: str,106    image_digest: str = None,107    delete_old_tag: str = True,108    registry_id: str = None,109    session: Session = None,110):111    """112    Function to rename an image in ECR via API call113    :param repostory_name: ECR Repository name114    :param str new_tag: The new tag for the image115    :param bool delete_old_tag: Whether or no to keep the tag for the image116    :param str image_digest: The image digest (sha)117    :param str image_tag: The image118    :param boto3.session.Session session:119    """120    session = get_session(session)121    if registry_id is None:122        registry_id = session.client("sts").get_caller_identity()["Account"]123    print(f"Registry ID set to {registry_id}")124    client = session.client("ecr")125    images = get_docker_image_details(126        repostory_name, image_tag, image_digest, registry_id, session127    )128    if not images:129        print("No images found. Skipping")130        return None131    if len(images) > 1:132        print("Only one image expected to rename. Skipping")133        return None134    image = images[0]135    client.put_image(136        registryId=registry_id,137        repositoryName=repostory_name,138        imageManifest=image["imageManifest"],139        imageManifestMediaType=image["imageManifestMediaType"],...diagnose.py
Source:diagnose.py  
...125                result.append(root)126        return result127    except Exception as e:128        return ["traversing files failed %s" % e]129def get_docker_image_details() -> Dict[str, str]:130    return bootstrap.get_docker_image_details()131def get_host_kernel_version() -> str:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
