7ec@s.ddlZddlZddlZddlZddlZddlZddlZddlZddlZyddl Z Wne k rnXddl m Z dZ dZdZdZdZdZd Zejd Zd Zd Zdd ZddZdedZdS(iN(tstrip_python_stderrc Ostjg}|s"|jdn|j|tjj}|j|tj |dtj dtj dtj d|}z|j \}}Wdtj |j j|jjX|j}t|}|r|s| r | r td||jddfn|||fS( Ns-Etstdintstdouttstderrtenvs-Process return code is %d, stderr follows: %stasciitignore(tsyst executabletappendtextendtostenvirontcopytupdatet subprocesstPopentPIPEt communicatet_cleanupRtcloseRt returncodeRtAssertionErrortdecode( texpected_successtargstenv_varstcmd_lineRtptoutterrtrc((s2/usr/lib64/python2.7/test/support/script_helper.pyt_assert_pythons*        cOstt||S(s Assert that running the interpreter with `args` and optional environment variables `env_vars` is ok and return a (return code, stdout, stderr) tuple. (R tTrue(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_ok2scOstt||S(s Assert that running the interpreter with `args` and optional environment variables `env_vars` fails and return a (return code, stdout, stderr) tuple. (R tFalse(RR((s2/usr/lib64/python2.7/test/support/script_helper.pytassert_python_failure9sc GsWtjdg}|j|ttjd#}tj|d|dtjSWdQXdS(Ns-EtwRR( RRR topenR tdevnullRtcalltSTDOUT(RRR'((s2/usr/lib64/python2.7/test/support/script_helper.pytpython_exit_code@s  c OsGtjdg}|j|tj|dtjdtjdtj|S(Ns-ERRR(RRR RRRR)(RtkwargsR((s2/usr/lib64/python2.7/test/support/script_helper.pyt spawn_pythonGs  cCsA|jj|jj}|jj|jtj|S(N(RRRtreadtwaitRR(Rtdata((s2/usr/lib64/python2.7/test/support/script_helper.pyt kill_pythonNs     cOs.td||}t|}|j|fS(Ns-O(R,R0R.(RR+Rt stdout_data((s2/usr/lib64/python2.7/test/support/script_helper.pyt run_pythonXs ccs<tj}tjj|}z |VWdtj|XdS(N(ttempfiletmkdtempR tpathtrealpathtshutiltrmtree(tdirname((s2/usr/lib64/python2.7/test/support/script_helper.pyttemp_diras   cCsP|tjd}tjj||}t|d}|j||j|S(NtpyR%(R textsepR5tjoinR&twriteR(t script_dirtscript_basenametsourcetscript_filenamet script_namet script_file((s2/usr/lib64/python2.7/test/support/script_helper.pyt make_scriptjs   cCs!tj|dt|d}|S(Ntdoraiseto(t py_compiletcompileR!(RCt compiled_name((s2/usr/lib64/python2.7/test/support/script_helper.pytcompile_scriptrs cCs|tjd}tjj||}tj|d}|dkrYtjj|}n|j|||j |tjj||fS(NtzipR%( R R<R5R=tzipfiletZipFiletNonetbasenameR>R(tzip_dirt zip_basenameRCt name_in_zipt zip_filenametzip_nametzip_file((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_zip_scriptzs  tcCs!tj|t|d|dS(Nt__init__(R tmkdirRE(tpkg_dirt init_source((s2/usr/lib64/python2.7/test/support/script_helper.pytmake_pkgs icCsg}t|dd}|j|tjj|} t|||} |j| |rt|}t| } |j|| fngtd|dD]} tjj |g| ^q} tjj | dtjj| } |tj d}tjj ||}t j |d}x3| D]+}tjj || }|j ||q'W|j | | |jx|D]}tj|qwW|tjj || fS(NRYRXiiRLR%(RER R R5RPRKR trangetsepR=R<RMRNR>Rtunlink(RQRRtpkg_nameR@RAtdepthtcompiledR`t init_namet init_basenameRCtit pkg_namestscript_name_in_zipRTRURVtnametinit_name_in_zip((s2/usr/lib64/python2.7/test/support/script_helper.pyt make_zip_pkgs.    9%   (RR tretos.pathR3RRHt contextlibR7RMt ImportErrort test.supportRR R"R$R*R,R0R2tcontextmanagerR:RERKRORWR]R#Rk(((s2/usr/lib64/python2.7/test/support/script_helper.pyts4