def output_stat(self): global END content = ['torrents:'] interval = time.time() - self.begin_time content.append(' PID: %s' % os.getpid()) content.append(' Time: %s' % time.strftime('%Y-%m-%d %H:%M:%S')) content.append(' Run time: %s' % get_time_formatter(interval)) content.append(' Get BT nums: %d' % self._count_success) content.append(' Get TCP nums: %d' % self._count_receive_tcp) content.append(' Get invalid TCP nums: %d' % self._count_invalid_msg) content.append(' DownLoad error nums: %d' % self._count_btdownload_error) content.append(' BDecode error nums: %d' % self._count_bdecode_error) content.append(' Meta decode error nums: %d' % self._count_decode_error) content.append('\n') try: with open(self._stat_file, 'wb') as f: f.write('\n'.join(content)) except Exception as err: self.log('output_stat error %s', str(err)) if not END: Timer(OUTPUT_STATFILE, self.output_stat).start() else: exit()
def output_stat(self): global END total_success = 0 total_error = 0 total_repeat = 0 individualData = '' for host in self._count_insert: total_success += self._count_insert[host] individualData += ' Host %s Success: %d \n' % (host,self._count_insert[host]) for host in self._count_error: total_error += self._count_error[host] individualData += ' Host %s Errors: %d \n' % (host,self._count_error[host]) for host in self._count_delete: total_error += self._count_delete[host] individualData += ' Host %s Delete: %d \n' % (host,self._count_delete[host]) for host in self._count_repeat: total_repeat += self._count_repeat[host] individualData += ' Host %s Repeat: %d \n' % (host,self._count_repeat[host]) content = ['torrents:'] interval = time.time() - self.begin_time content.append(' PID: %s \n' % os.getpid()) content.append(' Time: %s \n' % time.strftime('%Y-%m-%d %H:%M:%S')) content.append(' Run time: %s \n' % get_time_formatter(interval)) content.append(' Get invalid TCP nums: %d \n' % self._count_invalid_msg) content.append(' Get BT nums: %d \n' % total_success) content.append(' Repeat nums: %d \n' % total_repeat) content.append(' Error nums: %d \n' % total_error) content.append(individualData) content.append('\n') try: with open(self._stat_file, 'wb') as f: f.write('\n'.join(content)) except Exception as err: self.log('output_stat error %s', str(err)) if not END: Timer(OUTPUT_STATFILE, self.output_stat).start() else: exit(1)
def output_stat(self): global END content = ['torrents:'] interval = time.time() - self.begin_time content.append(' PID: %s' % os.getpid()) content.append(' Time: %s' % time.strftime('%Y-%m-%d %H:%M:%S')) content.append(' Run time: %s' % get_time_formatter(interval)) content.append(' Get BT nums: %d' % self._count_success) content.append(' Get TCP nums: %d' % self._count_receive_tcp) content.append(' Get invalid TCP nums: %d' % self._count_invalid_msg) content.append(' DownLoad error nums: %d' % self._count_btdownload_error) content.append(' BDecode error nums: %d'% self._count_bdecode_error) content.append(' Meta decode error nums: %d' % self._count_decode_error) content.append('\n') try: with open(self._stat_file, 'wb') as f: f.write('\n'.join(content)) except Exception as err: self.log('output_stat error %s', str(err)) if not END: Timer(OUTPUT_STATFILE, self.output_stat).start() else: exit()