ó FRTc@s´ddlZddlmZddlmZddlmZmZmZddl m Z ddl m Z m Z ddlZd ZdeZd eZdZd efd „ƒYZdS(iÿÿÿÿN(tUploadArchiveError(tJob(tcompute_hashes_from_fileobjtresume_file_uploadtWriter(tConcurrentUploader(tminimum_part_sizetDEFAULT_PART_SIZEii'itVaultcBs eZeZdeZd d!d"d#d$d%fZdd„Zd„Z d„Z dd„Z d„Z edd„Z ddddd„Zed„ƒZddd„Zd„Zddd„Zddddddd„Zd„Zd„Zd„Zddd„Zd„ZRS(&idt VaultNametnametVaultARNtarnt CreationDatet creation_datetLastInventoryDatetlast_inventory_datet SizeInBytestsizeitNumberOfArchivestnumber_of_archivescCsz||_|rIxd|jD])\}}}||}t|||ƒqWn-x*|jD]\}}}t|||ƒqSWdS(N(tlayer1tResponseDataElementstsetattr(tselfRt response_datat response_namet attr_nametdefaulttvalue((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pyt__init__5s  cCs d|jS(Ns Vault("%s")(R (R((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pyt__repr__?scCs|jj|jƒdS(s/ Delete's this vault. WARNING! N(Rt delete_vaultR (R((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pytdeleteBscCs>tjj|ƒ|jkr.|j|d|ƒS|j||ƒS(sr Adds an archive to a vault. For archives greater than 100MB the multipart upload will be used. :type file: str :param file: A filename to upload :type description: str :param description: An optional description for the archive. :rtype: str :return: The archive id of the newly created archive t description(tostpathtgetsizetSingleOperationThresholdtcreate_archive_from_filet _upload_archive_single_operation(RtfilenameR"((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pytupload_archiveHsc Cs`t|dƒG}t|ƒ\}}|jdƒ|jj|j||||ƒ}WdQX|dS(si Adds an archive to a vault in a single operation. It's recommended for archives less than 100MB :type file: str :param file: A filename to upload :type description: str :param description: A description for the archive. :rtype: str :return: The archive id of the newly created archive trbiNt ArchiveId(topenRtseekRR*R (RR)R"tfileobjt linear_hasht tree_hashtresponse((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pyR(Zs cCs2|jj|j||ƒ}t||dd|ƒS(s­ Create a new archive and begin a multi-part upload to it. Returns a file-like object to which the data for the archive can be written. Once all the data is written the file-like object should be closed, you can then call the get_archive_id method on it to get the ID of the created archive. :type part_size: int :param part_size: The part size for the multipart upload. :type description: str :param description: An optional description for the archive. :rtype: :class:`boto.glacier.writer.Writer` :return: A Writer object that to which the archive data should be written. tUploadIdt part_size(Rtinitiate_multipart_uploadR R(RR4R"R2((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pytcreate_archive_writerps c CsÛ|j}|sftjj|ƒ}yt||ƒ}Wntk rStdƒ‚nXt|dƒ}n|jd|d|ƒ}|r”||j ƒnx0t rÆ|j |ƒ}|s¶Pn|j |ƒq—W|j ƒ|jƒS(s Create a new archive and upload the data from the given file or file-like object. :type filename: str :param filename: A filename to upload :type file_obj: file :param file_obj: A file-like object to upload :type description: str :param description: An optional description for the archive. :type upload_id_callback: function :param upload_id_callback: if set, call with the upload_id as the only parameter when it becomes known, to enable future calls to resume_archive_from_file in case resume is needed. :rtype: str :return: The archive id of the newly created archive sAFile size of %s bytes exceeds 40,000 GB archive limit of Glacier.R+R"R4(tDefaultPartSizeR#R$R%Rt ValueErrorRR-R6t upload_idtTruetreadtwritetclosetget_archive_id( RR)tfile_objR"tupload_id_callbackR4t file_sizetwritertdata((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pyR'ˆs(      cCsªg|jdƒD]}t|ƒ^q\}}|d}||}||dkrs|d8}|d8}|d8}n|| sŠtdƒ‚||ks¢tdƒ‚||S(Nt-is0upload part start byte is not on a part boundarys$upload part is bigger than part size(tsplittinttAssertionError(t range_stringR4Rtstartt inside_endtendtlength((s?/opt/freeware/lib/python2.7/site-packages/boto/glacier/vault.pyt_range_string_to_part_indexµs.      c Cs˜|j|ƒ}|d}i}xH|dD]<}|j|d|ƒ}tj|ddƒ} | ||s