관리-도구
편집 파일: _psposix.cpython-36.opt-1.pyc
3 ��JZ� � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ddl mZ ddl mZ dd l mZ d ddd gZdd � Zddd�Zdd� Zedd � �ZdS )z%Routines common to all posix systems.� N� )�memoize)� sdiskusage)� usage_percent)�PY3)�unicode)�TimeoutExpired� pid_exists�wait_pid� disk_usage�get_terminal_mapc C sl | dkrdS yt j| d� W nF tk rb } z*|jtjkr>dS |jtjkrNdS |�W Y dd}~X nX dS dS )z6Check whether pid exists in the current process table.r TFN)�os�kill�OSError�errnoZESRCHZEPERM)�pid�err� r � /usr/lib64/python3.6/_psposix.pyr s c s � ����fdd�}t tdtj���dk rB� fdd�}�� � �n� fdd�}d}x�y|� \}}W nf tk r� } zJ|jtjkr�||�}wTn,|jtjkr�xt� �r�||�}q�dS q�W n� W Y dd}~X qTX |d kr�||�}qTtj|�r�tj |� S tj |��rtj|�S td | ��qTW dS )aI Wait for process with pid 'pid' to terminate and return its exit status code as an integer. If pid is not a children of os.getpid() (current process) just waits until the process disappears and return None. If pid does not exist at all return None immediately. Raise TimeoutExpired on timeout expired. c s8 �d k r �� �kr t �� �d��tj| � t| d d�S )N)r �name� g{�G�z�?)r �timeZsleep�min)�delay)r � proc_name�stop_at�timeout�timerr r � check_timeout? s zwait_pid.<locals>.check_timeoutZ monotonicNc s t j� t j�S )N)r �waitpid�WNOHANGr )r r r �waitcallH s zwait_pid.<locals>.waitcallc s t j� d�S )Nr )r r r )r r r r! L s g-C��6?r zunknown process exit status %r) �getattrr r r ZEINTRZECHILDr r �WIFSIGNALED�WTERMSIG� WIFEXITED�WEXITSTATUS� ValueError) r r r r r! r ZretpidZstatusr r )r r r r r r r 4 s8 c C s� t rtj| �}ndytj| �}W nT tk rr t| t�rly| jtj� �} W n tk r^ Y nX tj| �}n� Y nX |j |j }|j|j }|j|j }|| }|| }t ||dd�}t||||d�S )a. Return disk usage associated with path. Note: UNIX usually reserves 5% disk space which is not accessible by user. In this function "total" and "used" values reflect the total and used disk space whereas "free" and "percent" represent the "free" and "used percent" user disk space. r )Z_round)�total�usedZfreeZpercent)r r �statvfs�UnicodeEncodeError� isinstancer �encode�sys�getfilesystemencoding�f_blocks�f_frsize�f_bfree�f_bavailr r )�path�str( Z avail_to_rootZ avail_to_userr) Z total_userZusage_percent_userr r r r w s( c C sp i } t j d�t j d� }xR|D ]J}y|| tj|�j<