Viewing File: /usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyo

ó
¡ôXc@sàddlZddlZddlZddlmZddlmZddlm	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZdee	efd„ƒYZdS(
iÿÿÿÿN(tArg(t
ArgumentError(tFileTransferProgressBarMixin(topen_pipe_fileobjs(twaitpid_in_thread(tDownloadBundle(tBundleDownloadingMixin(tUnbundleStream(t	S3RequesttDownloadAndUnbundlecBsweZdZedddddddddd	ƒed
dddƒgZd
„Zd„Zd„Zd„Zd„Z	RS(sŽDownload and unbundle a bundled image from the cloud

 The key used to unbundle the image must match a certificate that was used to bundle it.s-ds
--destinationtdesttmetavars(FILE | DIR)tdefaultt.thelpsOwhere to place the unbundled image
                (default: current directory)s-ks--privatekeys˜file containing the private key to decrypt the bundle
                with.  This must match a certificate used when bundling the
                image.cCsZtj|ƒ|jjdƒs |jjdƒ}|jjdƒrS||jd<q dtjkr{tjdƒ|jd<q |r‘||jd<q t	dƒ‚ntj
jtj
j|jdƒƒ|jd<tj
j
|jdƒst	dj|jdƒƒ‚ntj
j|jdƒs<t	dj|jdƒƒ‚n|jjd|jdƒdS(	Nt
privatekeysprivate-keyt
userregiontEC2_PRIVATE_KEYs.missing private key; please supply one with -ks%private key file '{0}' does not exists$private key file '{0}' is not a filesprivate key: %s(Rt	configuretargstgettconfigtget_user_optiontostenvirontgetenvRtpatht
expandusert
expandvarstexiststformattisfiletlogtdebug(tselftconfig_privatekey((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyR9s(
		cCs²|jddkr3tj|jd<t|jd<n{t|jdtjƒr®tjj	|jdƒr‡tjj
|jd|jƒ}n
|jd}t|dƒ|jd<|SdS(NR
t-t
show_progresstw(
RtsyststdouttFalset
isinstancetsixtstring_typesRRtisdirtjoint
image_nametopen(R"tmanifesttimage_filename((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyt__open_destSs
cCsÅ|j|jd|jdƒ}tƒ\}}z|j|ƒWd|jƒX|j|ƒ}tj|d|d|jdd|j	d|j
d|jd|jd	|jj
d	tƒƒ}|jƒ|S(
Ntprivkey_filenameRtsourceR
tenc_keytenc_ivt
image_sizetsha1_digestR%(tfetch_manifesttserviceRRt._DownloadAndUnbundle__create_download_pipelinetcloset_DownloadAndUnbundle__open_destRt
from_otherR6R7R8timage_digestRR)tmain(R"R1tdownload_out_rtdownload_out_wR2tunbundlestream((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyRAas
cCs†tj|d|d|jdd|jjdƒd|jjdƒdtƒ}tjd|jƒ}|jƒt	|j
ƒ|jƒdS(NR
tbucketR1tlocal_manifestR%ttarget(RR?RRR)tmultiprocessingtProcessRAtstartRtpidR=(R"toutfiletdownloadbundletdownloadbundle_p((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyt__create_download_pipeliners	

cCs8|r4|jdjƒtjjƒkr4dG|GHndS(NR
tWrote(RtfilenoR'R((R"R2((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pytprint_result}s"(
t__name__t
__module__tDESCRIPTIONRtARGSRR>RAR<RR(((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyR	+s				(RHtos.pathRR'trequestbuilderRtrequestbuilder.exceptionsRtrequestbuilder.mixinsRR+teuca2ools.bundle.utilRRt(euca2ools.commands.bundle.downloadbundleRt euca2ools.commands.bundle.mixinsRt(euca2ools.commands.bundle.unbundlestreamRteuca2ools.commands.s3RR	(((sQ/usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyt<module>s	
Back to Directory File Manager