????

Your IP : 3.15.190.254


Current Path : /lib/python3.6/site-packages/glances/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/__pycache__/secure.cpython-36.pyc

3

Eo�c�@s<dZddlmZddlmZmZddlZdd�Zdd�ZdS)	zSecures functions for Glances�)�	nativestr)�Popen�PIPENcCs(d}x|jd�D]}|t|�7}qW|S)z�A more or less secure way to execute system commands

    Multiple command should be separated with a &&

    :return: the result of the commands
    �z&&)�split�__secure_popen)�cmd�ret�c�r�/usr/lib/python3.6/secure.py�secure_popensr
c	Cs|jd�}t|�dkr dj|�St|�dkrB|dj�}|d}nd}d}d}x`|jd�D]R}dd	�ttdtjd
|���D�}t|d|ttd�}|dk	r�|j	j
�|}|j	}qZW|j�}t|d�d
k�rt|d�}	|dk	�rt
|d��}
|
j|	�WdQRXnt|d�}	|	S)zbA more or less secure way to execute system command

    Manage redirection (>) and pipes (|)
    �>�z5Glances error: Only one file redirection allowed ({})�rN�|cSsg|]}|dkr|�qS)� r)�.0�_rrr�
<listcomp>5sz"__secure_popen.<locals>.<listcomp>z(\s+)|(".*?"+?)|(\'.*?\'+?)F)�shell�stdin�stdout�stderrr�w)r�len�format�strip�list�filter�rerrr�closeZcommunicater�open�write)rZcmd_split_redirectZstdout_redirectZ
sub_cmd_stdinZp_lastZsub_cmdZ
sub_cmd_split�pZp_retr	Zstdout_redirect_filerrrr!s0


 


r)	�__doc__Zglances.compatr�
subprocessrrr r
rrrrr�<module>
s