ó
½-'Nc           @   s<   d  d l  Z  d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿNt   ProcessErrorc           B   s   e  Z d  Z RS(   s)    Error running a process with os.system. (   t   __name__t
   __module__t   __doc__(    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyR       s   t
   SysVConfigc           B   sJ   e  Z d  d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   /etc/default/landscape-clientc         C   s   | |  _  d  S(   N(   t	   _filename(   t   selft   filename(    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   __init__	   s    c         C   s3   |  j  ƒ  } | r d p d | d <|  j | ƒ d  S(   Ni   i    t   RUN(   t   _parse_filet   _write_file(   R   t   flagt   current(    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   set_start_on_boot   s    c         C   s"   t  j d ƒ r t d ƒ ‚ n  d  S(   Ns$   /etc/init.d/landscape-client restarts   Could not restart client(   t   ost   systemR    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   restart_landscape   s    c         C   s"   t  j d ƒ r t d ƒ ‚ n  d  S(   Ns!   /etc/init.d/landscape-client stops   Could not stop client(   R   R   R    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   stop_landscape   s    c         C   s9   |  j  ƒ  } | j d d ƒ } | d  j ƒ  o8 | d k S(   sç   
        Return a boolean representing whether the init script will decide to
        actually start the client when it is run.  This method should match
        the semantics of the checks in debian/landscape-client.init.
        R	   t   0i   (   R
   t   gett   isspace(   R   t   statet	   run_value(    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   is_configured_to_run   s    c         C   sy   i  } t  j j |  j ƒ ru xW t |  j d ƒ D]@ } | j ƒ  } d | k r. | j d ƒ \ } } | | | <q. q. Wn  | S(   Nt   rt   =(   R   t   patht   isfileR   t   opent   stript   split(   R   t   valuest   linet   keyt   value(    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyR
   #   s    c         C   s^   t  |  j d ƒ } x; t | j ƒ  ƒ D]' } | j d | t | | ƒ f ƒ q% W| j ƒ  d  S(   Nt   ws   %s=%s
(   R   R   t   sortedt   keyst   writet   strt   close(   R   R    t   fileR"   (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyR   .   s    %(	   R   R   R   R   R   R   R   R
   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyR      s   				
	(   R   t	   ExceptionR    t   objectR   (    (    (    s8   /usr/lib/python2.7/dist-packages/landscape/sysvconfig.pyt   <module>   s   