Sets the standard params for a stats request
972039
def _standard_params(klass, ids, metric_groups, **kwargs):
        
        end_time = kwargs.get('end_time', datetime.utcnow())
        start_time = kwargs.get('start_time', end_time - timedelta(seconds=604800))
        granularity = kwargs.get('granularity', GRANULARITY.HOUR)
        placement = kwargs.get('placement', PLACEMENT.ALL_ON_TWITTER)

        params = {
            'metric_groups': ','.join(metric_groups),
            'start_time': to_time(start_time, granularity),
            'end_time': to_time(end_time, granularity),
            'granularity': granularity.upper(),
            'entity': klass.ANALYTICS_MAP[klass.__name__],
            'placement': placement
        }

        params['entity_ids'] = ','.join(ids)

        return params
1167806
function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE ) {
    $input = array();
    $input['value']['statcode']  = $statcode;
    $input['value']['text']      = $text;
    if( $extdata )
      $input['value']['extdata'] = $extdata;
    $input['params']    = $this->_setParams( $params);
    $this->requeststatus[] = $input;
  }
1326421
def _prepare_ogc_request_params(self):
        
        self.ogc_request.image_format = MimeType.TIFF_d32f
        if self.ogc_request.custom_url_params is None:
            self.ogc_request.custom_url_params = {}
        self.ogc_request.custom_url_params.update({
            CustomUrlParam.SHOWLOGO: False,
            CustomUrlParam.TRANSPARENT: True,
            CustomUrlParam.EVALSCRIPT: S2_BANDS_EVALSCRIPT if self.all_bands else MODEL_EVALSCRIPT,
            CustomUrlParam.ATMFILTER: 'NONE'
        })
        self.ogc_request.create_request(reset_wfs_iterator=False)
798369
def init(self):
        """"""
        if not self.export_enable:
            return None
        # Build the RESTful URL where the stats will be posted
        url = '{}://{}:{}{}'.format(self.protocol,
                                    self.host,
                                    self.port,
                                    self.path)
        logger.info(
            "Stats will be exported to the RESTful endpoint {}".format(url))
        return url
26211
def set_run_params(self, **run_params):
        """"""
        self.run_params.update(run_params)
        self.check_run_params()
        self._backend.set_run_params(**run_params)
982471
def normalize_param(self, slf, args, kwargs):
        """"""
        if self.is_kwarg:
            kwargs = self.normalize_kwarg(slf.request, kwargs)
        else:
            args = self.normalize_arg(slf.request, args)
        return slf, args, kwargs
302733
def _patch_stats_request(request):
    '''
    '''
    filt = request.get('filter', {})
    if not filt.get('config', None):
        request['filter'] = filters.date_range('acquired',
                                               gt='1970-01-01T00:00:00Z')
    return request
849004
def post_stats(cls, stats_url, stats, timeout=2, auth_provider=None):
    
    def error(msg):
      # Report aleady closed, so just print error.
      print('WARNING: Failed to upload stats to {}. due to {}'.format(stats_url, msg),
            file=sys.stderr)
      return False

    # TODO(benjy): The upload protocol currently requires separate top-level params, with JSON
    # values.  Probably better for there to be one top-level JSON value, namely json.dumps(stats).
    # But this will first require changing the upload receiver at every shop that uses this.
    params = {k: cls._json_dump_options(v) for (k, v) in stats.items()}
    cookies = Cookies.global_instance()
    auth_provider = auth_provider or '<provider>'

    # We can't simply let requests handle redirects, as we only allow them for specific codes:
    # 307 and 308 indicate that the redirected request must use the same method, POST in this case.
    # So they indicate a true redirect of the POST itself, and we allow them.
    # The other redirect codes either must, or in practice do, cause the user agent to switch the
    # method to GET. So when they are encountered on a POST, it indicates an auth problem (a
    # redirection to a login page).
    def do_post(url, num_redirects_allowed):
      if num_redirects_allowed < 0:
        return error('too many redirects.')
      r = requests.post(url, data=params, timeout=timeout,
                        cookies=cookies.get_cookie_jar(), allow_redirects=False)
      if r.status_code in {307, 308}:
        return do_post(r.headers['location'], num_redirects_allowed - 1)
      elif r.status_code != 200:
        error('HTTP error code: {}. Reason: {}.'.format(r.status_code, r.reason))
        if 300 <= r.status_code < 400 or r.status_code == 401:
          print('Use `path/to/pants login --to={}` to authenticate against the stats '
                'upload service.'.format(auth_provider), file=sys.stderr)
        return False
      return True

    try:
      return do_post(stats_url, num_redirects_allowed=6)
    except Exception as e:  # Broad catch - we don't want to fail the build over upload errors.
      return error('Error: {}'.format(e))
1071221
def set_request_defaults(endpoint, private_token, sudo=nil)
      raise Error::MissingCredentials.new("Please set an endpoint to API") unless endpoint
      @private_token = private_token

      self.class.base_uri endpoint
      self.class.default_params :sudo => sudo
      self.class.default_params.delete(:sudo) if sudo.nil?
    end
578109
public function setParameters()
    {
        if (is_numeric($this->request['iColumns'])) {
            $params = array();
            $associations = array();
            for ($i=0; $i < intval($this->request['iColumns']); $i++) {
                $fields = explode('.', $this->request['mDataProp_' . $i]);
                $params[] = $this->request['mDataProp_' . $i];
                $associations[] = array('containsCollections' => false);

                if (count($fields) > 1)
                    $this->setRelatedEntityColumnInfo($associations[$i], $fields);
                else
                    $this->setSingleFieldColumnInfo($associations[$i], $fields[0]);
            }
            $this->parameters = $params;
            $this->associations = $associations;
        }
    }
467406
def stats(request, date_offset=0, fields=None, title_prefix=None, model='WikiItem'):
    
    data = {}

    modified_chart_data = data['chart']['chartdata']
    if 'y2' in data['chart']['chartdata']:
        matrix = db.Columns([modified_chart_data['y1'], modified_chart_data['y2']], ddof=0, tall=True)
    else:
        fields = ['date/time'] + fields
        matrix = db.Columns([modified_chart_data['x'], modified_chart_data['y']], ddof=0, tall=True)
    if fields and len(fields) > 1:
        fields = fields[:2]
    else:
        fields = [
            data['chart']['chartdata'].get('name1') or 'time',
            data['chart']['chartdata'].get('name2') or data['chart']['chartdata'].get('name') or 'value',
            ]
    fields = util.pluralize_field_names(fields)
    data.update({
        'stats': {
            'fields': fields,
            'heading': 'Statistics',
            'cov': zip(fields, matrix.cov()),
            'R': zip(fields, matrix.rho),
            },
        })
    data['chart']['chartdata'] = modified_chart_data
    data['chart']['chart_title'] = 'Time Series'
    return render_to_response('miner/stats.html', data)
389700
def params(self, dict):
        """"""
        self._configuration.update(dict)
        self._measurements.update()
1253430
function resetstat(req, res) {
  this.stats.reset();
  res.send(null, Constants.OK);
}
1058425
def params
      {}.
      merge!(measurable_params).
      merge!(custom_dimensions).
      merge!(custom_metrics).
      reject {|_,v| v.nil?}
    end
1306934
def set_attributes_for exc, request
      self.backtrace      = exc.backtrace.join("\n"),
      self.request_url    = request.original_url,
      self.request_method = request.request_method,
      self.parameters     = request.filtered_parameters,
      self.user_agent     = request.user_agent,
      self.client_ip      = request.remote_ip,
      self.status         = "new",
      self.description    = exc.inspect
    end
700521
private function _setParams()
	{
		foreach ($_GET as $key => $value) {
			$this->_params[$key] = $this->_sanitize($value);
		}

		foreach ($_POST as $key => $value) {
			$_POST[$key] = $this->_sanitize($value);
		}

		$nbElements = count($this->_requestVars);
		if ($nbElements > 3) {
			$i = 2;
			while ($i < $nbElements and $i + 1 < $nbElements) {
				if (ctype_digit($this->_requestVars[$i])) {
					$i += 2;
					continue;
				}

				$this->_params[$this->_requestVars[$i]] = $this->_sanitize($this->_requestVars[$i + 1]);
				$i += 2;
			}
		}

		if ($nbElements > 2) {
			$i = 2;
			while ($i < $nbElements) {
				$this->_params[$i - 2] = $this->_sanitize($this->_requestVars[$i]);
				$i++;
			}
		}

		return $this;
	}
970694
private void processCustomMetricParameters(@SuppressWarnings("rawtypes") GoogleAnalyticsRequest request, List<NameValuePair> postParms) {
    Map<String, String> customMetricParms = new HashMap<String, String>();
    for (String defaultCustomMetricKey : defaultRequest.custommMetrics().keySet()) {
      customMetricParms.put(defaultCustomMetricKey, defaultRequest.custommMetrics().get(defaultCustomMetricKey));
    }

    @SuppressWarnings("unchecked")
    Map<String, String> requestCustomMetrics = request.custommMetrics();
    for (String requestCustomDimKey : requestCustomMetrics.keySet()) {
      customMetricParms.put(requestCustomDimKey, requestCustomMetrics.get(requestCustomDimKey));
    }

    for (String key : customMetricParms.keySet()) {
      postParms.add(new BasicNameValuePair(key, customMetricParms.get(key)));
    }
  }