ó FRTc@sXddlZddlZddlmZmZddlmZdefd„ƒYZdS(i˙˙˙˙N(tTreeHashDoesNotMatchErrortDownloadArchiveError(ttree_hash_from_strtJobcBsĥeZd(Zd*d+d,d d efd-d.d/d0d1d2d3d4d5d6fZd)d„Zd „Zd)ed!„Zd"„Z ee e j fd#„Z ee e j fd$„Zd%„Zd&„ZRS(7iitActiontactiont ArchiveIdt archive_idtArchiveSizeInBytest archive_sizeit Completedt completedtCompletionDatetcompletion_datet CreationDatet creation_datetInventorySizeInBytestinventory_sizetJobDescriptiont descriptiontJobIdtidtSHA256TreeHashtsha256_treehashtSNSTopict sns_topict StatusCodet status_codet StatusMessagetstatus_messagetVaultARNtarncCst||_|rCx^|jD]#\}}}t||||ƒqWn-x*|jD]\}}}t|||ƒqMWdS(N(tvaulttResponseDataElementstsetattr(tselfR t response_datat response_namet attr_nametdefault((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyt__init__2s  cCs d|jS(NsJob(%s)(R(R#((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyt__repr__;scCs…|jjj|jj|j|ƒ}|rd|kr|jƒ}t|ƒ}|d|krtd||d|fƒ‚qn|S(s& 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. tTreeHashsZThe calculated tree hash %s does not match the expected tree hash %s for the byte range %s(R tlayer1tget_job_outputtnameRtreadRR(R#t byte_rangetvalidate_checksumtresponsetdatatactual_tree_hash((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyt get_output>s   cCs ttj|jt|ƒƒƒS(N(tinttmathtceilR tfloat(R#t chunk_size((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyt_calc_num_chunksdsc CsD|j|ƒ}t|dƒ }|j|||||ƒWdQXdS(sĈDownload an archive to a file by name. :type filename: str :param filename: The name of the file where the archive contents will be saved. :type chunk_size: int :param chunk_size: The chunk size to use when downloading the archive. :type verify_hashes: bool :param verify_hashes: Indicates whether or not to verify the tree hashes for each downloaded chunk. twbN(R:topent_download_to_fileob(R#tfilenameR9t verify_hashestretry_exceptionst num_chunkst output_file((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pytdownload_to_filegscCs,|j|ƒ}|j|||||ƒdS(sÇDownload an archive to a file object. :type output_file: file :param output_file: The file object where the archive contents will be saved. :type chunk_size: int :param chunk_size: The chunk size to use when downloading the archive. :type verify_hashes: bool :param verify_hashes: Indicates whether or not to verify the tree hashes for each downloaded chunk. N(R:R=(R#RBR9R?R@RA((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pytdownload_to_fileobj}sc Cs™x’t|ƒD]„}|||d|df}|j||ƒ\}} |r„t|ƒ} | | kr„td| | |fƒ‚q„n|j|ƒq WdS(NisZThe calculated tree hash %s does not match the expected tree hash %s for the byte range %s(tranget_download_byte_rangeRRtwrite( R#tfileobjRAR9R?R@tiR/R2texpected_tree_hashR3((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyR=“s  cCs}xvtdƒD]R}y3|j|ƒ}|jƒ}|d}||fSWq |k r^}q q Xq Wtd||fƒ‚dS(NiR*s/There was an error downloadingbyte range %s: %s(RER4R.R(R#R/R@t_R1R2RJte((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyRF˘s   ii@N(RsactionN(RRN(Rs archive_sizei(R R N(RRN(RRi(Rs descriptionN(RsidN(RRN(RRN(s StatusCodeRN(RRN(RsarnN(t__name__t __module__tDefaultPartSizetNonetFalseR!R(R)R4R:tTruetsocketterrorRCRDR=RF(((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyRs4   &  ( R6RStboto.glacier.exceptionsRRtboto.glacier.utilsRtobjectR(((s=/opt/freeware/lib/python2.7/site-packages/boto/glacier/job.pyts