Example #1
0
 def call(self, current_progress_byte, total_size_unused):
     """Forcibly exits if the passed the halting point since the last call."""
     if (self._last_progress_byte is not None and self._last_progress_byte <
             self._halt_at_byte < current_progress_byte):
         sys.stderr.write('Halting transfer.\r\n')
         raise ResumableDownloadException('Artifically halting download.')
     self._last_progress_byte = current_progress_byte
Example #2
0
 def call(self, total_bytes_transferred, total_size):
   """Forcibly exits if the transfer has passed the halting point."""
   if total_bytes_transferred >= self._halt_at_byte:
     sys.stderr.write(
         'Halting transfer after byte %s. %s/%s transferred.\r\n' % (
             self._halt_at_byte, MakeHumanReadable(total_bytes_transferred),
             MakeHumanReadable(total_size)))
     if self._is_upload:
       raise ResumableUploadException('Artifically halting upload.')
     else:
       raise ResumableDownloadException('Artifically halting download.')
Example #3
0
    def call(self, total_bytes_transferred, total_size):
        """Forcibly exits if the transfer has passed the halting point.

    Note that this function is only called when the conditions in
    gslib.progress_callback.ProgressCallbackWithTimeout.Progress are met, so
    self._halt_at_byte is only precise if it's divisible by
    gslib.progress_callback._START_BYTES_PER_CALLBACK.
    """
        if total_bytes_transferred >= self._halt_at_byte:
            sys.stderr.write(
                'Halting transfer after byte %s. %s/%s transferred.\r\n' %
                (self._halt_at_byte,
                 MakeHumanReadable(total_bytes_transferred),
                 MakeHumanReadable(total_size)))
            if self._is_upload:
                raise ResumableUploadException('Artifically halting upload.')
            else:
                raise ResumableDownloadException(
                    'Artifically halting download.')