def _on_harvest_status_message(self):
        try:
            log.debug("Updating harvest with id %s", self.message["id"])
            # Retrieve harvest model object
            harvest = Harvest.objects.get(harvest_id=self.message["id"])

            # And update harvest model object
            harvest.status = self.message["status"]
            harvest.stats = self.message.get("summary", {})
            harvest.infos = self.message.get("infos", [])
            harvest.warnings = self.message.get("warnings", [])
            harvest.errors = self.message.get("errors", [])
            harvest.token_updates = self.message.get("token_updates")
            harvest.uids = self.message.get("uids")
            harvest.warcs_count = self.message.get("warcs", {}).get("count", 0)
            harvest.warcs_bytes = self.message.get("warcs", {}).get("bytes", 0)
            harvest.date_started = iso8601.parse_date(self.message["date_started"])
            if "date_ended" in self.message:
                harvest.date_ended = iso8601.parse_date(self.message["date_ended"])
            harvest.save()

            # Update seeds based on tokens that have changed
            for id, token in self.message.get("token_updates", {}).items():
                # Try to find seed based on seedset and uid.
                try:
                    seed = Seed.objects.get(seed_id=id)
                    seed.token = token
                    seed.history_note = "Changed token based on information from harvester from harvest {}".format(
                            self.message["id"])
                    seed.save()
                except ObjectDoesNotExist:
                    log.error("Seed model object with seed_id %s not found to update token to %s", id, token)

            # Update seeds based on uids that have been returned
            for id, uid in self.message.get("uids", {}).items():
                # Try to find seed based on seedset and token.
                try:
                    seed = Seed.objects.get(seed_id=id)
                    seed.uid = uid
                    seed.history_note = "Changed uid based on information from harvester from harvest {}".format(
                            self.message["id"])
                    seed.save()
                except ObjectDoesNotExist:
                    log.error("Seed model object with seed_id %s not found to update uid to %s", id, uid)

        except __HOLE__:
            log.error("Harvest model object not found for harvest status message: %s",
                      json.dumps(self.message, indent=4))
dataset/ETHPy150Open gwu-libraries/sfm-ui/sfm/message_consumer/sfm_ui_consumer.py/SfmUiConsumer._on_harvest_status_message