o ckF[¥ã@s8ddlZddlmZddlZddlZGdd„deƒZdS)éN)Ú ScriptBasecsDeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Z‡Z S) ÚCopyBotcstt|ƒ ¡tj dd¡|_d|j|_t j   |j|j¡|_ t  |j|j ¡tj |jd¡|_tj |jd¡|_tj |jdd¡|_t ¡}| |j¡|_|jsZtj d|j¡tj |jd d¡}|rttj |jd d¡}t ||¡}| |j¡|_|js‡| |j¡|_dSdS) NÚPyamiÚ working_dirz%s.logÚ src_bucketÚ dst_bucketÚ replace_dstTz Source bucket does not exist: %sÚdest_aws_access_key_idÚdest_aws_secret_access_key)ÚsuperrÚ__init__ÚbotoÚconfigÚgetÚwdirÚ instance_idÚlog_fileÚosÚpathÚjoinÚlog_pathÚset_file_loggerÚnameÚsrc_nameÚdst_nameÚgetboolÚreplaceÚ connect_s3ÚlookupÚsrcÚlogÚerrorÚconnectÚdstÚ create_bucket)ÚselfÚs3Údest_access_keyÚdest_secret_key©Ú __class__©ú4/usr/lib/python3/dist-packages/boto/pyami/copybot.pyr s(  ÿzCopyBot.__init__cCs0tj |jdd¡r|j ¡}|j |¡dSdS©NÚ copy_aclsT)r rrrrÚ get_xml_aclr#Ú set_xml_acl)r%Úaclr+r+r,Úcopy_bucket_acl1s þzCopyBot.copy_bucket_aclcCs,tj |jdd¡r| ¡}| |¡dSdSr-)r rrrr/r0)r%rr#r1r+r+r,Ú copy_key_acl6sþzCopyBot.copy_key_aclcCstj d|jj¡tj d|jj¡z\|jD]U}|js4|j |j¡}|r4tj d|j|jjf¡qtj d|j|jf¡t j   |j¡\}}t j   |j |¡}| |¡|j |j¡}| |¡| ||¡t  |¡qWdStj d|j¡YdS)Nzsrc=%szdst=%sz%key=%s already exists in %s, skippingzcopying %d bytes from key=%szError copying key: %s)r r Úinforrr#rrÚsizerrÚsplitrrÚget_contents_to_filenameÚnew_keyÚset_contents_from_filenamer3ÚunlinkÚ exception)r%ÚkeyÚexistsÚprefixÚbaserr8r+r+r,Ú copy_keys;s(     ózCopyBot.copy_keyscCs|j |j¡}| |j¡dS)N)r#r8rr9r)r%r<r+r+r,Úcopy_logPszCopyBot.copy_logcCsšt ¡}tj |¡| d|j|jf| ¡¡|jr"|j r"|  ¡|j r)|  ¡| d|j|jfd¡tj  |jdd¡rKt  ¡}| |jg¡dSdS)Nz%s (%s) Startingz%s (%s) StoppingzCopy Operation CompleteÚexit_on_completionT)ÚStringIOr rÚ dump_safeÚnotifyrrÚgetvaluerr#r@rArÚ connect_ec2Úterminate_instances)r%ÚfpÚec2r+r+r,ÚmainTs  ÿþz CopyBot.main) Ú__name__Ú __module__Ú __qualname__r r2r3r@rArKÚ __classcell__r+r+r)r,rs r)r Úboto.pyami.scriptbaserrrCrr+r+r+r,Ús