Viewing File: /usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pyc

ó
¡ôXc@s¤ddlZddlZddlZddlZddlZddlZddlmZed„Z	ed„Z
dd„Zed„Z
ed„Zed„ZdS(	iÿÿÿÿN(t
close_all_fdsc
Cs)g}tjjjƒ\}}tjdtd|||fdi|d6ƒ}	|	jƒ|j|	j	ƒ|j
ƒ|j
ƒtjjjƒ\}
}tjdtƒ\}}
tjdt
di|d6d|||
fƒ}|jƒ|j|j	ƒ|j
ƒ|j
ƒ|
j
ƒy4tjddgd|
d	tjd
tddƒ}WnAtk
r‡tjd
dgd|
d	tjd
tddƒ}nX|
j
ƒ|j|j	ƒtjddddd|d|gd|jd	|d
tddƒ}|jj
ƒ|j|j	ƒx!|D]}tjjj|ƒqW|S(Nttargettargstkwargstdebugtduplextpigzs-ctstdintstdoutt	close_fdstbufsizeiÿÿÿÿtgziptopenssltencs-es-aes-128-cbcs-Ks-iv(t	euca2oolstbundletutiltopen_pipe_fileobjstmultiprocessingtProcesst_create_tarball_from_streamtstarttappendtpidtclosetPipetFalset_calc_sha1_for_pipet
subprocesstPopentPIPEtTruetOSErrorRtwaitpid_in_thread(tinfiletoutfiletenc_keytenc_ivttarinfoRtpidst	tar_out_rt	tar_out_wttar_ptdigest_out_rtdigest_out_wtdigest_result_rtdigest_result_wtdigest_pRRR((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pytcreate_bundle_pipeline$sL


	









c
Csg}tjddddd|d|gd|dtjd	td
dƒ}|j|jƒ|jƒy:tjdd
dgd|jdtjd	td
dƒ}WnGtk
råtjdd
dgd|jdtjd	td
dƒ}nX|j|jƒ|jjƒt	j
jjƒ\}}	t
jdtƒ\}
}t
jdtdi|d6d|j|	|fƒ}|jƒ|j|jƒ|jjƒ|	jƒ|jƒt
jdtd||fdi|d6ƒ}
|
jƒ|jƒ|j|
jƒx!|D]}t	j
jj|ƒqõW|
S(s˜
    Create a pipeline to perform the unbundle operation on infile input.
    The resulting unbundled image will be written to 'outfile'.

    :param outfile: file  obj to write unbundled image to
    :param enc_key: the encryption key used to bundle the image
    :param enc_iv: the encyrption initialization vector used in the bundle
    :returns multiprocess pipe to read sha1 digest of written image
    RR
s-ds-aes-128-cbcs-Ks-ivRRR	R
iÿÿÿÿRs-cRRRRRR(RRRRRRRRR RRRRRRRRRRt_extract_from_tarball_streamR!(R"R#R$R%RR'RRR+R,R-R.R/R*R((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pytcreate_unbundle_pipelineZsH





	



	


cCs«d}|r|jƒnzmxf|js„|jtjƒ}|r€|j|ƒ|jƒ|t|ƒ7}|r|j|ƒqqPqWWd|rœ|j	ƒn|j
ƒX|S(sÞ
    Synchronously copy data from infile to outfile, updating a progress bar
    with the total number of bytes copied along the way if one was provided,
    and return the number of bytes copied.

    This method must be run on the main thread.

    :param infile: file obj to read input from
    :param outfile: file obj to write output to
    :param progressbar: progressbar object to update with i/o information
    :param maxbytes: Int maximum number of bytes to write
    iN(RtclosedtreadRtBUFSIZEtwritetflushtlentupdatetfinishR(R"R#tprogressbart
bytes_writtentchunk((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pytcopy_with_progressbar–s"



	
cCsÎt|||gƒtjƒ}z‰ydxJtrq|jtjƒ}|rm|j|ƒ|j|ƒ|j	ƒq(Pq(W|j
|jƒƒWntk
r¦|s dS‚nXWd|j
ƒ|j
ƒ|j
ƒXdS(s¨
    Read data from infile and write it to outfile, calculating a running SHA1
    digest along the way.  When infile hits end-of-file, send the digest in
    hex form to result_mpconn and exit.
    :param infile: file obj providing input for digest
    :param outfile: file obj destination for writing output
    :param digest_out_pipe_w: fileobj to write digest to
    :param debug: boolean used in exception handling
    N(Rthashlibtsha1RR4RR5R9R6R7tsendt	hexdigesttIOErrorR(R"R#tdigest_out_pipe_wRtdigestR=((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pyR¹s&
	





cCs–td||gƒtjddd|dtjƒ}z<y|j|d|ƒWntk
rn|shdS‚nXWd|jƒ|jƒ|jƒXdS(Nt
except_fdstmodesw|tfileobjR
(RttarfiletopenRR5taddfileRCR(R"R#R&Rttarball((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pyRÚs


cCsœt||gƒtjddd|ƒ}zNy)t|ƒ}tj|j|ƒ|ƒWntk
rt|sndS‚nXWd|jƒ|jƒ|jƒXdS(sÝ
    Perform tar extract on infile and write to outfile
    :param infile: file obj providing input for tar
    :param outfile: file obj destination for tar output
    :param debug: boolean used in exception handling
    RGsr|RHN(	RRIRJtnexttshutiltcopyfileobjtextractfileRCR(R"R#RRLR&((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pyR1ës


(R?RRNRRIteuca2ools.bundle.utilRRRR0R2tNoneR>RRR1(((s?/usr/lib/python2.7/site-packages/euca2ools/bundle/pipes/core.pyt<module>s5<#!
Back to Directory File Manager