ó
ÍÿŠTc           @   s‚   d  d l  Z  d  d l m Z d  d l m Z m Z d  d l m Z d  d l m	 Z	 d e
 f d „  ƒ  YZ d e f d	 „  ƒ  YZ d S(
   iÿÿÿÿN(   t   gettext(   t   NOT_MANAGEDt   CANONICAL_MANAGED(   t   RegistrationProxy(   t
   StateErrort   ConfigControllerLockErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR      s   t   ConfigControllerc           B   s\   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   sÅ   
    L{ConfigContoller} defines actions to take against a configuration object,
    providing starting values from the file, allowing them to be changed
    transiently, reverted or committed.
    t
   standalonec         C   s   g  |  _  | |  _ t |  _ d  S(   N(   t
   _observerst   _configurationt   Truet   _initialised(   t   selft   configuration(    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   __init__   s    		c         C   s.   | |  j  k r |  j  | St |  j | ƒ Sd  S(   N(   t   __dict__t   getattrR   (   R   t   name(    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   __getattr__   s    c         C   s   d |  j  k r" t j |  | | ƒ S| t j  k rD t j |  | | ƒ Sy$ t |  j | | ƒ |  j j ƒ  Wn! t k
 r‹ t j |  | | ƒ SX|  j j ƒ  d  S(   NR   (   R   t   objectt   __setattr__R   t   setattrR   t   modifyt   AttributeError(   R   R   t   value(    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR   #   s    c         C   s   |  j  j ƒ  S(   s?   
        Load the initial data from the configuration.
        (   R   t	   load_data(   R   (    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   load2   s    c         C   s6   y |  j  j ƒ  Wn t k
 r1 t j d ƒ n Xd S(   sU   
        Revert settings to those the configuration object originally found.
        s@   landscape-client-settings-ui reverted with no changes to revert.N(   R   t   revertR   t   loggingt   info(   R   (    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR   8   s    c         C   st   y |  j  j ƒ  Wn t k
 r1 t j d ƒ n X|  j  j t k rZ |  j | | | ƒ n |  j | | | | ƒ d S(   s.   Persist settings via the configuration object.sA   landscape-client-settings-ui committed with no changes to commit.N(	   R   t   persistR   R   R   t   management_typeR   t   disablet   register(   R   t	   on_notifyt   on_errort
   on_succeedt   on_fail(    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR    C   s    c      	      s¬   ‡ f d †  } ‡  f d †  } t  d | d | d | d | ƒ } |  j j t k rn | t d ƒ |  j j ƒ n | t d ƒ |  j j ƒ | j |  j j ƒ  ƒ | j	 ƒ  d S(	   sF   
        Perform registration using the L{RegistrationProxy}.
        c              s   ˆ  d t  d ƒ ƒ d  S(   Nt   actions   Registering client failed(   t   _(    (   t   fail_method(    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   registration_fail_wrapperV   s    c              s   ˆ  d t  d ƒ ƒ d  S(   NR(   s!   Registering client was successful(   R)   (    (   t   succeed_method(    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   registration_succeed_wrapperY   s    t   on_register_notifyt   on_register_errort   on_register_succeedt   on_register_fails   Attempting to register at %sN(
   R   R   R!   R   R)   t   hosted_landscape_hostt   local_landscape_hostR#   t   get_config_filenamet   exit(   R   t   notify_methodt   error_methodR,   R*   R+   R-   t   registration(    (   R,   R*   sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR#   P   s    	c            s[   ‡  f d †  } ‡ f d †  } t  d | d | ƒ } | t d ƒ ƒ | j ƒ  | j ƒ  d S(   sH   
        Disable landscape client via the L{RegistrationProxy}.
        c              s   ˆ  d t  d ƒ ƒ d  S(   NR(   s   Disabling client failed(   R)   (    (   R*   (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   disabling_fail_wrappero   s    c              s   ˆ  d t  d ƒ ƒ d  S(   NR(   s   Disabling client was successful(   R)   (    (   R,   (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   disabling_succeed_wrapperr   s    t   on_disable_succeedt   on_disable_fails'   Attempting to disable landscape client.N(   R   R)   R"   R5   (   R   R6   R,   R*   R9   R:   R8   (    (   R*   R,   sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR"   j   s    	
(   R   R   t   __doc__t   DEFAULT_DEDICATED_ACCOUNT_NAMER   R   R   R   R   R    R#   R"   (    (    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyR      s   							(   R   R    R)   t   landscape.ui.constantsR   R   t%   landscape.ui.model.registration.proxyR   t&   landscape.ui.model.configuration.stateR   t	   ExceptionR   R   R   (    (    (    sI   /usr/lib/python2.7/dist-packages/landscape/ui/controller/configuration.pyt   <module>   s   