ó FRTc@söddlZddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddl m Z ddl m Z ddlmZddlmZdefd „ƒYZed „Zd efd „ƒYZdS( i’’’’N(tconfigtstorage_uri_for_key(tAWSAuthConnection(tResumableDownloadException(tResumableTransferDisposition(tKeyFile(tKeytByteTranslatingCallbackHandlercBs eZdZd„Zd„ZRS(s” Proxy class that translates progress callbacks made by boto.s3.Key.get_file(), taking into account that we're resuming a download. cCs||_||_dS(N(t proxied_cbtdownload_start_point(tselfRR ((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyt__init__?s cCs|j|j||ƒdS(N(RR (R ttotal_bytes_uploadedt total_size((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pytcallCs(t__name__t __module__t__doc__R R(((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyR9s cCswt|tƒr#| r#|jƒjS|s8|jƒ}n|jdtjƒ|jƒ}|ss|j|tjƒn|S(sH Returns size of file, optionally leaving fp positioned at EOF. i( t isinstanceRtgetkeytsizettelltseektostSEEK_ENDtSEEK_SET(tfptposition_to_eoftcur_post cur_file_size((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pytget_cur_file_sizeHs  tResumableDownloadHandlercBszeZdZdZejeejej fZ d d d„Z d„Z d„Zd„Zd„Zd ded d d„ZRS( s* Handler for resumable downloads. icCs;||_||_d|_|r.|jƒnd|_dS(s Constructor. Instantiate once for each downloaded file. :type tracker_file_name: string :param tracker_file_name: optional file name to save tracking info about this download. If supplied and the current process fails the download, it can be retried in a new process. If called with an existing file containing an unexpired timestamp, we'll resume the transfer for this file; else we'll start a new resumable download. :type num_retries: int :param num_retries: the number of times we'll re-try a resumable download making no progress. (Count resets every time we get progress, so download can span many more than this number of retries.) N(ttracker_file_namet num_retriestNonetetag_value_for_current_downloadt_load_tracker_file_etagR (R R R!((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyR bs     cCsŗd}z™yUt|jdƒ}|jƒjdƒ|_t|jƒ|jkr]d|jGHnWn=tk r}|j t j kržd|j|j fGHqžnXWd|rµ|j ƒnXdS(Ntrs sJCouldn't read etag in tracker file (%s). Restarting download from scratch.sJCouldn't read URI tracker file (%s): %s. Restarting download from scratch.( R"topenR treadlinetrstripR#tlent MIN_ETAG_LENtIOErrorterrnotENOENTtstrerrortclose(R tfte((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyR$~scCs©|jjdƒ|_|js"dSd}zfy*t|jdƒ}|jd|jƒWn5tk rŒ}td|j|j ft j ƒ‚nXWd|r¤|j ƒnXdS(Ns"'tws%s s·Couldn't write tracker file (%s): %s. This can happenif you're using an incorrectly configured download tool (e.g., gsutil configured to save tracker files to an unwritable directory)( tetagtstripR#R R"R&twriteR+RR.RtABORTR/(R tkeyR0R1((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyt_save_tracker_info–s cCs5|jr1tjj|jƒr1tj|jƒndS(N(R Rtpathtexiststunlink(R ((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyt_remove_tracker_fileŖs c Cs¾t|dtƒ} | r|jr|j|jjdƒkr| |jkr‚td|j| tt |ƒƒ|jft j ƒ‚n0| |jkr²|j j jdkr®dGHndS|j j jdkrĻdGHn|jƒ}d| |jdf|d R?s4Caught non-retryable ResumableDownloadException (%s)sXCaught non-retryable ResumableDownloadException (%s); aborting and removing tracker files3Caught ResumableDownloadException (%s) - will retryseToo many resumable download attempts failed without progress. You might try this download again laterisWGot retryable failure (%d progress-less in a row). Sleeping %d seconds before re-trying(RCRDRER!R"RtgetintR@RRPR<tRETRYABLE_EXCEPTIONSt__repr__RR+R,tEPIPERHRIRt dispositionRtABORT_CUR_PROCESStmessageR6R/thttplibtIncompleteReadttimetsleep(R R7RRKRLRMRNROR?REtprogress_less_iterationsthad_file_bytes_before_attemptR1tsleep_time_secs((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyRIßsr*       !             N(RRRR*RYt HTTPExceptionR+tsocketterrortgaierrorRSR"R R$R8R<RPtFalseRI(((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyRXs     0 (R,RYRtreRaR[tbotoRRtboto.connectionRtboto.exceptionRRtboto.s3.keyfileRt boto.gs.keyRRHtobjectRRdRR(((sO/opt/freeware/lib/python2.7/site-packages/boto/s3/resumable_download_handler.pyts