def download(self, doc_type, prev_hash=None): """ Download <doc_type> from this authority. Can raise exceptions if authority not available. :return: Consensus text """ # doc_type: consensus, consensus-microdesc, authority? headers = {'X-Or-Diff-From-Consensus': prev_hash} if prev_hash else None return http_get('{}/{}'.format(self.status_url, doc_type), headers=headers)
def get_descriptor_for(self, fingerprint): """ Get another router descriptor through this one. :param fingerprint: :return: Descriptor object """ logger.debug('Getting descriptor for %s from %s', fingerprint, self) url = self.descriptor_url(fingerprint) try: response = http_get(url) except (ConnectionError, socket.timeout, HTTPError, URLError) as e: logger.debug(e) raise FetchDescriptorError("Can't fetch descriptor from %s" % url) descriptor_info = RouterDescriptorParser.parse(response) return Descriptor(**descriptor_info)
def download_fp_sk(self, identity, keyid): # TODO: multiple key download return http_get('{}/{}-{}'.format(self.fp_sk_url, identity, keyid))