def _setup_stats_status_codes(self):
        '''
        Sets up the status code stats collectors
        '''
        hostname = self._get_hostname()
        # we chose to handle 504's here as well as in the middleware
        # in case the middleware is disabled
        self.logger.debug("Setting up log retry middleware stats")
        status_code = 504
        temp_key = 'stats:crawler:{h}:{n}:{s}'.format(
            h=hostname, n=self.name, s=status_code)
        for item in self.settings['STATS_TIMES']:
            try:
                time = getattr(StatsCollector, item)

                self.stats_dict[time] = StatsCollector \
                        .get_rolling_time_window(
                                redis_conn=self.redis_conn,
                                key='{k}:{t}'.format(k=temp_key, t=time),
                                window=time,
                                cycle_time=self.settings['STATS_CYCLE'])
                self.logger.debug("Set up LRM status code {s}, {n} spider,"\
                    " host {h} Stats Collector '{i}'"\
                    .format(h=hostname, n=self.name, s=status_code, i=item))
            except __HOLE__ as e:
                self.logger.warning("Unable to find Stats Time '{s}'"\
                        .format(s=item))
        total = StatsCollector.get_hll_counter(redis_conn=self.redis_conn,
                        key='{k}:lifetime'.format(k=temp_key),
                        cycle_time=self.settings['STATS_CYCLE'],
                        roll=False)
        self.logger.debug("Set up status code {s}, {n} spider,"\
                    "host {h} Stats Collector 'lifetime'"\
                        .format(h=hostname, n=self.name, s=status_code))
        self.stats_dict['lifetime'] = total
dataset/ETHPy150Open istresearch/scrapy-cluster/crawler/crawling/log_retry_middleware.py/LogRetryMiddleware._setup_stats_status_codes