Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/utils/__pycache__/_process_common.cpython-39.pyc
Ðазад
a o�h[ � @ sl d Z ddlZddlZddlZddlZddlmZ dd� Zejfdd�Z dd � Z d d� Zdd � Zddd�Z dS )z�Common utilities for the various process_* implementations. This file is only meant to be imported by the platform-specific implementations of subprocess utilities, and it contains tools that are common to all of them. � N)� py3compatc C sJ ddl }z | �� W S tyD } z|j |jkr0� W Y d}~n d}~0 0 dS )z�Read from a pipe ignoring EINTR errors. This is necessary because when reading from pipes with GUI event loops running in the background, often interrupts are raised that stop the command from completing.r N)�errno�read�IOErrorZEINTR)�pr �err� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/utils/_process_common.py�read_no_interrupt s r c C sz t j�� t j�� t jdk}t| t�}d}|rNtjdkrNdtj v rNtj d }t j| ||t jt j||d�}z�z||�}W n2 t y� td� t j�� t j�� d}Y n0 W |jdu r�z|�� |�� W n ty� Y n0 |jdu �rvz|�� W n t�y Y n0 nf|jdu �rFz|�� |�� W n t�yD Y n0 |jdu �rtz|�� W n t�yr Y n0 0 |S )a� Open a command in a shell subprocess and execute a callback. This function provides common scaffolding for creating subprocess.Popen() calls. It creates a Popen object and then calls the callback with it. Parameters ---------- cmd : str or list A command to be executed by the system, using :class:`subprocess.Popen`. If a string is passed, it will be run in the system shell. If a list is passed, it will be used directly as arguments. callback : callable A one-argument function that will be called with the Popen object. stderr : file descriptor number, optional By default this is set to ``subprocess.PIPE``, but you can also pass the value ``subprocess.STDOUT`` to force the subprocess' stderr to go into the same file descriptor as its stdout. This is useful to read stdout and stderr combined in the order they are generated. Returns ------- The return value of the provided callback is returned. �win32N�posix�SHELL)�shell� executable�stdin�stdout�stderr� close_fdsz^C)�sysr �flushr �platform� isinstance�str�os�name�environ� subprocess�Popen�PIPE�KeyboardInterrupt�print� returncode� terminate�poll�OSError�kill)�cmd�callbackr r r r r �outr r r �process_handler+ sX � �r) c C s( t | dd� tj�}|du rdS t�|�S )a� Run a command and return its stdout/stderr as a string. Parameters ---------- cmd : str or list A command to be executed in the system shell. Returns ------- output : str A string containing the combination of stdout and stderr from the subprocess, in whatever order the subprocess originally wrote to its file descriptors (so the order of the information in this string is the correct order as would be seen if running the command in a terminal). c S s | � � d S )Nr ��communicate�r r r r �<lambda>� � zgetoutput.<locals>.<lambda>N� )r) r �STDOUTr �decode)r&