def generate_image_from_url(url=None, timeout=30):

    file_name = posixpath.basename(url)
    img_tmp = NamedTemporaryFile(delete=True)

    try:
        response = requests.get(url, timeout=timeout)
        response.raise_for_status()
    except Exception as e:
        return None, None

    img_tmp.write(response.content)
    img_tmp.flush()

    image = File(img_tmp)
    image.seek(0)

    return file_name, image
wrapper for maybe raising an exception if apply failed.
dataset/ETHPy150Open marteinn/AtomicPress/atomicpress/utils/files.py/generate_image_from_url--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/parallel/client/client.py/Client._maybe_raise