Listen for new Scores and update the relevant ScoreSummary.

        Args:
            sender: not used

        Kwargs:
            instance (Score): The score model whose save triggered this receiver.
508336
def update_score_summary(sender, **kwargs):
        
        score = kwargs['instance']
        try:
            score_summary = ScoreSummary.objects.get(
                student_item=score.student_item
            )
            score_summary.latest = score

            # A score with the "reset" flag set will always replace the current highest score
            if score.reset:
                score_summary.highest = score
            # The conversion to a float may return None if points possible is zero
            # In Python, None is always less than an integer, so any score
            # with non-null points possible will take precedence.
            elif score.to_float() > score_summary.highest.to_float():
                score_summary.highest = score
            score_summary.save()
        except ScoreSummary.DoesNotExist:
            ScoreSummary.objects.create(
                student_item=score.student_item,
                highest=score,
                latest=score,
            )
        except DatabaseError as err:
            logger.exception(
                u"Error while updating score summary for student item {}"
                .format(score.student_item)
            )
357776
def messageReceived(self, value, sender, target):
        
        if value.type != AMP_MESSAGE_TYPE:
            raise UnknownMessageType()
        inputBox = self._boxFromData(value.data)
        thunk = commandMethod.responderForName(self, inputBox[COMMAND])
        placeholder = _ProtocolPlaceholder(sender, target)
        arguments = thunk.command.parseArguments(inputBox, placeholder)
        try:
            result = thunk(**arguments)
        except tuple(thunk.command.errors.keys()), knownError:
            errorCode = thunk.command.errors[knownError.__class__]
            raise RevertAndRespond(
                Value(AMP_ANSWER_TYPE,
                         Box(_error_code=errorCode,
                             _error_description=str(knownError)).serialize()))
        else:
            response = thunk.command.makeResponse(result, None)
            return Value(AMP_ANSWER_TYPE, response.serialize())
392258
def update(self, **kwargs):
        

        old_json = self.__json__()

        for prop in kwargs:
            setattr(self, prop, kwargs[prop])

        # We send notif only if object has changed
        if old_json != self.__json__():
            self.controller.notification.emit("project.updated", self.__json__())
            self.dump()
928959
def repeat(self, target, sender, **kwargs):
        ""
        if target.startswith("#"):
            self.message(target, kwargs["msg"])
        else:
            self.message(sender, kwargs["msg"])
906671
def score(self, env=None, score_out=None):
        
        messages = {}
        self.assignment.set_args(
            score=True,
            score_out=score_out,
        )
        if env is None:
            import __main__
            env = __main__.__dict__
        self.run('scoring', messages, env=env)
        return messages['scoring']
63202
def send(self, sender: PytgbotApiBot):
        
        return sender.send_sticker(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            sticker=self.sticker, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )
1350327
def send(self, sender: PytgbotApiBot):
        
        return sender.send_audio(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            audio=self.audio, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, duration=self.duration, performer=self.performer, title=self.title, thumb=self.thumb, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )
24658
def update_notify_on_sample_invalidation(portal):
    
    setup = api.get_setup()

    # NotifyOnARRetract --> NotifyOnSampleInvalidation
    old_value = setup.__dict__.get("NotifyOnARRetract", True)
    setup.setNotifyOnSampleInvalidation(old_value)

    # NotifyOnRejection --> NotifyOnSampleRejection
    old_value = setup.__dict__.get("NotifyOnRejection", False)
    setup.setNotifyOnSampleRejection(old_value)
1250236
def set_score(self, member, score, pipe=None):
        
        pipe = self.redis if pipe is None else pipe
        pipe.zadd(self.key, {self._pickle(member): float(score)})
1038418
def _updateEndpoints(self,*args,**kwargs):
        

        sender = self.sender()
        if not self.ignoreEvents:
            self.ignoreEvents = True

            for binding in self.bindings.values():
                if binding.instanceId == id(sender):
                    continue
                
                if args: 
                    binding.setter(*args,**kwargs)
                else:
                    binding.setter(self.bindings[id(sender)].getter())

            self.ignoreEvents = False
1356255
def action_log_update(sender, instance, **kwargs):
    
    if instance.pk is not None:
        try:
            old = sender.objects.get(pk=instance.pk)
        except sender.DoesNotExist:
            pass
        else:
            new = instance

            changes = model_instance_diff(old, new)

            # Log an entry only if there are changes
            if changes:
                log_entry = LogAction.objects.create_log_action(
                    instance=instance,
                    action=LogAction.UPDATE,
                    changes=json.dumps(changes),
                )
1187028
def _on_write(self, sender, *args, **kwargs):
        
        self.on_write(data=kwargs.get('data', None))
572233
def sendInstanceChange(self, view_no: int,
                           suspicion=Suspicions.PRIMARY_DEGRADED):
        

        # If not found any sent instance change messages in last
        # `ViewChangeWindowSize` seconds or the last sent instance change
        # message was sent long enough ago then instance change message can be
        # sent otherwise no.
        canSendInsChange, cooldown = self.insChngThrottler.acquire()
        if canSendInsChange:
            logger.info(
                "{}{} sending an instance change with view_no {}"
                " since {}".format(
                    VIEW_CHANGE_PREFIX,
                    self,
                    view_no,
                    suspicion.reason))
            logger.info("{}{} metrics for monitor: {}"
                        .format(MONITORING_PREFIX, self,
                                self.provider.pretty_metrics()))
            msg = self._create_instance_change_msg(view_no, suspicion.code)
            self.send(msg)
            # record instance change vote for self and try to change the view
            # if quorum is reached
            self._on_verified_instance_change_msg(msg, self.name)
        else:
            logger.info("{} cannot send instance change sooner then {} seconds".format(self, cooldown))
1368783
def stats_send(template = nil, start_date = nil, end_date = nil, options = {})
      data = options
      if template != nil
        data[:template] = template
      end
      if start_date != nil
        data[:start_date] = start_date
      end
      if end_date != nil
        data[:end_date] = end_date
      end
      data[:stat] = 'send'
      api_get(:stats, data)
    end
1303442
def _update(self, data: TransDict, *args, **kwargs):
        

        for l in self.listeners:
            l(data, *args, **kwargs)
1205716
def payment_status_changed_listener(sender, instance, old_status, new_status, **kwargs):
    
    logger.debug("payment_status_changed_listener, old=%s, new=%s", old_status,
                 new_status)
    if old_status != 'paid' and new_status == 'paid':
        # Ensures that we process order only one
        instance.order.status = 'P'
        instance.order.save()
550410
def update_graderoster(graderoster, requestor):
    
    label = graderoster.graderoster_label()
    url = "{}/{}".format(graderoster_url, encode_section_label(label))
    headers = {"Content-Type": "application/xhtml+xml",
               "Connection": "keep-alive",
               "X-UW-Act-as": requestor.uwnetid}
    body = graderoster.xhtml()

    response = SWS_GradeRoster_DAO().putURL(url, headers, body)

    if response.status != 200:
        root = etree.fromstring(response.data)
        msg = root.find(".//*[@class='status_description']").text.strip()
        raise DataFailureException(url, response.status, msg)

    return GradeRoster(data=etree.fromstring(response.data.strip()),
                       section=graderoster.section,
                       instructor=graderoster.instructor)