Return meta information about an action. Cache the result as specified by the server
974878
def getMeta(self, uri):
        """"""

        action = urlparse(uri).path

        mediaKey = self.cacheKey + '_meta_' + action
        mediaKey = mediaKey.replace(' ', '__')

        meta = cache.get(mediaKey, None)

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

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

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

            if 'expire' not in r.headers:
                expire = 5 * 60  # 5 minutes of cache if the server didn't specified anything
            else:
                expire = int((parser.parse(r.headers['expire']) - datetime.datetime.now(tzutc())).total_seconds())  # Use the server value for cache

            if expire > 0:  # Do the server want us to cache ?
                cache.set(mediaKey, meta, expire)

        return meta
1329158
function obtainInfo(action, id, cb) {
    request.post({
        url: action,
        form: {
            code: id,
            lng: 'en',
            type: 'update'
        },
        headers: {
            'Referer': 'https://track24.net',
            'Origin': 'https://track24.net'
        },
        timeout: 20000,
        maxAttempts: 2,
    }, function (error, response, body) {
        if (error || response.statusCode != 200) {
            cb(utils.errorDown())
            return
        }

        let data = null
        try {
            data = JSON.parse(body)
        } catch (error) {
            return cb(utils.errorParser(id, error.message))
        }

        if (data.status == undefined ||
            data.status != 'ok' ||
            (data.data.events.length == 1 &&
            data.data.events[0].operationAttributeTranslated == 'The track code is added to the database Track24.ru for automatic monitoring.')) {
            cb(utils.errorNoData())
            return
        }

        data.gearTrackID = id

        let entity = null
        try {
            entity = createTrackerEntity(data)
        } catch (error) {
            return cb(utils.errorParser(id, error.message))
        }

        if (entity != null) cb(null, entity)
    })
}
289221
def _GetMetadataForClients(self, client_urns):
    """"""

    result = {}
    metadata_to_fetch = set()

    for urn in client_urns:
      try:
        result[urn] = self._cached_metadata[urn]
      except KeyError:
        metadata_to_fetch.add(urn)

    if metadata_to_fetch:
      if data_store.RelationalDBEnabled():
        client_ids = set(urn.Basename() for urn in metadata_to_fetch)
        infos = data_store.REL_DB.MultiReadClientFullInfo(client_ids)

        fetched_metadata = [
            export.GetMetadata(client_id, info)
            for client_id, info in infos.items()
        ]
      else:
        client_fds = aff4.FACTORY.MultiOpen(
            metadata_to_fetch, mode="r", token=self.token)

        fetched_metadata = [
            export.GetMetadataLegacy(client_fd, token=self.token)
            for client_fd in client_fds
        ]

      for metadata in fetched_metadata:
        metadata.source_urn = self.source_urn

        self._cached_metadata[metadata.client_urn] = metadata
        result[metadata.client_urn] = metadata
        metadata_to_fetch.remove(metadata.client_urn)

      for urn in metadata_to_fetch:
        default_mdata = export.ExportedMetadata(source_urn=self.source_urn)
        result[urn] = default_mdata
        self._cached_metadata[urn] = default_mdata

    return [result[urn] for urn in client_urns]
538073
def metadata(self):
        
        resp = self.r_session.get(self.server_url)
        resp.raise_for_status()
        return response_to_json_dict(resp)
646573
private function processResults($response_set, $meta) {
        // If getting an aggregation, results appear on the first response.
        if(count($meta['aggs']) > 0) {
            return $this->processAggResults($response_set[0], $meta);
        }

        // If we're only returning hits, we can return the count here.
        if($meta['count'] && !$meta['post_query']) {
            return ['count' => array_sum(array_map(function($x) { return $x['hits']['total']; }, $response_set))];
        }

        $results = [];
        $this->processHitResults($results, $response_set, $meta);
        return $results;
    }
905856
def _return_metadata():
    
    app = current_app
    retdict = {"auth": app.config["AUTH"]["type"]}
    for fld in ["name", "repository", "version", "description",
                "api_version"]:
        retdict[fld] = app.config[fld.upper()]
    return jsonify(retdict)
80515
def get_metadata(self, queue):
        
        uri = "/%s/%s/metadata" % (self.uri_base, utils.get_id(queue))
        resp, resp_body = self.api.method_get(uri)
        return resp_body
914861
def get(self, key):
        

        if not key in self._actions:
            return None
        if not key in self._cache:
            self._cache[key] = self._actions[key]()

        return self._cache[key]
130236
def get_request_meta(request, key):
    
    value = request.META.get(key, request.META.get(key.replace('_', '-'), '')).strip()
    if value == '':
        return None
    return value
184256
def _get_cached_response(self):
        """"""

        if not self._is_cached():
            response = self._download_response()
            self.cache.set_xml(self._get_cache_key(), response)

        return self.cache.get_xml(self._get_cache_key())
588772
def _get_action_endpoint(action):
    
    _endpoint = None
    if is_method(action):
        if hasattr(action, "_rule_cache"):
            rc = action._rule_cache
            if rc:
                k = list(rc.keys())[0]
                rules = rc[k]
                len_rules = len(rules)
                if len_rules == 1:
                    rc_kw = rules[0][1]
                    _endpoint = rc_kw.get("endpoint", None)
                    if not _endpoint:
                        _endpoint = _build_endpoint_route_name(action)
                elif len_rules > 1:
                    _prefix = _build_endpoint_route_name(action)
                    for r in Mocha._app.url_map.iter_rules():
                        if ('GET' in r.methods or 'POST' in r.methods) \
                                and _prefix in r.endpoint:
                            _endpoint = r.endpoint
                            break
    return _endpoint
464938
def _get_action(self, action):
        

        # If we don't have an action named that, bail out
        if action not in self.wsgi_actions:
            return None

        # Generate an ActionDescriptor if necessary
        if action not in self.wsgi_descriptors:
            self.wsgi_descriptors[action] = actions.ActionDescriptor(
                self.wsgi_actions[action],
                self.wsgi_extensions.get(action, []),
                self.wsgi_resp_type)

        # OK, return the method descriptor
        return self.wsgi_descriptors[action]
230246
def action_get(method_name):
    

    def action_get(_value, context, **_params):
        method = getattr(context["action"], method_name)
        return _get(method, context["key"], (), {})

    return action_get
1291477
async def get_action_status(self, uuid_or_prefix=None, name=None):
        
        results = {}
        action_results = []
        action_facade = client.ActionFacade.from_connection(
            self.connection()
        )
        if name:
            name_results = await action_facade.FindActionsByNames([name])
            action_results.extend(name_results.actions[0].actions)
        if uuid_or_prefix:
            # Collect list of actions matching uuid or prefix
            matching_actions = await action_facade.FindActionTagsByPrefix(
                [uuid_or_prefix])
            entities = []
            for actions in matching_actions.matches.values():
                entities = [{'tag': a.tag} for a in actions]
            # Get action results matching action tags
            uuid_results = await action_facade.Actions(entities)
            action_results.extend(uuid_results.results)
        for a in action_results:
            results[tag.untag('action-', a.action.tag)] = a.status
        return results
537327
def _get_action_from_method_and_request_uri(self, method, request_uri):
        

        # service response class should have 'SERVICE_NAME' class member,
        # if you want to get action from method and url
        if not hasattr(self, 'SERVICE_NAME'):
            return None
        service = self.SERVICE_NAME
        conn = boto3.client(service, region_name=self.region)

        # make cache if it does not exist yet
        if not hasattr(self, 'method_urls'):
            self.method_urls = defaultdict(lambda: defaultdict(str))
            op_names = conn._service_model.operation_names
            for op_name in op_names:
                op_model = conn._service_model.operation_model(op_name)
                _method = op_model.http['method']
                uri_regexp = self.uri_to_regexp(op_model.http['requestUri'])
                self.method_urls[_method][uri_regexp] = op_model.name
        regexp_and_names = self.method_urls[method]
        for regexp, name in regexp_and_names.items():
            match = re.match(regexp, request_uri)
            self.uri_match = match
            if match:
                return name
        return None
599543
function build_meta_information(object) {
      var res = {
        "timestamp": object.timestamp,
        "version": object.version,
        "changeset": object.changeset,
        "user": object.user,
        "uid": object.uid
      };
      for (var k in res)
        if (res[k] === undefined)
          delete res[k];
      return res;
    }
873680
def get_stats_action(cachespec, interval):
    
    if cachespec == 'global':
        caches = get_bcache_fs()
    else:
        caches = [Bcache.fromdevice(cachespec)]
    res = dict((c.cachepath, c.get_stats(interval)) for c in caches)
    return json.dumps(res, indent=4, separators=(',', ': '))