def _fetch_image(url):
 log.debug(u'fetchart: downloading art: {0}'.format(url))
 try:
  with closing(requests_session.get(url, stream=True)) as resp:
   if (('Content-Type' not in resp.headers) or (resp.headers['Content-Type'] not in CONTENT_TYPES)):
    log.debug(u'fetchart: not an image')
    return
   with NamedTemporaryFile(suffix=DOWNLOAD_EXTENSION, delete=False) as fh:
    for chunk in resp.iter_content():
     fh.write(chunk)
   log.debug(u'fetchart: downloaded art to: {0}'.format(util.displayable_path(fh.name)))
   return fh.name
 except (IOError, requests.RequestException):
  log.debug(u'fetchart: error fetching art')

def _fetch_image ( url ) : log . debug ( u'fetchart: downloading art: {0}' . format ( url ) ) try : with closing ( requests_session . get ( url , stream = True ) ) as resp : if ( ( 'Content-Type' not in resp . headers ) or ( resp . headers [ 'Content-Type' ] not in CONTENT_TYPES ) ) : log . debug ( u'fetchart: not an image' ) return with NamedTemporaryFile ( suffix = DOWNLOAD_EXTENSION , delete = False ) as fh : for chunk in resp . iter_content ( ) : fh . write ( chunk ) log . debug ( u'fetchart: downloaded art to: {0}' . format ( util . displayable_path ( fh . name ) ) ) return fh . name except ( IOError , requests . RequestException ) : log . debug ( u'fetchart: error fetching art' )
fetch image from glance based on image type .