Make MEDIA_URL and current HttpRequest object
    available in template code.
347017
def url_info(request):
    

    return {
        'MEDIA_URL' : core_settings.MEDIA_URL,
        'STATIC_URL': core_settings.STATIC_URL,
        'VERSION' : core_settings.VERSION,
        'SERVER_INFO' : core_settings.SERVER_INFO,
        'SITE_NAME' : current_site_name,
        'CURRENT_SITE': current_site,
    }
851317
def get_request(self, request):
        
        return [DownloadRequest(url=self._get_url(item),
                                filename=self._get_filename(request, item),
                                data_type=request.image_format)
                for item in self._get_items(request)]
1211842
def static_serve(request, path, client):
    
    
    if msettings['SERVE_REMOTE']:
        # We're serving from S3, redirect there.
        url = client.remote_media_url().strip('/') + '/%(path)s'
        return redirect(url, permanent=True)

    if not msettings['SERVE_REMOTE'] and msettings['EMULATE_COMBO']:
        # Combo emulation is on and we're serving media locally. Try to see if
        # the given path matches a combo file defined in the JOINED dict in
        # the MEDIASYNC settings dict.
        combo_match = _find_combo_match(path)
        if combo_match:
            # We found a combo file match. Combine it and serve the result.
            return combo_serve(request, combo_match, client)

    # No combo file, but we're serving locally. Use the standard (inefficient)
    # Django static serve view.
    
    resp = serve(request, path, document_root=client.media_root, show_indexes=True)
    try:
        resp.content = client.process(resp.content, resp['Content-Type'], path)
    except KeyError:
        # HTTPNotModifiedResponse lacks the "Content-Type" key.
        pass
    return resp
59472
def _do_request(self, request, url, **kwargs):
        ""
        try:
            response = request(url, stream=True, **kwargs)
        except RequestException as e:
            raise RequestError(e)
        else:
            if response.status_code >= 400:
                raise ResponseError(response)
        # Try to return the response in the most useful fashion given it's
        # type.
        if response.headers.get('content-type') == 'application/json':
            try:
                # Try to decode as JSON
                return response.json()
            except (TypeError, ValueError):
                # If that fails, return the text.
                return response.text
        else:
            # This might be a file, so return it.
            if kwargs.get('params', {}).get('raw', True):
                return response.raw
            else:
                return response
706394
def _serve_individual_image(self, request):
    """"""
    run = request.args.get('run')
    tag = request.args.get('tag')
    index = int(request.args.get('index'))
    sample = int(request.args.get('sample', 0))
    data = self._get_individual_image(run, tag, index, sample)
    image_type = imghdr.what(None, data)
    content_type = _IMGHDR_TO_MIMETYPE.get(image_type, _DEFAULT_IMAGE_MIMETYPE)
    return http_util.Respond(request, data, content_type)
1342075
def adjust_response(self, response):
        ''

        try:
            c1 = self._replace(response.content,
                               self.header_placeholder,
                               self.embedded_holder.css)

            response.content = self._replace(c1,
                                             self.footer_placeholder,
                                             "\n".join([self.embedded_holder.config,
                                                        self.embedded_holder.scripts]))
        except AttributeError:
            # Catch the "FileResponse instance has no `content` attribute" error when serving media files in the Django development server.
            pass

        return response
1076804
def avail_images(call=None):
    '''
    
    '''
    all_servers = list_nodes_full()
    templates = {}
    for server in all_servers:
        if server["IsTemplate"]:
            templates.update({"Template Name": server["Name"]})
    return templates
522588
public GetMediaInfoOfFileResponse getMediaInfoOfFile(GetMediaInfoOfFileRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getBucket(), "The parameter bucket should NOT be null or empty string.");
        checkStringNotEmpty(request.getKey(), "The parameter key should NOT be null or empty string.");
        InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, MEDIAINFO);
        internalRequest.addParameter("bucket", request.getBucket());
        internalRequest.addParameter("key", request.getKey());
        return invokeHttpClient(internalRequest, GetMediaInfoOfFileResponse.class);
    }
714823
def get_instance(uri):
    """"""
    global _instances
    try:
        instance = _instances[uri]
    except KeyError:
        instance = MediaFile(
            uri,
            client.get_instance()
        )
        _instances[uri] = instance

    return instance
390780
protected function prepareRequestMediaVersionFromUrlPath () {
		$requestPath = $this->request->GetPath(TRUE);
		$requestPathExploded = explode('/', trim($requestPath, '/'));
		$requestPathFirstPart = mb_strtolower($requestPathExploded[0]);
		foreach ($this->allowedMediaVersionsAndUrlValues as $mediaSiteVersion => $mediaSiteUrlValue) {
			$mediaSiteUrlPrefix = mb_strtolower($mediaSiteUrlValue);
			if ($requestPathFirstPart === $mediaSiteUrlPrefix) {
				//$this->prepareSetUpRequestMediaSiteVersionIfValid($mediaSiteVersion);
				$this->requestMediaSiteVersion = $mediaSiteVersion;
				if (mb_strlen($mediaSiteUrlPrefix) > 0) 
					$this->request->SetPath(
						mb_substr($requestPath, mb_strlen('/' . $mediaSiteUrlPrefix))	
					);
				break;
			}
		}
	}
799677
def _request(self, http_method, relative_url='', **kwargs):
        """"""
        # It could be possible to call api.resource.get('/index')
        # but it would be non-intuitive that the path would resolve
        # to root of domain
        relative_url = self._remove_leading_slash(relative_url)

        # Add default kwargs with possible custom kwargs returned by
        # before_request
        new_kwargs = self.default_kwargs().copy()
        custom_kwargs = self.before_request(
            http_method,
            relative_url,
            kwargs.copy()
        )
        new_kwargs.update(custom_kwargs)

        response = requests.request(
            http_method,
            self._join_url(relative_url),
            **new_kwargs
        )

        return self.after_request(response)
93400
async def play_url(self, url, position=0):
        """"""
        headers = {'User-Agent': 'MediaControl/1.0',
                   'Content-Type': 'application/x-apple-binary-plist'}
        body = {'Content-Location': url, 'Start-Position': position}

        address = self._url(self.port, 'play')
        _LOGGER.debug('AirPlay %s to %s', url, address)

        resp = None
        try:
            # pylint: disable=no-member
            resp = await self.session.post(
                address, headers=headers,
                data=plistlib.dumps(body, fmt=plistlib.FMT_BINARY),
                timeout=TIMEOUT)
            await self._wait_for_media_to_end()
        finally:
            if resp is not None:
                resp.close()
1363378
def insert_virtual_media(self, url, device='FLOPPY'):
        """"""
        dic = {
            'DEVICE': device.upper(),
            'IMAGE_URL': url,
        }
        data = self._execute_command(
            'INSERT_VIRTUAL_MEDIA', 'RIB_INFO', 'write', dic)
        return data
53121
def getTemplate(self, uri, meta=None):
        """"""

        if not meta:

            metaKey = self.cacheKey + '_templatesmeta_cache_' + uri

            meta = cache.get(metaKey, None)

            if not meta:
                meta = self.getMeta(uri)
                cache.set(metaKey, meta, 15)

        if not meta:  # No meta, can return a template
            return None

        # Let's find the template in the cache
        action = urlparse(uri).path

        templateKey = self.cacheKey + '_templates_' + action + '_' + meta['template_tag']
        template = cache.get(templateKey, None)

        # Nothing found -> Retrieve it from the server and cache it
        if not template:

            r = self.doQuery('template/' + uri)

            if r.status_code == 200:  # Get the content if there is not problem. If there is, template will stay to None
                template = r.content

            cache.set(templateKey, template, None)  # None = Cache forever

        return template
635135
def link_callback(uri, rel):
    
    # use short variable names
    sUrl = settings.STATIC_URL      # Typically /static/
    sRoot = settings.STATIC_ROOT    # Typically /home/userX/project_static/
    mUrl = settings.MEDIA_URL       # Typically /static/media/
    # Typically /home/userX/project_static/media/
    mRoot = settings.MEDIA_ROOT

    # convert URIs to absolute system paths
    if uri.startswith(mUrl):
        path = os.path.join(mRoot, uri.replace(mUrl, ""))
    elif uri.startswith(sUrl):
        path = os.path.join(sRoot, uri.replace(sUrl, ""))
    else:
        return uri  # handle absolute uri (ie: http://some.tld/foo.png)

    # make sure that file exists
    if not os.path.isfile(path):
        raise Exception(
            'media URI must start with %s or %s' % (sUrl, mUrl)
        )
    return path
603888
def get_obj_url(request, obj):
    
    if (is_callable(getattr(obj, 'get_absolute_url', None)) and
            (not hasattr(obj, 'can_see_edit_link') or
             (is_callable(getattr(obj, 'can_see_edit_link', None)) and obj.can_see_edit_link(request)))):
        return call_method_with_unknown_input(obj.get_absolute_url, request=request)
    else:
        return get_url_from_model_core(request, obj)
1207706
def resource(resource_id):
    """"""
    resource_obj = app.db.resource(resource_id)

    if 'raw' in request.args:
        return send_from_directory(os.path.dirname(resource_obj.path),
                                   os.path.basename(resource_obj.path))

    return render_template('resource.html', resource=resource_obj)