Exemplo n.º 1
0
def baked_image_from_abi(abi):
    image_url = abi.badge_instance.get('image')
    if image_url is not None:
        try:
            image = requests.get(image_url)

            unbake(image)
        except:
            pass
        else:
            return image

    try:
        image_url = abi.badge.get('image')
        unbaked_image = ContentFile(
            requests.get(image_url)._content, "unbaked_image.png"
        )

        unbaked_image.open()
        baked_image = bake(
            unbaked_image, json.dumps(dict(abi.badge_instance), indent=2)
        )
    except requests.exceptions.SSLError as e:
        raise ValidationError("SSL failure retrieving image " + image_url)
    except Exception as e:
        raise e
    else:
        return baked_image
Exemplo n.º 2
0
def get_instance_url_from_image(imageFile):
    """ unbake an open file, and return the assertion URL contained within """
    image_contents = unbake(imageFile)

    if image_contents is None:
        raise ValidationError("No assertion found in image")

    return get_instance_url_from_unknown_string(image_contents)
Exemplo n.º 3
0
def get_instance_url_from_image(imageFile):
    """ unbake an open file, and return the assertion URL contained within """
    image_contents = unbake(imageFile)

    if image_contents is None:
        raise ValidationError("No assertion found in image")

    return get_instance_url_from_unknown_string(image_contents)
Exemplo n.º 4
0
def get_instance_url_from_image(imageFile):
    """ unbake an open file, and return the assertion URL contained within """
    image_contents = unbake(imageFile)

    return get_instance_url_from_unknown_string(image_contents)
Exemplo n.º 5
0
def get_instance_url_from_image(imageFile):
    """ unbake an open file, and return the assertion URL contained within """
    image_contents = unbake(imageFile)

    return get_instance_url_from_unknown_string(image_contents)