Return a dictionary of the job stats.

        Returns:
            dict: Dictionary of the stats.
428073
def to_dict(self):
        
        return {
            'name': self.name,
            'id': self.id,
            'type': self.type,
            'workflow_id': self.workflow_id,
            'queue': self.queue,
            'start_time': self.start_time,
            'arguments': self.arguments,
            'acknowledged': self.acknowledged,
            'func_name': self.func_name,
            'hostname': self.hostname,
            'worker_name': self.worker_name,
            'worker_pid': self.worker_pid,
            'routing_key': self.routing_key
        }
692391
def get_statistics(self):
        
        stats = {
            "creation_time": self._creation_time_in_seconds,
            "evictions": self._evictions,
            "expirations": self._expirations,
            "misses": self._misses,
            "hits": self._hits,
            "invalidations": self._invalidations,
            "invalidation_requests": self._invalidation_requests,
            "owned_entry_count": self.__len__(),
            "owned_entry_memory_cost": getsizeof(self),
        }

        return stats
444393
def as_dict(self):
        

        result_dict = super(Benchmark, self).as_dict()

        statuses = list()
        titles = list()
        descriptions = list()
        front_matters = list()
        rear_matters = list()
        platforms = list()
        version = None
        profiles = list()
        groups = list()

        for child in self.children:
            if isinstance(child, Version):
                version = child.as_dict()
            elif isinstance(child, Status):
                statuses.append(child.as_dict())
            elif isinstance(child, Title):
                titles.append(child.as_dict())
            elif isinstance(child, Description):
                descriptions.append(child.as_dict())
            elif isinstance(child, FrontMatter):
                front_matters.append(child.as_dict())
            elif isinstance(child, RearMatter):
                rear_matters.append(child.as_dict())
            elif isinstance(child, Platform):
                platforms.append(child.as_dict())
            elif isinstance(child, Profile):
                profiles.append(child.as_dict())
            elif isinstance(child, Group):
                groups.append(child.as_dict())

        if version is not None:
            result_dict['version'] = version
        if len(statuses) > 0:
            result_dict['statuses'] = statuses
        if len(titles) > 0:
            result_dict['titles'] = titles
        if len(descriptions) > 0:
            result_dict['descriptions'] = descriptions
        if len(front_matters) > 0:
            result_dict['front_matters'] = front_matters
        if len(rear_matters) > 0:
            result_dict['rear_matters'] = rear_matters
        if len(platforms) > 0:
            result_dict['platforms'] = platforms
        if len(profiles) > 0:
            result_dict['profiles'] = profiles
        if len(groups) > 0:
            result_dict['groups'] = groups

        return result_dict
1058761
def get_queue_stats(self):
        '''
        
        '''
        self.logger.debug("Gathering queue based stats")

        the_dict = {}
        keys = self.redis_conn.keys('*:*:queue')
        total_backlog = 0
        for key in keys:
            elements = key.split(":")
            spider = elements[0]
            domain = elements[1]
            spider = 'queue_' + spider

            if spider not in the_dict:
                the_dict[spider] = {
                    'spider_backlog': 0,
                    'num_domains': 0,
                    'domains': []
                }

            count = self.redis_conn.zcard(key)
            total_backlog += count
            the_dict[spider]['spider_backlog'] += count
            the_dict[spider]['num_domains'] += 1
            the_dict[spider]['domains'].append({'domain': domain,
                                                'backlog': count})

        the_dict['total_backlog'] = total_backlog
        ret_dict = {
            'queues': the_dict
        }

        return ret_dict
1233636
def get(self):
        
        stats = {}
        if self.start_date is not None:
            stats["start_date"] = self.start_date
        if self.end_date is not None:
            stats["end_date"] = self.end_date
        if self.aggregated_by is not None:
            stats["aggregated_by"] = self.aggregated_by
        if self.sort_by_metric is not None:
            stats["sort_by_metric"] = self.sort_by_metric
        if self.sort_by_direction is not None:
            stats["sort_by_direction"] = self.sort_by_direction
        if self.limit is not None:
            stats["limit"] = self.limit
        if self.offset is not None:
            stats["offset"] = self.offset
        if self.categories is not None:
            stats['categories'] = [category.get() for category in
                                   self.categories]
        return stats
26012
def to_dict(self):
        
        if self._dict is not None:
            return self._dict

        result = {}
        for key in self.ATTRIBUTES:
            value = getattr(self, key)
            if value:
                result[key] = value
        self._dict = result
        return result
581799
def get_summary(self):
        
        return {
            "count": self.count(),
            "pass": self.success_count(),
            "fail": self.failure_count(),
            "skip": self.skip_count(),
            "inconclusive": self.inconclusive_count(),
            "retries": self.retry_count(),
            "duration": self.total_duration()
        }
810574
def stats(self):
        ''''''
        data = Counter()
        for name, value, aggregated in self.raw:
            if aggregated:
                data['%s.max' % name] = max(data['%s.max' % name], value)
                data['%s.total' % name] += value
            else:
                data[name] = value

        return sorted(data.items())
310451
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'workspaces') and self.workspaces is not None:
            _dict['workspaces'] = [x._to_dict() for x in self.workspaces]
        if hasattr(self, 'pagination') and self.pagination is not None:
            _dict['pagination'] = self.pagination._to_dict()
        return _dict
533163
def get_stats(self):
        
        stats = {
            "input_file": self.media_file.input_file,
            "output_file": self.media_file.output_file,
            "stream_id": self.stream_id
        }
        stats.update(self.loudness_statistics)
        return stats
1144641
def as_dict(self):
        
        return {self.FLD_OP: self._op.name,
                self.FLD_MARK: self._pos,
                self.FLD_FLD: self._fld}
710912
def to_dict(self) -> dict:
        
        return {
            key: getattr(self, key)
            for key in self.__slots__
            if getattr(self, key) is not None
        }
690522
def stats_job(self, job: JobOrID) -> Stats:
        
        return self._stats_cmd(b'stats-job %d' % _to_id(job))
108371
def asDict(self):
        '''
            
        '''
        ret = {}
        for field in BackgroundTaskInfo.FIELDS:
            ret[field] = getattr(self, field)
        return ret
1163848
def to_dict(self):
        

        data = {"model": {}}

        data["model"]["description"] = self.description
        data["model"]["entity_name"] = self.entity_name
        data["model"]["package"] = self.package
        data["model"]["resource_name"] = self.resource_name
        data["model"]["rest_name"] = self.rest_name
        data["model"]["extends"] = self.extends
        data["model"]["get"] = self.allows_get
        data["model"]["update"] = self.allows_update
        data["model"]["create"] = self.allows_create
        data["model"]["delete"] = self.allows_delete
        data["model"]["root"] = self.is_root
        data["model"]["userlabel"] = self.userlabel
        data["model"]["template"] = self.template
        data["model"]["allowed_job_commands"] = self.allowed_job_commands

        data["attributes"] = []
        for attribute in self.attributes:
            data["attributes"].append(attribute.to_dict())

        data["children"] = []
        for api in self.child_apis:
            data["children"].append(api.to_dict())

        return data
143403
def get_stats_summary_dict(self):
        
        uptime = time.time() - self._established_time \
            if self._established_time != 0 else -1
        return {
            stats.UPDATE_MSG_IN: self.get_count(PeerCounterNames.RECV_UPDATES),
            stats.UPDATE_MSG_OUT: self.get_count(
                PeerCounterNames.SENT_UPDATES
            ),
            stats.TOTAL_MSG_IN: self.total_msg_recv,
            stats.TOTAL_MSG_OUT: self.total_msg_sent,
            stats.FMS_EST_TRANS: self.get_count(
                PeerCounterNames.FSM_ESTB_TRANSITIONS
            ),
            stats.UPTIME: uptime
        }
892819
def _dict_of_results(self):
        
        result_json = {}

        result_list = []
        for r in self.results:
            result_list.append({
                'name': r.check_name,
                'ok': r.ok,
                'status': r.status,
                'description': r.description,
                'message': r.message,
                'reference_url': r.reference_url,
                'logs': r.logs,
            })
        result_json["checks"] = result_list
        return result_json