Update resource consumption details and price estimate if its configuration has changed.
        Create estimates for previous months if resource was created not in current month.
519439
def resource_update(sender, instance, created=False, **kwargs):
    
    resource = instance
    try:
        new_configuration = CostTrackingRegister.get_configuration(resource)
    except ResourceNotRegisteredError:
        return
    models.PriceEstimate.update_resource_estimate(
        resource, new_configuration, raise_exception=not _is_in_celery_task())
    # Try to create historical price estimates
    if created:
        _create_historical_estimates(resource, new_configuration)
681003
def add_changed_resources(self, resources, change=None):
        
        for resource in resources:
            rc = Resource(resource=resource, change=change)
            self.add(rc)
311929
public void setResourceChanges(java.util.Collection<ResourceChange> resourceChanges) {
        if (resourceChanges == null) {
            this.resourceChanges = null;
            return;
        }

        this.resourceChanges = new java.util.ArrayList<ResourceChange>(resourceChanges);
    }
332877
function (data, estimatedEntropy, source) {
    source = source || "user";

    var id,
      i, tmp,
      t = (new Date()).valueOf(),
      robin = this._robins[source],
      oldReady = this.isReady(), err = 0, objName;

    id = this._collectorIds[source];
    if (id === undefined) { id = this._collectorIds[source] = this._collectorIdNext ++; }

    if (robin === undefined) { robin = this._robins[source] = 0; }
    this._robins[source] = ( this._robins[source] + 1 ) % this._pools.length;

    switch(typeof(data)) {

    case "number":
      if (estimatedEntropy === undefined) {
        estimatedEntropy = 1;
      }
      this._pools[robin].update([id,this._eventId++,1,estimatedEntropy,t,1,data|0]);
      break;

    case "object":
      objName = Object.prototype.toString.call(data);
      if (objName === "[object Uint32Array]") {
        tmp = [];
        for (i = 0; i < data.length; i++) {
          tmp.push(data[i]);
        }
        data = tmp;
      } else {
        if (objName !== "[object Array]") {
          err = 1;
        }
        for (i=0; i<data.length && !err; i++) {
          if (typeof(data[i]) !== "number") {
            err = 1;
          }
        }
      }
      if (!err) {
        if (estimatedEntropy === undefined) {
          /* horrible entropy estimator */
          estimatedEntropy = 0;
          for (i=0; i<data.length; i++) {
            tmp= data[i];
            while (tmp>0) {
              estimatedEntropy++;
              tmp = tmp >>> 1;
            }
          }
        }
        this._pools[robin].update([id,this._eventId++,2,estimatedEntropy,t,data.length].concat(data));
      }
      break;

    case "string":
      if (estimatedEntropy === undefined) {
       /* English text has just over 1 bit per character of entropy.
        * But this might be HTML or something, and have far less
        * entropy than English...  Oh well, let's just say one bit.
        */
       estimatedEntropy = data.length;
      }
      this._pools[robin].update([id,this._eventId++,3,estimatedEntropy,t,data.length]);
      this._pools[robin].update(data);
      break;

    default:
      err=1;
    }
    if (err) {
      throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");
    }

    /* record the new strength */
    this._poolEntropy[robin] += estimatedEntropy;
    this._poolStrength += estimatedEntropy;

    /* fire off events */
    if (oldReady === this._NOT_READY) {
      if (this.isReady() !== this._NOT_READY) {
        this._fireEvent("seeded", Math.max(this._strength, this._poolStrength));
      }
      this._fireEvent("progress", this.getProgress());
    }
  }
1208626
def _update(self):
        """"""
        self.dataChanged.emit(self.createIndex(0, 0), self.createIndex(
            len(self.collection), len(self.header)))
329222
def _refresh_resource_index(self, resource):
        
        if self._resource_config(resource, 'FORCE_REFRESH', True):
            self.elastic(resource).indices.refresh(self._resource_index(resource))
237649
def _get_consumed(self, time):
        
        minutes_from_last_update = self._get_minutes_from_last_update(time)
        if minutes_from_last_update < 0:
            raise ConsumptionDetailCalculateError('Cannot calculate consumption if time < last modification date.')
        _consumed = {}
        for consumable_item in set(list(self.configuration.keys()) + list(self.consumed_before_update.keys())):
            after_update = self.configuration.get(consumable_item, 0) * minutes_from_last_update
            before_update = self.consumed_before_update.get(consumable_item, 0)
            _consumed[consumable_item] = after_update + before_update
        return _consumed
113569
def refresh(self, **kwargs):
        """"""
        self.resource.refresh(**kwargs)
        self.rdict = self.resource.entries
        self._update_stats()
201294
def update(self):
        
        if self._owner_changed:
            self.update_owner(self.owner)

        self._resources = [res.name for res in self.resources]
        return self.parent.update(self)
599907
def perform_update(self, data, instance):
        

        for key, val in data.items():
            setattr(instance, key, val)
453414
def update(context, resource, **kwargs):
    """"""
    etag = kwargs.pop('etag')
    id = kwargs.pop('id')
    data = utils.sanitize_kwargs(**kwargs)
    uri = '%s/%s/%s' % (context.dci_cs_api, resource, id)
    r = context.session.put(uri, timeout=HTTP_TIMEOUT,
                            headers={'If-match': etag},
                            json=data)
    return r
631184
def _update_resourcescenario(scenario, resource_scenario, dataset=None, new=False, user_id=None, source=None):
    
    if scenario is None:
        scenario = db.DBSession.query(Scenario).filter(Scenario.id==1).one()

    ra_id = resource_scenario.resource_attr_id

    log.debug("Assigning resource attribute: %s",ra_id)
    try:
        r_scen_i = db.DBSession.query(ResourceScenario).filter(
                        ResourceScenario.scenario_id==scenario.id,
                        ResourceScenario.resource_attr_id==ra_id).one()
    except NoResultFound as e:
        log.info("Creating new RS")
        r_scen_i = ResourceScenario()
        r_scen_i.resource_attr_id = resource_scenario.resource_attr_id
        r_scen_i.scenario_id      = scenario.id
        r_scen_i.scenario = scenario

        db.DBSession.add(r_scen_i)


    if scenario.locked == 'Y':
        log.info("Scenario %s is locked",scenario.id)
        return r_scen_i


    if dataset is not None:
        r_scen_i.dataset = dataset

        return r_scen_i

    dataset = resource_scenario.dataset

    value = dataset.parse_value()

    log.info("Assigning %s to resource attribute: %s", value, ra_id)

    if value is None:
        log.info("Cannot set data on resource attribute %s",ra_id)
        return None

    metadata = dataset.get_metadata_as_dict(source=source, user_id=user_id)
    data_unit_id = dataset.unit_id

    data_hash = dataset.get_hash(value, metadata)

    assign_value(r_scen_i,
                 dataset.type.lower(),
                 value,
                 data_unit_id,
                 dataset.name,
                 metadata=metadata,
                 data_hash=data_hash,
                 user_id=user_id,
                 source=source)
    return r_scen_i
900302
def resource_changed?(resource, response)
      changed = false
      puts "checking for changes on #{resource.url}"
      puts "response.response.hash: #{response.response.hash}"
      puts "resource.last_modified_hash: #{resource.last_modified_hash}"
      if response.response.hash != resource.last_modified_hash
        puts "changed!!!!\n\n\n\n"
        changed = true
      end
    end
770341
def update_build_configuration_set(id, **kwargs):
    
    data = update_build_configuration_set_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
488516
def update(self):
        

        if not self.calendar_id:
            return False

        url = self.build_url(self._endpoints.get('calendar'))

        data = {
            self._cc('name'): self.name,
            self._cc('color'): self._cc(self.color.value
                                        if isinstance(self.color, CalendarColor)
                                        else self.color)
        }

        response = self.con.patch(url, data=data)

        return bool(response)
1269732
private function updatePeakMemoryUsage ()
	{
		$memory = memory_get_peak_usage ();
		if ($memory > $this->peakMemoryUsage)
		{
			$this->peakMemoryUsage = $memory;
			$this->setParameter ('Memory/PeakMemoryUsage', $memory);

			if (extension_loaded ('newrelic'))
			{
				newrelic_custom_metric ('Custom/PeakMemoryUsage', $memory);
			}
		}
	}
1181163
def add_resource(self, resource):
        """"""
        if resource.exists():
            self.resources[resource] = self.timekeeper.get_indicator(resource)
        else:
            self.resources[resource] = None