def pull_image(image_name):
    'Pulls the image.\n \n    If the policy is `IfNotPresent` the set of pulled image names is\n    checked and, if present, the method returns.  Otherwise, the pull attempt is made\n    and the set of pulled images is updated, when successful.\n \n    Since NotFound exceptions are tolerated, we trap for only that exception and let\n    the caller handle others.\n    '
    if (policy == POLICY_IF_NOT_PRESENT):
        if (image_name in pulled_images):
            logger.info("Image '{}' already pulled and policy is '{}'.  Checking existence.".format(image_name, policy))
            try:
                t1 = time.time()
                docker_client.images.get(image_name)
                t2 = time.time()
                logger.debug("Checked existence of image '{}' in {:.3f} secs.".format(image_name, (t2 - t1)))
                return
            except NotFound:
                pulled_images.remove(image_name)
                logger.warning("Previously pulled image '{}' was not found - attempting pull...".format(image_name))
    logger.debug("Pulling image '{}'...".format(image_name))
    try:
        t1 = time.time()
        docker_client.images.pull(image_name)
        t2 = time.time()
        pulled_images.add(image_name)
        logger.info("Pulled image '{}' in {:.3f} secs.".format(image_name, (t2 - t1)))
    except NotFound:
        logger.warning("Image '{}' was not found!".format(image_name))
Pulls the image.

If the policy is `IfNotPresent` the set of pulled image names is
checked and, if present, the method returns.  Otherwise, the pull attempt is made
and the set of pulled images is updated, when successful.

Since NotFound exceptions are tolerated, we trap for only that exception and let
the caller handle others.
def pull_image(image_name):
    'Pulls the image.\n \n    If the policy is `IfNotPresent` the set of pulled image names is\n    checked and, if present, the method returns.  Otherwise, the pull attempt is made\n    and the set of pulled images is updated, when successful.\n \n    Since NotFound exceptions are tolerated, we trap for only that exception and let\n    the caller handle others.\n    '
    if (policy == POLICY_IF_NOT_PRESENT):
        if (image_name in pulled_images):
            logger.info("Image '{}' already pulled and policy is '{}'.  Checking existence.".format(image_name, policy))
            try:
                t1 = time.time()
                docker_client.images.get(image_name)
                t2 = time.time()
                logger.debug("Checked existence of image '{}' in {:.3f} secs.".format(image_name, (t2 - t1)))
                return
            except NotFound:
                pulled_images.remove(image_name)
                logger.warning("Previously pulled image '{}' was not found - attempting pull...".format(image_name))
    logger.debug("Pulling image '{}'...".format(image_name))
    try:
        t1 = time.time()
        docker_client.images.pull(image_name)
        t2 = time.time()
        pulled_images.add(image_name)
        logger.info("Pulled image '{}' in {:.3f} secs.".format(image_name, (t2 - t1)))
    except NotFound:
        logger.warning("Image '{}' was not found!".format(image_name))