Print the extended JSON report to reporter's output.

        :param dict stats: Metrics for the current pylint run
        :param dict previous_stats: Metrics for the previous pylint run
779029
def on_close(self, stats, previous_stats):
        
        reports = {
            'messages': self._messages,
            'stats': stats,
            'previous': previous_stats,
        }
        print(json.dumps(reports, cls=JSONSetEncoder, indent=4), file=self.out)
1062855
def json_dumps(self, data, **options):
        
        params = {'sort_keys': True, 'indent': 2}
        params.update(options)
        # This code is based off django's built in JSON serializer
        if json.__version__.split('.') >= ['2', '1', '3']:
            # Use JS strings to represent Python Decimal instances (ticket #16850)
            params.update({'use_decimal': False})
        return json.dumps(data, cls=DjangoJSONEncoder, **params)
407310
def read_stats(self, *stats):
        

        self.statistics = OrderedDict()
        for port in self.ports:
            port_stats = IxeStatTotal(port).get_attributes(FLAG_RDONLY, *stats)
            port_stats.update({c + '_rate': v for c, v in
                               IxeStatRate(port).get_attributes(FLAG_RDONLY, *stats).items()})
            self.statistics[str(port)] = port_stats
        return self.statistics
846872
def load_existing_json():
        
        dir = logger.get_logger_dir()
        fname = os.path.join(dir, JSONWriter.FILENAME)
        if tf.gfile.Exists(fname):
            with open(fname) as f:
                stats = json.load(f)
                assert isinstance(stats, list), type(stats)
                return stats
        return None
1296557
def _iostats_dict(header, stats):
    '''
    
    '''
    stats = [float((sum(stat) / len(stat)).quantize(decimal.Decimal('.01'))) for stat in zip(*stats)]
    stats = dict(zip(header, stats))
    return stats
56699
def _dump_crawl_stats(self):
        '''
        
        '''
        extras = {}
        spiders = {}

        spider_set = set()
        total_spider_count = 0

        keys = self.redis_conn.keys('stats:crawler:*:*:*')
        for key in keys:
            # we only care about the spider
            elements = key.split(":")
            spider = elements[3]

            if spider not in spiders:
                spiders[spider] = 0

            if len(elements) == 6:
                # got a time based stat
                response = elements[4]
                end = elements[5]

                final = '{s}_{r}_{e}'.format(s=spider, r=response, e=end)

                if end == 'lifetime':
                    value = self.redis_conn.execute_command("PFCOUNT", key)
                else:
                    value = self.redis_conn.zcard(key)

                extras[final] = value

            elif len(elements) == 5:
                # got a spider identifier
                spiders[spider] += 1
                total_spider_count += 1
                spider_set.add(spider)

            else:
                self.logger.warn("Unknown crawler stat key", {"key":key})

        # simple counts
        extras['unique_spider_count'] = len(spider_set)
        extras['total_spider_count'] = total_spider_count

        for spider in spiders:
            extras['{k}_spider_count'.format(k=spider)] = spiders[spider]

        if not self.logger.json:
            self.logger.info('Crawler Stats Dump:\n{0}'.format(
                    json.dumps(extras, indent=4, sort_keys=True)))
        else:
            self.logger.info('Crawler Stats Dump', extra=extras)
1189678
def _print_stats(cls, stats: Statistics, human_format_speed: bool=True):
        ''''''
        time_length = datetime.timedelta(
            seconds=int(stats.stop_time - stats.start_time)
        )
        file_size = wpull.string.format_size(stats.size)

        if stats.bandwidth_meter.num_samples:
            speed = stats.bandwidth_meter.speed()

            if human_format_speed:
                speed_size_str = wpull.string.format_size(speed)
            else:
                speed_size_str = '{:.1f} b'.format(speed * 8)
        else:
            speed_size_str = _('-- B')

        _logger.info(_('FINISHED.'))
        _logger.info(__(
            _(
                'Duration: {preformatted_timedelta}. '
                'Speed: {preformatted_speed_size}/s.'
            ),
            preformatted_timedelta=time_length,
            preformatted_speed_size=speed_size_str,
        ))
        _logger.info(__(
            gettext.ngettext(
                'Downloaded: {num_files} file, {preformatted_file_size}.',
                'Downloaded: {num_files} files, {preformatted_file_size}.',
                stats.files
            ),
            num_files=stats.files,
            preformatted_file_size=file_size
        ))

        if stats.is_quota_exceeded:
            _logger.info(_('Download quota exceeded.'))
1302781
def report_stats(self):
        """"""
        if not self.previous:
            self.previous = dict()
            for key in self.counters:
                self.previous[key] = 0
        values = {
            'name': self.name,
            'consumer_name': self.consumer_name,
            'counts': dict(self.counters),
            'previous': dict(self.previous)
        }
        self.previous = dict(self.counters)
        return values
1295802
def dump_as_json(record, output_file):
    
    def default_func(value):
        """
        Default conversion for JSON value.
        """
        if isinstance(value, frozenset):
            return sorted(value)
        raise TypeError(repr(value) + " is not JSON serializable")

    converted_record = record._replace(
        ordered_statistics=[x._asdict() for x in record.ordered_statistics])
    json.dump(
        converted_record._asdict(), output_file,
        default=default_func, ensure_ascii=False)
    output_file.write(os.linesep)
1352394
def _dict_to_report_line(cls, report_dict):
        ''''''
        return '\t'.join([str(report_dict[x]) for x in report.columns])
287996
@SuppressWarnings({ "rawtypes" })
    static void report(Progressable progressable, Stats stats) {
        progressable = (Progressable) CompatHandler.unwrap(progressable);

        if (progressable == null || progressable == Reporter.NULL) {
            return;
        }

        if (progressable instanceof Reporter) {
            Reporter reporter = (Reporter) progressable;
            for (Counter count : Counter.ALL) {
                oldApiCounter(reporter, count, count.get(stats));
            }
        }

        if (progressable instanceof org.apache.hadoop.mapreduce.TaskInputOutputContext) {
            TaskInputOutputContext compatTioc = CompatHandler.taskInputOutputContext((org.apache.hadoop.mapreduce.TaskInputOutputContext) progressable);
            for (Counter count : Counter.ALL) {
                newApiCounter(compatTioc, count, count.get(stats));
            }
        }
    }
748136
def print_report(self):
        
        report = compare_report_print(
            self.sorted, self.scores, self.best_name)
        print(report)
1322376
def stats(data):
    '''
    '''
    return {'len': len(data),
            'mean': np.mean(data),
            'sum': np.sum(data),
            'std': np.std(data),
            'min': np.min(data),
            'max': np.max(data)}
1135438
def stats(self):
        
        printDebug("Classes.....: %d" % len(self.classes))
        printDebug("Properties..: %d" % len(self.properties))
1358019
def _print_daily_stats(self, conn):
        
        stats = conn.get_send_statistics()
        stats = stats['GetSendStatisticsResponse']['GetSendStatisticsResult']
        stats = stats['SendDataPoints']
        
        today = datetime.date.today()
        current_day = {'HeaderName': 'Current Day: %s/%s' % (today.month, 
                                                             today.day)}
        prev_day = {'HeaderName': 'Past two weeks'}
        
        for data_point in stats:
            if self._is_data_from_today(data_point):
                day_dict = current_day
            else:
                day_dict = prev_day
                
            self._update_day_dict(data_point, day_dict)      

        for day in [current_day, prev_day]:
            print "--- %s ---" % day.get('HeaderName', 0)
            print "  Delivery attempts: %s" % day.get('DeliveryAttempts', 0)
            print "  Bounces: %s" % day.get('Bounces', 0)
            print "  Rejects: %s" % day.get('Rejects', 0)
            print "  Complaints: %s" % day.get('Complaints', 0)
654656
def print_scan_summary(json_data, names=None):
    '''
    
    '''
    max_col_width = 50
    min_width = 15

    def _max_width(data):
        max_name = 0
        for name in data:
            max_name = len(data[name]) if len(data[name]) > max_name \
                else max_name
        # If the max name length is less that max_width
        if max_name < min_width:
            max_name = min_width

        # If the man name is greater than the max col leng
        # we wish to use
        if max_name > max_col_width:
            max_name = max_col_width

        return max_name

    clean = True

    if len(names) > 0:
        max_width = _max_width(names)
    else:
        max_width = min_width
    template = "{0:" + str(max_width) + "}   {1:5} {2:5} {3:5} {4:5}"
    sevs = ['critical', 'important', 'moderate', 'low']
    writeOut(template.format("Container/Image", "Cri", "Imp", "Med", "Low"))
    writeOut(template.format("-" * max_width, "---", "---", "---", "---"))
    res_summary = json_data['results_summary']
    for image in res_summary.keys():
        image_res = res_summary[image]
        if 'msg' in image_res.keys():
            tmp_tuple = (image_res['msg'], "", "", "", "")
        else:
            if len(names) < 1:
                image_name = image[:max_width]
            else:
                image_name = names[image][-max_width:]
                if len(image_name) == max_col_width:
                    image_name = '...' + image_name[-(len(image_name) - 3):]

            tmp_tuple = tuple([image_name] +
                              [str(image_res[sev]) for sev in sevs])
            sev_results = [image_res[sev] for sev in
                           sevs if image_res[sev] > 0]
            if len(sev_results) > 0:
                clean = False
        writeOut(template.format(*tmp_tuple))
    writeOut("")
    return clean
208469
def _refresh_stats(self):
        

        # regex identifies all possible stats files.
        #regex = self.outfolder +  "*_stats.tsv"       
        #stats_files = glob.glob(regex)
        #stats_files.insert(self.pipeline_stats_file) # last one is the current pipeline
        #for stats_file in stats_files:

        stats_file = self.pipeline_stats_file
        if os.path.isfile(self.pipeline_stats_file):
            with open(stats_file, 'r') as stat_file:
                for line in stat_file:
                    try:
                        # Someone may have put something that's not 3 columns in the stats file
                        # if so, shame on him, but we can just ignore it.
                        key, value, annotation  = line.split('\t')
                    except ValueError:
                        print("WARNING: Each row in a stats file is expected to have 3 columns")

                    if annotation.rstrip() == self.name or annotation.rstrip() == "shared":
                        self.stats_dict[key] = value.strip()