Current File : //usr/lib/python2.7/site-packages/euca2ools/commands/bundle/downloadandunbundle.pyc
�
��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