fdutils/web/_utils.py
def stream_to_file_with_retry(chunk_size, local_file, partial_download, partial_download_max_retries, raw_response,
                              sess_response, sess, unzip_file_func):
    """ saves stream from response to file if a http exception we will try to do a partial download """
    partial_download_tries = total_chunks = 0
    while partial_download_tries < partial_download_max_retries:
        mode = 'wb' if not partial_download_tries else 'rb+'
        with open(local_file, mode) as f, unzip_file_func(raw_response) as zf, raw_response:
            if partial_download_tries:
                f.seek(total_chunks * chunk_size)
            chunks, exception = copyfileobj_counter(zf, f, chunk_size)
            if exception:
                if partial_download and (partial_download_tries + 1) < partial_download_max_retries:
                    total_chunks += chunks
                    total_bytes = total_chunks * chunk_size
                    log.debug('Retrying a partial download from byte {}'.format(total_bytes))
                    partial_download_tries += 1
                    sess_response = partial_download(sess, sess_response, total_bytes)
                    raw_response = sess_response.raw
                else:
                    raise exception
            else:
                break
 saves stream from response to file if a http exception we will try to do a partial download 
saves stream from response to file if a http exception we will try to do a partial download
saves stream from response to file if a http exception we will try to do a partial download
def stream_to_file_with_retry(chunk_size, local_file, partial_download, partial_download_max_retries, raw_response,
                              sess_response, sess, unzip_file_func):
    partial_download_tries = total_chunks = 0
    while partial_download_tries < partial_download_max_retries:
        mode = 'wb' if not partial_download_tries else 'rb+'
        with open(local_file, mode) as f, unzip_file_func(raw_response) as zf, raw_response:
            if partial_download_tries:
                f.seek(total_chunks * chunk_size)
            chunks, exception = copyfileobj_counter(zf, f, chunk_size)
            if exception:
                if partial_download and (partial_download_tries + 1) < partial_download_max_retries:
                    total_chunks += chunks
                    total_bytes = total_chunks * chunk_size
                    log.debug('Retrying a partial download from byte {}'.format(total_bytes))
                    partial_download_tries += 1
                    sess_response = partial_download(sess, sess_response, total_bytes)
                    raw_response = sess_response.raw
                else:
                    raise exception
            else:
                break
def stream_to_file_with_retry ( chunk_size , local_file , partial_download , partial_download_max_retries , raw_response , sess_response , sess , unzip_file_func ) : partial_download_tries = total_chunks = 0 while partial_download_tries < partial_download_max_retries : mode = 'wb' if not partial_download_tries else 'rb+' with open ( local_file , mode ) as f , unzip_file_func ( raw_response ) as zf , raw_response : if partial_download_tries : f . seek ( total_chunks * chunk_size ) chunks , exception = copyfileobj_counter ( zf , f , chunk_size ) if exception : if partial_download and ( partial_download_tries + 1 ) < partial_download_max_retries : total_chunks += chunks total_bytes = total_chunks * chunk_size log . debug ( 'Retrying a partial download from byte {}' . format ( total_bytes ) ) partial_download_tries += 1 sess_response = partial_download ( sess , sess_response , total_bytes ) raw_response = sess_response . raw else : raise exception else : break
saves stream from response to file if a http exception we will try to do a partial download
saves stream from response to file if a http exception we will try to do a partial download
""" saves stream from response to file if a http exception we will try to do a partial download """
chunk_size
local_file
partial_download
partial_download_max_retries
raw_response
sess_response
sess
unzip_file_func