def read_peers_file(self): try: with util.open_file(PEERS_FILE, create=True) as f: data = f.read(-1).decode() except Exception as e: self.logger.error('error reading peers file {}'.format(e)) else: if data: version, items = ast.literal_eval(data) if version == 1: peers = [Peer.deserialize(item) for item in items] self.add_peers(peers, source='peers file', limit=None)
def read_peers_file(self): try: with util.open_file(PEERS_FILE, create=True) as f: data = f.read(-1).decode() except Exception as e: self.logger.error('error reading peers file {}'.format(e)) else: if data: version, items = ast.literal_eval(data) if version == 1: peers = [] for item in items: if 'last_connect' in item: item['last_good'] = item.pop('last_connect') try: peers.append(Peer.deserialize(item)) except Exception: pass self.add_peers(peers, source='peers file', limit=None)