3
�[g D � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddlm
Z
ddlmZ ddlmZ ddlm
Z
dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ e
�rNddlZddlZddlm Z d,dd�Z!dd� Z"dd� Z#dd� Z$d d!� Z%d"d#� Z&ej'j(e
d$d%�G d&d'� d'e��Z)ej'j(e
d$d%�G d(d)� d)e��Z*ej'j(e
d$d%�G d*d+� d+e��Z+dS )-zPOSIX specific tests.� N)�AIX)�BSD)�LINUX)�MACOS)�OPENBSD)�POSIX)�SUNOS)�AARCH64)�HAS_NET_IO_COUNTERS)�
PYTHON_EXE)� QEMU_USER)�PsutilTestCase)�mock)�pytest)�retry_on_failure)�sh)�skip_on_access_denied)�spawn_testproc)� terminate)�which)�getpagesizec C s� dg}t r|jd� |dk r0|jdt|�g� nts8trD|jd� n
|jd� tr^| jdd�} |jd | g� t|�}t r�|j� n|j� d
d� }g }x@|D ]8}|j � }yt
|�}W n tk
r� Y nX |j|� q�W |dkr�|S |d S dS )zwWrapper for calling the ps command with a little bit of cross-platform
support for a narrow range of features.
�psz--no-headersNz-pz-AZax�startZstimez-o� r )r �append�extend�strr r �replacer �
splitlines�strip�int�
ValueError)�fmt�pid�cmd�outputZ
all_output�line� r' |