Parse image information request and create response.
177548
def image_information_response(self):
        """"""
        dr = degraded_request(self.identifier)
        if (dr):
            self.logger.info("image_information: degraded %s -> %s" %
                             (self.identifier, dr))
            self.degraded = self.identifier
            self.identifier = dr
        else:
            self.logger.info("image_information: %s" % (self.identifier))
        # get size
        self.manipulator.srcfile = self.file
        self.manipulator.do_first()
        # most of info.json comes from config, a few things specific to image
        info = {'tile_height': self.config.tile_height,
                'tile_width': self.config.tile_width,
                'scale_factors': self.config.scale_factors
                }
        # calculate scale factors if not hard-coded
        if ('auto' in self.config.scale_factors):
            info['scale_factors'] = self.manipulator.scale_factors(
                self.config.tile_width, self.config.tile_height)
        i = IIIFInfo(conf=info, api_version=self.api_version)
        i.server_and_prefix = self.server_and_prefix
        i.identifier = self.iiif.identifier
        i.width = self.manipulator.width
        i.height = self.manipulator.height
        if (self.api_version >= '2.0'):
            # FIXME - should come from manipulator
            i.qualities = ["default", "color", "gray"]
        else:
            # FIXME - should come from manipulator
            i.qualities = ["native", "color", "gray"]
        i.formats = ["jpg", "png"]  # FIXME - should come from manipulator
        if (self.auth):
            self.auth.add_services(i)
        return self.make_response(i.as_json(),
                                  headers={"Content-Type": self.json_mime_type})
369485
def create_response(self, request, content, content_type):
        """"""

        return HttpResponse(content=content, content_type=content_type)
1132631
def process_request(self, request_object):
        """"""

        resource = request_object.entity_cls.create(**request_object.data)
        return ResponseSuccessCreated(resource)
10340
def parse_requests_response(response, **kwargs):
    

    return parse_headers(
        response.headers.get('content-disposition'), response.url, **kwargs)
1260176
def render_response(self, **kwargs):
        """"""
        from flask import Response
        return Response(self.render(**kwargs), mimetype='image/svg+xml')
617341
def image_to_file(self, path, get_image=True):
        """"""
        if not self.image_url or get_image:
            if not self.refresh_image():
                return False

        response = requests.get(self.image_url, stream=True)

        if response.status_code != 200:
            _LOGGER.warning(
                "Unexpected response code %s when requesting image: %s",
                str(response.status_code), response.text)
            raise AbodeException((ERROR.CAM_IMAGE_REQUEST_INVALID))

        with open(path, 'wb') as imgfile:
            copyfileobj(response.raw, imgfile)

        return True
831556
def image(id, options={})
      params = options
      get(surl('image') + id, params).body
    end
310854
def image(image_format, doc=None):
    """"""
    @on_valid('image/{0}'.format(image_format))
    def image_handler(data, **kwargs):
        if hasattr(data, 'read'):
            return data
        elif hasattr(data, 'save'):
            output = stream()
            if introspect.takes_all_arguments(data.save, 'format') or introspect.takes_kwargs(data.save):
                data.save(output, format=image_format.upper())
            else:
                data.save(output)
            output.seek(0)
            return output
        elif hasattr(data, 'render'):
            return data.render()
        elif os.path.isfile(data):
            return open(data, 'rb')

    image_handler.__doc__ = doc or "{0} formatted image".format(image_format)
    return image_handler
733499
def image_data(verbose=False):
  """"""
  # This is a principled use of the `global` statement; don't lint me.
  global _IMAGE_DATA  # pylint: disable=global-statement
  if _IMAGE_DATA is None:
    if verbose:
      logger.info("--- Downloading image.")
    with contextlib.closing(urllib.request.urlopen(IMAGE_URL)) as infile:
      _IMAGE_DATA = infile.read()
  return _IMAGE_DATA
180205
def request_image( title, options = {} )
      request( {
        action: 'query',
        prop: 'imageinfo',
        iiprop: 'url',
        iiurlwidth: options && options[:iiurlwidth] ? options[:iiurlwidth] : 200,
        titles: title
      }.merge( options ) )
    end
508198
def _request(self, data):
        """"""
        return requests.post(self.endpoint, data=data.encode("ascii")).content
749282
@GetMapping(path = {"/swivel/turingImage"})
    public void generate(final HttpServletResponse response, final HttpServletRequest request) throws Exception {
        response.setContentType("image/png");
        val principal = request.getParameter("principal");
        if (StringUtils.isBlank(principal)) {
            throw new IllegalArgumentException("No principal is specified in the turing image request");
        }
        generateImage(response.getOutputStream(), principal);
    }
1367572
def image_request_response(self, path):
        """"""
        # Parse the request in path
        if (len(path) > 1024):
            raise IIIFError(code=414,
                            text="URI Too Long: Max 1024 chars, got %d\n" % len(path))
        try:
            self.iiif.identifier = self.identifier
            self.iiif.parse_url(path)
        except IIIFRequestPathError as e:
            # Reraise as IIIFError with code=404 because we can't tell
            # whether there was an encoded slash in the identifier or
            # whether there was a bad number of path segments.
            raise IIIFError(code=404, text=e.text)
        except IIIFError as e:
            # Pass through
            raise e
        except Exception as e:
            # Something completely unexpected => 500
            raise IIIFError(code=500,
                            text="Internal Server Error: unexpected exception parsing request (" + str(e) + ")")
        dr = degraded_request(self.identifier)
        if (dr):
            self.logger.info("image_request: degraded %s -> %s" %
                             (self.identifier, dr))
            self.degraded = self.identifier
            self.identifier = dr
            self.iiif.quality = 'gray'
        else:
            # Parsed request OK, attempt to fulfill
            self.logger.info("image_request: %s" % (self.identifier))
        file = self.file
        self.manipulator.srcfile = file
        self.manipulator.do_first()
        if (self.api_version < '2.0' and
                self.iiif.format is None and
                'Accept' in request.headers):
            # In 1.0 and 1.1 conneg was specified as an alternative to format, see:
            # http://iiif.io/api/image/1.0/#format
            # http://iiif.io/api/image/1.1/#parameters-format
            formats = {'image/jpeg': 'jpg', 'image/tiff': 'tif',
                       'image/png': 'png', 'image/gif': 'gif',
                       'image/jp2': 'jps', 'application/pdf': 'pdf'}
            accept = do_conneg(request.headers['Accept'], list(formats.keys()))
            # Ignore Accept header if not recognized, should this be an error
            # instead?
            if (accept in formats):
                self.iiif.format = formats[accept]
        (outfile, mime_type) = self.manipulator.derive(file, self.iiif)
        # FIXME - find efficient way to serve file with headers
        self.add_compliance_header()
        return send_file(outfile, mimetype=mime_type)
699057
def make_response(self, status, content_type, response):
        """"""
        headers = [('Access-Control-Allow-Origin', '*'),
                   ('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'),
                   ('Access-Control-Allow-Headers', 'Content-Type'),
                   ('Access-Control-Max-Age', '86400'),
                   ('Content-type', content_type)
                  ]
        self.start_response(status, headers)
        return [response.encode()]
766839
def _req(self, endpoint, get_data=dict(), post_data=dict()):

        

        if get_data:
            request_parameter = "{}?{}".format(endpoint, urlencode(get_data))
        else:
            request_parameter = endpoint

        try:
            encdata = urlencode(post_data, True).encode('utf-8')
            response = self.oauth.request(request_parameter, data=encdata)
            self._checkResponseForErrors(response)
        except HTTPError as e:
            raise DeviantartError(e)

        return response
1080234
def loader():
    """"""
    url = request.args.get('url')  # read image URL as a request URL param
    response = requests.get(url)  # make request to static image file
    return response.content
1231057
def user_parse(data):
        """"""
        yield 'id', data.get('id') or data.get('user_id')
        first_name, _, last_name = data['name'].partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
        yield 'picture', data.get('profile_image_url')
        yield 'locale', data.get('lang')
        yield 'link', data.get('url')
        yield 'username', data.get('screen_name')
        city, _, country = map(lambda s: s.strip(),
                               data.get('location', '').partition(','))
        yield 'city', city
        yield 'country', country