ó
½-'Nc           @   sb   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d Z d Z d e f d „  ƒ  YZ	 d S(	   iÿÿÿÿN(   t	   exception(   t   format_object(   t   BrokerClientPlugini   i   t   ManagerPluginc           B   s    e  Z e d  „  ƒ Z d „  Z RS(   c         C   s   |  j  S(   s&   An alias for the C{client} attribute}.(   t   client(   t   self(    (    s<   /usr/lib/python2.7/dist-packages/landscape/manager/plugin.pyt   manager   s    c   
      O   s¶   y | | | Ž  } WnO t  } t j ƒ  d  \ } } d | j | f } t d t | ƒ | | ƒ n Xt } i d d 6| d 6| d d 6}	 | r | |	 d <n  |  j j j	 |	 d	 t
 ƒS(
   s¿  Send an operation-result message after calling C{callable}.

        If the function returns normally, an operation-result
        indicating success will be sent.  If the function raises an
        exception, an operation-result indicating failure will be
        sent.

        @param message: The original message.
        @param callable: The function to call to handle the message.
            C{args} and C{kwargs} are passed to it.
        i   s   %s: %ss9   Error occured running message handler %s with args %r %r.s   operation-resultt   typet   statuss   operation-ids   result-textt   urgent(   t   FAILEDt   syst   exc_infot   __name__R    R   t	   SUCCEEDEDR   t   brokert   send_messaget   True(
   R   t   messaget   callablet   argst   kwargst   textR   t   clst   objt   operation_result(    (    s<   /usr/lib/python2.7/dist-packages/landscape/manager/plugin.pyt   call_with_operation_result   s    (   R   t
   __module__t   propertyR   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/landscape/manager/plugin.pyR      s   (
   R   t   loggingR    t   landscape.logR   t   landscape.broker.clientR   R
   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/landscape/manager/plugin.pyt   <module>   s   