Edit File: script_helper.cpython-36.opt-2.pyc
3 48e�)������������������@���s���d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlmZ�d�dl mZmZ�dadd��ZG�dd��de�jdd#��Zdd��Zd d��Zdd��Zdd��Zejejd�dd�Zdd��Zd$dd�Zd%dd�Zd&dd�Zd'd!d"�ZdS�)(�����N)�source_from_cache)�make_legacy_pyc�strip_python_stderrc���������������C���sV���t�d�krRdtjkrda�dS�ytjtjdddg��W�n�tjk rL���da�Y�nX�da�t�S�)NZ PYTHONHOMETz-Ez-czimport sys; sys.exit(0)F)�$__cached_interp_requires_environment�os�environ� subprocessZ check_call�sys� executableZCalledProcessError��r���r����2/usr/lib64/python3.6/test/support/script_helper.py� interpreter_requires_environment���s���� r ���c���������������@���s���e�Zd�Zdd��ZdS�)�_PythonRunResultc�������������C���s����d}|�j�|�j�}}t|�|kr0d||�d����}t|�|krNd||�d����}|jdd�j��}|jdd�j��}td|�j|||f���d�S�) N�P����d���s���(... truncated stdout ...)s���(... truncated stderr ...)�ascii�replacezRProcess return code is %d command line: %r stdout: --- %s --- stderr: --- %s ---i@��)�out�err�len�decode�rstrip�AssertionError�rc)�self�cmd_line�maxlenr���r���r���r���r����fail>���s����z_PythonRunResult.failN)�__name__� __module__�__qualname__r���r���r���r���r���r���;���s���r���r���r���r���c�������� ������O���s��t���}d|kr|jd�}n|�o$|�}tjddg}|rB|jd��n|�rX|�rX|jd��|jdd��r�i�}tjdkr�tjd�|d<�n tjj��}d |kr�d |d <�|j |��|j |���tj|tj tj tj |d�}|�*�z|j��\}}W�d�|j���tj���X�W�d�Q�R�X�|j} t|�}t| ||�|fS�)NZ __isolatedz-XZfaulthandlerz-Iz-EZ __cleanenvZwin32Z SYSTEMROOT�TERM��)�stdin�stdout�stderr�env)r ����popr ���r ����append�platformr���r����copy�update�extendr����Popen�PIPEZcommunicate�kill�_cleanup� returncoder���r���) �args�env_varsZenv_required�isolatedr���r&����procr���r���r���r���r���r����run_python_until_end[���s:���� r6���c�������������O���s4���t�||�\}}|jr|�s&|j�r0|��r0|j|��|S�)N)r6���r���r���)Zexpected_successr2���r3����resr���r���r���r����_assert_python����s���� r8���c��������������O���s���t�d|��|�S�)NT)T)r8���)r2���r3���r���r���r����assert_python_ok����s����r9���c��������������O���s���t�d|��|�S�)NF)F)r8���)r2���r3���r���r���r����assert_python_failure����s����r:���)r$���r%���c�������������O���sX���t�jg}t��s|jd��|j|��|jdttj��}d|d<�t j |ft j|�|d�|��S�)Nz-Er&���Zvt100r!���)r#���r$���r%���)r ���r ���r ���r(���r,���� setdefault�dictr���r���r���r-���r.���)r$���r%���r2����kwr���r&���r���r���r����spawn_python����s���� r>���c�������������C���s2���|�j�j���|�jj��}|�jj���|�j���tj���|S�)N)r#����closer$����read�waitr���r0���)�p�datar���r���r����kill_python����s���� rD���Fc�������������C���sP���|}|s|t�jd�7�}t�jj|�|�}t|ddd�}|j|��|j���tj���|S�)N�py�wzutf-8)�encoding) r����extsep�path�join�open�writer?���� importlib�invalidate_caches)Z script_dir�script_basename�sourceZomit_suffixZscript_filename�script_nameZscript_filer���r���r����make_script����s���� rR���c������� ������C���s����|t�j�d�}t�jj|�|�}tj|d�}|d�kr~|jt�j�}t|�dkrr|d�dkrrt t |��}t�jj|�}|}nt�jj|�}|j||��|j ���|t�jj||�fS�)N�ziprF��������__pycache__���)r���rH���rI���rJ����zipfile�ZipFile�split�sepr���r���r����basenamerL���r?���) �zip_dir�zip_basenamerQ���Zname_in_zip�zip_filename�zip_name�zip_file�partsZ legacy_pycr���r���r����make_zip_script����s����rb���r"���c�������������C���s���t�j|���t|�d|��d�S�)N�__init__)r����mkdirrR���)Zpkg_dirZinit_sourcer���r���r����make_pkg����s���� re�������c����������������s0��g�}t�|�dd�}|j|��tjj|�} t�|�||�} |j| ��|rjtj|dd�}tj| dd�} |j|| f����fdd�td|d��D��}tjj |d �tjj| ��}|tj �d�} tjj |�| �}tj|d �}x&|D�]}tjj || �}|j ||��q�W�|j | |��|j���x|D�]}tj|���q W�|tjj ||�fS�)Nrc���r"���T)�doraisec����������������s���g�|�]}t�jj��g|���qS�r���)r���rZ���rJ���)�.0�i)�pkg_namer���r���� <listcomp>����s����z make_zip_pkg.<locals>.<listcomp>rf���rS���rF������)rR���r(���r���rI���r[���� py_compile�compiler,����rangerJ���rH���rW���rX���rL���r?����unlink)r\���r]���rj���rO���rP���ZdepthZcompiledrp���Z init_nameZ init_basenamerQ���Z pkg_namesZscript_name_in_zipr^���r_���r`����nameZinit_name_in_zipr���)rj���r����make_zip_pkg����s.���� rr���)r���r���r���)F)N)r"���)rf���F) �collectionsrM���r ���r���Zos.pathZtempfiler���rm���� contextlibZshutilrW����importlib.utilr���Ztest.supportr���r���r���r ���� namedtupler���r6���r8���r9���r:���r.���ZSTDOUTr>���rD���rR���rb���re���rr���r���r���r���r����<module>���s4���$3