File: //lib/python2.7/site-packages/clcommon/utils.pyc
�
b=0Yc           @   s;   d  d l  Z  d e f d �  �  YZ d d � Z d �  Z d S(   i����Nt   ExternalProgramFailedc           B   s   e  Z d  �  Z RS(   c         C   s   t  j |  | � d  S(   N(   t	   Exceptiont   __init__(   t   selft   message(    (    s2   /usr/lib/python2.7/site-packages/clcommon/utils.pyR      s    (   t   __name__t
   __module__R   (    (    (    s2   /usr/lib/python2.7/site-packages/clcommon/utils.pyR       s   c         C   s�   d j  |  � } y= t j |  d t d � d t j d t j d t d | �} Wn/ t k
 r} } t d | t	 | � f � � n X| j
 �  \ } } | j d	 k r� t | p� d
 | | f � � n  | S(   sv   
    Runs external process and returns output
    @param cmd: command and arguments as a list
    @return: string
    t    t   stdins	   /dev/nullt   stdoutt   stderrt	   close_fdst   envs   %s. Can not run command: %si    s   output of the command: %s
%s(   t   joint
   subprocesst   Popent   opent   PIPEt   STDOUTt   Truet   OSErrorR    t   strt   communicatet
   returncode(   t   cmdt   env_datat   cmd_linet   outputt   oserrt   std_outt   std_err(    (    s2   /usr/lib/python2.7/site-packages/clcommon/utils.pyt   run_command   s    		
 c         C   s}   t  } t |  d � } | j �  } | j d � x4 | D], } | d | k r[ | j | � q5 t } q5 W| j �  | j �  | S(   s  
    Delete line from file. Return True when line(s) have been deleted, False otherwise (specified line is not found)
    :param path: path to file
    :type path: string
    :param line: line to delete without EOL ('
')
    :type line: string
    :rtype bool
    s   r+i    s   %s
(   t   FalseR   t	   readlinest   seekt   writeR   t   truncatet   close(   t   patht   linet   foundt   ft   linest   l(    (    s2   /usr/lib/python2.7/site-packages/clcommon/utils.pyt   delete_line_from_file#   s    	
(   R   R   R    t   NoneR   R,   (    (    (    s2   /usr/lib/python2.7/site-packages/clcommon/utils.pyt   <module>   s