σ
ίΘ[c           @` sn   d  d l  m Z m Z m Z m Z d d l m Z d d l m Z d g Z	 d g Z
 d e f d     YZ d	 S(
   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsi   (   t
   SAMPClient(   t   SAMPHubProxyu   SAMPIntegratedClientu   SAMPIntegratedClient.*t   SAMPIntegratedClientc           B` s`  e  Z d  Z d( d( d( d( d e d  Z e d    Z d( d( d d  Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d( d( d  Z d   Z e j j e _ d   Z  e j  j e  _ d   Z! e j! j e! _ e d( d  Z" e j" j e" _ e d( d  Z# e j# j e# _ e d( d   Z$ e j$ j e$ _ d!   Z% e j% j e% _ e d"  Z& e j& j e& _ e d#  Z' e j' j e' _ d$   Z( e j( j e( _ d( d%  Z) e j) j e) _ d&   Z* e j* j e* _ d'   Z+ e j+ j e+ _ RS()   uo  
    A Simple SAMP client.

    This class is meant to simplify the client usage providing a proxy class
    that merges the :class:`~astropy.samp.SAMPClient` and
    :class:`~astropy.samp.SAMPHubProxy` functionalities in a
    simplified API.

    Parameters
    ----------
    name : str, optional
        Client name (corresponding to ``samp.name`` metadata keyword).

    description : str, optional
        Client description (corresponding to ``samp.description.text`` metadata
        keyword).

    metadata : dict, optional
        Client application metadata in the standard SAMP format.

    addr : str, optional
        Listening address (or IP). This defaults to 127.0.0.1 if the internet
        is not reachable, otherwise it defaults to the host name.

    port : int, optional
        Listening XML-RPC server socket port. If left set to 0 (the default),
        the operating system will select a free port.

    callable : bool, optional
        Whether the client can receive calls and notifications. If set to
        `False`, then the client can send notifications and calls, but can not
        receive any.
    i    c         C` sL   t    |  _ i | d 6| d 6| d 6| d 6| d 6| d 6|  _ d  |  _ d  S(   Nu   nameu   descriptionu   metadatau   addru   portu   callable(   R   t   hubt   client_argumentst   Nonet   client(   t   selft   namet   descriptiont   metadatat   addrt   portt   callable(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   __init__1   s    		c         C` s   |  j  j o |  j j S(   uΨ   
        Testing method to verify the client connection with a running Hub.

        Returns
        -------
        is_connected : bool
            True if the client is connected to a Hub, False otherwise.
        (   R   t   is_connectedR
   t
   is_running(   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR   J   s    
i   c         C` sL   |  j  j | | |  t |  j  |  j  |  _ |  j j   |  j j   d S(   uN  
        Connect with the current or specified SAMP Hub, start and register the
        client.

        Parameters
        ----------
        hub : `~astropy.samp.SAMPHubServer`, optional
            The hub to connect to.

        hub_params : dict, optional
            Optional dictionary containing the lock-file content of the Hub
            with which to connect. This dictionary has the form
            ``{<token-name>: <token-string>, ...}``.

        pool_size : int, optional
            The number of socket connections opened to communicate with the
            Hub.
        N(   R   t   connectR   R   R
   t   startt   register(   R   R   t
   hub_paramst	   pool_size(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR   V   s    c         C` sN   |  j  rJ z |  j j   Wd |  j j r9 |  j j   n  |  j j   Xn  d S(   uw   
        Unregister the client from the current SAMP Hub, stop the client and
        disconnect from the Hub.
        N(   R   R
   t
   unregisterR   t   stopR   t
   disconnect(   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR   w   s    	c         C` s   |  j  j   S(   uL   
        Proxy to ``ping`` SAMP Hub method (Standard Profile only).
        (   R   t   ping(   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR      s    c         C` s   |  j  j |  S(   u?   
        Proxy to ``declareMetadata`` SAMP Hub method.
        (   R
   t   declare_metadata(   R   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR      s    c         C` s   |  j  j |  j   |  S(   u;   
        Proxy to ``getMetadata`` SAMP Hub method.
        (   R   t   get_metadatat   get_private_key(   R   t	   client_id(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR      s    c         C` s   |  j  j |  j   |  S(   u@   
        Proxy to ``getSubscriptions`` SAMP Hub method.
        (   R   t   get_subscriptionsR    (   R   R!   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR"      s    c         C` s   |  j  j |  j    S(   u   
        Proxy to ``getRegisteredClients`` SAMP Hub method.

        This returns all the registered clients, excluding the current client.
        (   R   t   get_registered_clientsR    (   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR#      s    c         C` s   |  j  j |  j   |  S(   uD   
        Proxy to ``getSubscribedClients`` SAMP Hub method.
        (   R   t   get_subscribed_clientsR    (   R   t   mtype(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR$   ₯   s    c         C` s_   i  } d | k rG | d } | d =i | d 6| d 6} | j  |  n i | d 6| d 6} | S(   Nu	   extra_kwsu
   samp.mtypeu   samp.params(   t   update(   R   R%   t   paramst   msgt   extra(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   _format_easy_msg«   s    
c         C` s   |  j  j |  j   | |  S(   u6   
        Proxy to ``notify`` SAMP Hub method.
        (   R   t   notifyR    (   R   t   recipient_idt   message(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR+   Ή   s    c         K` s   |  j  | |  j | |   S(   u9  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify`.

        This is a proxy to ``notify`` method that allows to send the
        notification message in a simplified way.

        Note that reserved ``extra_kws`` keyword is a dictionary with the
        special meaning of being used to add extra keywords, in addition to
        the standard ``samp.mtype`` and ``samp.params``, to the message sent.

        Parameters
        ----------
        recipient_id : str
            Recipient ID

        mtype : str
            the MType to be notified

        params : dict or set of keywords
            Variable keyword set which contains the list of parameters for the
            specified MType.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> cli.enotify("samp.msg.progress", msgid = "xyz", txt = "initialization",
        ...             percent = "10", extra_kws = {"my.extra.info": "just an example"})
        (   R+   R*   (   R   R,   R%   R'   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   enotifyΏ   s    c         C` s   |  j  j |  j   |  S(   u9   
        Proxy to ``notifyAll`` SAMP Hub method.
        (   R   t
   notify_allR    (   R   R-   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR/   ΰ   s    c         K` s   |  j  |  j | |   S(   u  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.notify_all`.

        This is a proxy to ``notifyAll`` method that allows to send the
        notification message in a simplified way.

        Note that reserved ``extra_kws`` keyword is a dictionary with the
        special meaning of being used to add extra keywords, in addition to
        the standard ``samp.mtype`` and ``samp.params``, to the message sent.

        Parameters
        ----------
        mtype : str
            MType to be notified.

        params : dict or set of keywords
            Variable keyword set which contains the list of parameters for
            the specified MType.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> cli.enotify_all("samp.msg.progress", txt = "initialization",
        ...                 percent = "10",
        ...                 extra_kws = {"my.extra.info": "just an example"})
        (   R/   R*   (   R   R%   R'   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   enotify_allζ   s    c         C` s   |  j  j |  j   | | |  S(   u4   
        Proxy to ``call`` SAMP Hub method.
        (   R   t   callR    (   R   R,   t   msg_tagR-   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR1     s    c         K` s   |  j  | | |  j | |   S(   u  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.call`.

        This is a proxy to ``call`` method that allows to send a call message
        in a simplified way.

        Note that reserved ``extra_kws`` keyword is a dictionary with the
        special meaning of being used to add extra keywords, in addition to
        the standard ``samp.mtype`` and ``samp.params``, to the message sent.

        Parameters
        ----------
        recipient_id : str
            Recipient ID

        msg_tag : str
            Message tag to use

        mtype : str
            MType to be sent

        params : dict of set of keywords
            Variable keyword set which contains the list of parameters for
            the specified MType.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> msgid = cli.ecall("abc", "xyz", "samp.msg.progress",
        ...                   txt = "initialization", percent = "10",
        ...                   extra_kws = {"my.extra.info": "just an example"})
        (   R1   R*   (   R   R,   R2   R%   R'   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   ecall  s    $c         C` s   |  j  j |  j   | |  S(   u7   
        Proxy to ``callAll`` SAMP Hub method.
        (   R   t   call_allR    (   R   R2   R-   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR4   1  s    c         K` s    |  j  | |  j | |   d S(   u[  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.call_all`.

        This is a proxy to ``callAll`` method that allows to send the call
        message in a simplified way.

        Note that reserved ``extra_kws`` keyword is a dictionary with the
        special meaning of being used to add extra keywords, in addition to
        the standard ``samp.mtype`` and ``samp.params``, to the message sent.

        Parameters
        ----------
        msg_tag : str
            Message tag to use

        mtype : str
            MType to be sent

        params : dict of set of keywords
            Variable keyword set which contains the list of parameters for
            the specified MType.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> msgid = cli.ecall_all("xyz", "samp.msg.progress",
        ...                       txt = "initialization", percent = "10",
        ...                       extra_kws = {"my.extra.info": "just an example"})
        N(   R4   R*   (   R   R2   R%   R'   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt	   ecall_all7  s     c         C` s   |  j  j |  j   | | |  S(   u;   
        Proxy to ``callAndWait`` SAMP Hub method.
        (   R   t   call_and_waitR    (   R   R,   R-   t   timeout(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR6   Y  s    c         K` s   |  j  | |  j | |  |  S(   u  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.call_and_wait`.

        This is a proxy to ``callAndWait`` method that allows to send the call
        message in a simplified way.

        Note that reserved ``extra_kws`` keyword is a dictionary with the
        special meaning of being used to add extra keywords, in addition to
        the standard ``samp.mtype`` and ``samp.params``, to the message sent.

        Parameters
        ----------
        recipient_id : str
            Recipient ID

        mtype : str
            MType to be sent

        timeout : str
            Call timeout in seconds

        params : dict of set of keywords
            Variable keyword set which contains the list of parameters for
            the specified MType.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> cli.ecall_and_wait("xyz", "samp.msg.progress", "5",
        ...                    txt = "initialization", percent = "10",
        ...                    extra_kws = {"my.extra.info": "just an example"})
        (   R6   R*   (   R   R,   R%   R7   R'   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   ecall_and_wait_  s    #c         C` s   |  j  j |  j   | |  S(   u5   
        Proxy to ``reply`` SAMP Hub method.
        (   R   t   replyR    (   R   t   msg_idt   response(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR9     s    c         C` sW   i | d 6} | d  k	 r0 | j i | d 6 n  | d  k	 rS | j i | d 6 n  | S(   Nu   samp.statusu   samp.resultu
   samp.error(   R	   R&   (   R   t   statust   resultt   errorR(   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   _format_easy_response  s    c         C` s   |  j  | |  j | | |   S(   ua  
        Easy to use version of :meth:`~astropy.samp.integrated_client.SAMPIntegratedClient.reply`.

        This is a proxy to ``reply`` method that allows to send a reply
        message in a simplified way.

        Parameters
        ----------
        msg_id : str
            Message ID to which reply.

        status : str
            Content of the ``samp.status`` response keyword.

        result : dict
            Content of the ``samp.result`` response keyword.

        error : dict
            Content of the ``samp.error`` response keyword.

        Examples
        --------
        >>> from astropy.samp import SAMPIntegratedClient, SAMP_STATUS_ERROR
        >>> cli = SAMPIntegratedClient()
        >>> ...
        >>> cli.ereply("abd", SAMP_STATUS_ERROR, result={},
        ...            error={"samp.errortxt": "Test error message"})
        (   R9   R?   (   R   R:   R<   R=   R>   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   ereply  s    c         C` s   |  j  j | | |  S(   N(   R
   t   receive_notification(   R   t   private_keyt	   sender_idR-   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRA   ΅  s    c         C` s   |  j  j | | | |  S(   N(   R
   t   receive_call(   R   RB   RC   R:   R-   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRD   Ί  s    c         C` s   |  j  j | | | |  S(   N(   R
   t   receive_response(   R   RB   t   responder_idR2   R;   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRE   Ώ  s    c         C` s#   |  j  j | | d t d d  d  S(   Nt   declareR   (   R
   t   bind_receive_messaget   TrueR	   (   R   R%   t   functionRG   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRH   Δ  s    c         C` s   |  j  j | | | |  d  S(   N(   R
   t   bind_receive_notification(   R   R%   RJ   RG   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRK   Ι  s    c         C` s   |  j  j | | | |  d  S(   N(   R
   t   bind_receive_call(   R   R%   RJ   RG   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRL   Ξ  s    c         C` s   |  j  j | |  d  S(   N(   R
   t   bind_receive_response(   R   R2   RJ   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRM   Σ  s    c         C` s   |  j  j | |  d  S(   N(   R
   t   unbind_receive_notification(   R   R%   RG   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRN   Ψ  s    c         C` s   |  j  j | |  d  S(   N(   R
   t   unbind_receive_call(   R   R%   RG   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRO   έ  s    c         C` s   |  j  j |  d  S(   N(   R
   t   unbind_receive_response(   R   R2   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRP   β  s    c         C` s   |  j  j |  d  S(   N(   R
   t   declare_subscriptions(   R   t   subscriptions(    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRQ   η  s    c         C` s   |  j  j   S(   N(   R
   R    (   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR    μ  s    c         C` s   |  j  j   S(   N(   R
   t   get_public_id(   R   (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyRS   ρ  s    N(,   t   __name__t
   __module__t   __doc__R	   RI   R   t   propertyR   R   R   R   R   R   R"   R#   R$   R*   R+   R.   R/   R0   R1   R3   R4   R5   R6   R8   R9   R?   R@   RA   R   RD   RE   RH   RK   RL   RM   RN   RO   RP   RQ   R    RS   (    (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyR      sh   !	!										!				&		"		%		
!							N(   t
   __future__R    R   R   R   R
   R   t	   hub_proxyR   t   __all__t   __doctest_skip__t   objectR   (    (    (    s=   lib/python2.7/site-packages/astropy/samp/integrated_client.pyt   <module>   s
   "		