# Path: gslib/exception.py
# class InvalidUrlError(Exception):
#   """Exception raised when URL is invalid."""
# 
#   def __init__(self, message):
#     Exception.__init__(self, message)
#     self.message = message
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'InvalidUrlError: %s' % self.message
# 
# Path: gslib/utils/boto_util.py
# def GetMaxRetryDelay():
#   return config.getint('Boto', 'max_retry_delay', 32)
# 
# Path: gslib/utils/boto_util.py
# def GetNumRetries():
#   return config.getint('Boto', 'num_retries', 23)


import errno
import random
import re
import socket
import time
import six
from six.moves import urllib
from six.moves import http_client
from boto import config
from boto import UserAgent
from boto.connection import AWSAuthConnection
from boto.exception import ResumableTransferDisposition
from boto.exception import ResumableUploadException
from gslib.exception import InvalidUrlError
from gslib.utils.boto_util import GetMaxRetryDelay
from gslib.utils.boto_util import GetNumRetries
from gslib.utils.constants import XML_PROGRESS_CALLBACKS
from gslib.utils.constants import UTF8
        self.logger.debug('Caught ResumableUploadException (%s) - will retry',
                          e.message)

  def TrackProgressLessIterations(self,
                                  service_had_bytes_before_attempt,
                                  debug=0):
    """Tracks the number of iterations without progress.

    Performs randomized exponential backoff.

    Args:
      service_had_bytes_before_attempt: Number of bytes the service had prior
                                       to this upload attempt.
      debug: debug level 0..3
    """
    # At this point we had a re-tryable failure; see if made progress.
    if self.service_has_bytes > service_had_bytes_before_attempt:
      self.progress_less_iterations = 0  # If progress, reset counter.
    else:
      self.progress_less_iterations += 1

    if self.progress_less_iterations > self.num_retries:
      # Don't retry any longer in the current process.
      raise ResumableUploadException(
          'Too many resumable upload attempts failed without '
          'progress. You might try this upload again later',
          ResumableTransferDisposition.ABORT_CUR_PROCESS)

    # Use binary exponential backoff to desynchronize client requests.
    sleep_time_secs = min(random.random() * (2**self.progress_less_iterations),

# Path: gslib/exception.py
# class InvalidUrlError(Exception):
#   """Exception raised when URL is invalid."""
# 
#   def __init__(self, message):
#     Exception.__init__(self, message)
#     self.message = message
# 
#   def __repr__(self):
#     return str(self)
# 
#   def __str__(self):
#     return 'InvalidUrlError: %s' % self.message
# 
# Path: gslib/utils/boto_util.py
# def GetMaxRetryDelay():
#   return config.getint('Boto', 'max_retry_delay', 32)
# 
# Path: gslib/utils/boto_util.py
# def GetNumRetries():
#   return config.getint('Boto', 'num_retries', 23)


# Path: gslib/boto_resumable_upload.py
import errno
import random
import re
import socket
import time
import six
from six.moves import urllib
from six.moves import http_client
from boto import config
from boto import UserAgent
from boto.connection import AWSAuthConnection
from boto.exception import ResumableTransferDisposition
from boto.exception import ResumableUploadException
from gslib.exception import InvalidUrlError
from gslib.utils.boto_util import GetMaxRetryDelay
from gslib.utils.boto_util import GetNumRetries
from gslib.utils.constants import XML_PROGRESS_CALLBACKS
from gslib.utils.constants import UTF8

        self.logger.debug('Caught ResumableUploadException (%s) - will retry',
                          e.message)

  def TrackProgressLessIterations(self,
                                  service_had_bytes_before_attempt,
                                  debug=0):
    """Tracks the number of iterations without progress.

    Performs randomized exponential backoff.

    Args:
      service_had_bytes_before_attempt: Number of bytes the service had prior
                                       to this upload attempt.
      debug: debug level 0..3
    """
    # At this point we had a re-tryable failure; see if made progress.
    if self.service_has_bytes > service_had_bytes_before_attempt:
      self.progress_less_iterations = 0  # If progress, reset counter.
    else:
      self.progress_less_iterations += 1

    if self.progress_less_iterations > self.num_retries:
      # Don't retry any longer in the current process.
      raise ResumableUploadException(
          'Too many resumable upload attempts failed without '
          'progress. You might try this upload again later',
          ResumableTransferDisposition.ABORT_CUR_PROCESS)

    # Use binary exponential backoff to desynchronize client requests.
    sleep_time_secs = min(random.random() * (2**self.progress_less_iterations),

                          GetMaxRetryDelay())