コード例 #1
0
ファイル: job.py プロジェクト: Rome84/AWS-BOTO1
 def _download_to_fileob(self, fileobj, num_chunks, chunk_size,
                         verify_hashes, retry_exceptions):
     for i in range(num_chunks):
         byte_range = ((i * chunk_size), ((i + 1) * chunk_size) - 1)
         data, expected_tree_hash = self._download_byte_range(
             byte_range, retry_exceptions)
         if verify_hashes:
             actual_tree_hash = tree_hash_from_str(data)
             if expected_tree_hash != actual_tree_hash:
                 raise TreeHashDoesNotMatchError(
                     "The calculated tree hash %s does not match the "
                     "expected tree hash %s for the byte range %s" %
                     (actual_tree_hash, expected_tree_hash, byte_range))
         fileobj.write(data)
コード例 #2
0
ファイル: job.py プロジェクト: 10sr/hue
 def _download_to_fileob(self, fileobj, num_chunks, chunk_size, verify_hashes,
                         retry_exceptions):
     for i in range(num_chunks):
         byte_range = ((i * chunk_size), ((i + 1) * chunk_size) - 1)
         data, expected_tree_hash = self._download_byte_range(
             byte_range, retry_exceptions)
         if verify_hashes:
             actual_tree_hash = tree_hash_from_str(data)
             if expected_tree_hash != actual_tree_hash:
                 raise TreeHashDoesNotMatchError(
                     "The calculated tree hash %s does not match the "
                     "expected tree hash %s for the byte range %s" % (
                         actual_tree_hash, expected_tree_hash, byte_range))
         fileobj.write(data)
コード例 #3
0
ファイル: job.py プロジェクト: 10sr/hue
    def get_output(self, byte_range=None, validate_checksum=False):
        """
        This operation downloads the output of the job.  Depending on
        the job type you specified when you initiated the job, the
        output will be either the content of an archive or a vault
        inventory.

        You can download all the job output or download a portion of
        the output by specifying a byte range. In the case of an
        archive retrieval job, depending on the byte range you
        specify, Amazon Glacier returns the checksum for the portion
        of the data. You can compute the checksum on the client and
        verify that the values match to ensure the portion you
        downloaded is the correct data.

        :type byte_range: tuple
        :param range: A tuple of integer specifying the slice (in bytes)
            of the archive you want to receive

        :type validate_checksum: bool
        :param validate_checksum: Specify whether or not to validate
            the associate tree hash.  If the response does not contain
            a TreeHash, then no checksum will be verified.

        """
        response = self.vault.layer1.get_job_output(self.vault.name,
                                                    self.id,
                                                    byte_range)
        if validate_checksum and 'TreeHash' in response:
            data = response.read()
            actual_tree_hash = tree_hash_from_str(data)
            if response['TreeHash'] != actual_tree_hash:
                raise TreeHashDoesNotMatchError(
                    "The calculated tree hash %s does not match the "
                    "expected tree hash %s for the byte range %s" % (
                        actual_tree_hash, response['TreeHash'], byte_range))
        return response
コード例 #4
0
ファイル: job.py プロジェクト: yang123vc/libui
    def get_output(self, byte_range=None, validate_checksum=False):
        """
        This operation downloads the output of the job.  Depending on
        the job type you specified when you initiated the job, the
        output will be either the content of an archive or a vault
        inventory.

        You can download all the job output or download a portion of
        the output by specifying a byte range. In the case of an
        archive retrieval job, depending on the byte range you
        specify, Amazon Glacier returns the checksum for the portion
        of the data. You can compute the checksum on the client and
        verify that the values match to ensure the portion you
        downloaded is the correct data.

        :type byte_range: tuple
        :param range: A tuple of integer specifying the slice (in bytes)
            of the archive you want to receive

        :type validate_checksum: bool
        :param validate_checksum: Specify whether or not to validate
            the associate tree hash.  If the response does not contain
            a TreeHash, then no checksum will be verified.

        """
        response = self.vault.layer1.get_job_output(self.vault.name,
                                                    self.id,
                                                    byte_range)
        if validate_checksum and 'TreeHash' in response:
            data = response.read()
            actual_tree_hash = tree_hash_from_str(data)
            if response['TreeHash'] != actual_tree_hash:
                raise TreeHashDoesNotMatchError(
                    "The calculated tree hash %s does not match the "
                    "expected tree hash %s for the byte range %s" % (
                        actual_tree_hash, response['TreeHash'], byte_range))
        return response