
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
9Mj~                 @   sD   d dl Z d dlZdd Zdd Zdd Zdd	 Zd
d Zdd ZdS )    Nc             C   s   | d dkr|dkrdS dS )Nr   "    )lineisquotfr   r   -/usr/share/lve/modlscapi/user/exec_command.py
first_quot   s    r   c             C   s$   | t | d  dkr |dkr dS dS )Nr   r   r   )len)r   r   r   r   r   	last_quot   s    r
   c             C   s   | j d} d}d}g }xtt| D ]p}| | dkr$t| | |dkrTd}| | }q$t| | |dkrd}|d| |  7 }|j| q$|j| |  q$W t| d S )N r    r   )splitranger	   r   r
   appendprint)commandZisquotresresultir   r   r   parse_command   s"    

r   c             C   s   g }yNt j| dt jt jd}x2|jj }|s.P |j dkr|j|j j  qW W n2 tk
r } zt	dt
|  W Y d d }~X nX |S )NT)shellstdoutstderrr   zCall process error: )
subprocessPopenPIPEr   readlinestripr   decode	Exceptionr   str)r   r   poutputinstr   r   r   exec_command'   s    
"r$   c             C   s
   t j| S )z
    Run command via os.system and return its exit status

    :param command: Command to execute in a subshell
    :return: Exit status of the command process
    )ossystem)r   r   r   r   exec_command_out6   s    r'   c             C   s&   t | }x|D ]}||kr|S qW dS )Nr   )r$   )r   Z	substringr   r   r   r   r   exec_command_find_substring@   s
    
r)   )r%   r   r   r
   r   r$   r'   r)   r   r   r   r   <module>   s   
