Viewing File: /opt/alt/python35/lib64/python3.5/site-packages/psutil/__pycache__/_psposix.cpython-35.pyc



Cs[@sdZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
mZdd	l
mZd
ddd
gZdd
ZddddZddZedd
ZdS)z%Routines common to all posix systems.N)memoize)
sdiskusage)
usage_percent)PY3)unicode)TimeoutExpired
pid_existswait_pid
disk_usageget_terminal_mapcCs|dkrdSytj|dWnWtk
r}}z7|jtjkrOdS|jtjkredS|WYdd}~XnXdSdS)z6Check whether pid exists in the current process table.rTFN)oskillOSErrorerrnoZESRCHEPERM)piderrr/_psposix.pyr	sc	sfdd}ttdtjdk	rafdd}nfdd}d}xy|\}}Wntk
r}zg|jtjkr||}w|n>|jtjkrx)tr||}qdSqWnWYdd}~Xq|X|d	kr4||}q|tj|rQtj	|Stj
|rmtj|Std
|q|WdS)aIWait 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.
    csQdk	r3kr3tddtj|t|ddS)Nrnameg{Gz?)rtimesleepmin)delay)r	proc_namestop_attimeouttimerrr
check_timeout?s

zwait_pid.<locals>.check_timeout	monotonicNcstjtjS)N)r
waitpidWNOHANGr)rrrwaitcallHszwait_pid.<locals>.waitcallcstjdS)Nr)r
r"r)rrrr$Lsg-C6?rzunknown process exit status %r)
getattrrrrZEINTRZECHILDr	r
WIFSIGNALEDWTERMSIG	WIFEXITEDWEXITSTATUS
ValueError)	rrrr r$rZretpidstatusrr)rrrrrrr
4s8
cCs
trtj|}nzytj|}Wndtk
rt|try|jtj}Wntk
rwYnXtj|}nYnX|j	|j
}|j|j
}|j|j
}||}||}t
||dd}td|d|d|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.
    Zround_rtotalusedfreeZpercent)rr
statvfsUnicodeEncodeError
isinstancerencodesysgetfilesystemencodingf_blocksf_frsizef_bfreef_bavailrr)pathstr,Z
avail_to_rootZ
avail_to_userr-Z
total_userZusage_percent_userrrrrws(



cCsi}tjdtjd}x}|D]u}||ksGt|y||tj|j<Wq)tk
r}z|jtjkrWYdd}~Xq)Xq)W|S)zMGet a map of device-id -> path as a dict.
    Used by Process.terminal()
    z	/dev/tty*z
/dev/pts/*N)globAssertionErrorr
statst_rdevrrENOENT)ZretZlsrrrrrrs
)__doc__rr;r
r3rZ_commonrrrZ_compatrr_exceptionsr__all__r	r
rrrrrr<module>s C1
Back to Directory File Manager