ó
ý}Lc           @   s  d  Z  d d l Z d d l j Z d d l m Z d d l Td d l m Z d d l m	 Z	 m
 Z
 d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m  Z  d d l! m" Z" d d l# m# Z# d d l$ m% Z% d d l& m' Z' d d l( m) Z) e) e* ƒ Z+ d e, f d „  ƒ  YZ- d d( d „  ƒ  YZ d d) d „  ƒ  YZ. d d* d „  ƒ  YZ/ d  d+ d! „  ƒ  YZ0 d" d, d# „  ƒ  YZ1 d$ d- d% „  ƒ  YZ2 d& e2 f d' „  ƒ  YZ3 d S(.   sX   
The I{2nd generation} service proxy provides access to web services.
See I{README.txt}
iÿÿÿÿN(   t	   CookieJar(   t   *(   t   DefinitionsReader(   t   TransportErrort   Request(   t   HttpAuthenticated(   t   ServiceDefinition(   t
   sudsobject(   t   Factory(   t   Object(   t   PathResolver(   t   Builder(   t   Definitions(   t   ObjectCache(   t   Document(   t   Parser(   t   Options(   t   Unskin(   t   urlparse(   t   deepcopy(   t   PluginContainer(   t	   getLoggert   Clientc           B   sƒ   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z RS(   sÔ   
    A lightweight web services client.
    I{(2nd generation)} API.
    @ivar wsdl: The WSDL object.
    @type wsdl:L{Definitions}
    @ivar service: The service proxy used to invoke operations.
    @type service: L{Service}
    @ivar factory: The factory used to create objects.
    @type factory: L{Factory}
    @ivar sd: The service definition
    @type sd: L{ServiceDefinition}
    @ivar messages: The last sent/received messages.
    @type messages: str[2]
    c         C   s   t  j | ƒ S(   s  
        Extract the I{items} from a suds object much like the
        items() method works on I{dict}.
        @param sobject: A suds object
        @type sobject: L{Object}
        @return: A list of items contained in I{sobject}.
        @rtype: [(key, value),...]
        (   R   t   items(   t   clst   sobject(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR   @   s    
c         C   s   t  j | ƒ S(   sô   
        Convert a sudsobject into a dictionary.
        @param sobject: A suds object
        @type sobject: L{Object}
        @return: A python dictionary containing the
            items contained in I{sobject}.
        @rtype: dict
        (   R   t   asdict(   R   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   dictL   s    
c         C   s   | j  S(   sÏ   
        Extract the metadata from a suds object.
        @param sobject: A suds object
        @type sobject: L{Object}
        @return: The object's metadata
        @rtype: L{sudsobject.Metadata}
        (   t   __metadata__(   R   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   metadataX   s    	c         K   s  t  ƒ  } t ƒ  | _ | |  _ t d d ƒ | _ |  j | �  t | t ƒ } | j	 | ƒ |  _
 t | j ƒ } | j j d |  j
 ƒ t |  j
 ƒ |  _ t |  |  j
 j ƒ |  _ g  |  _ x6 |  j
 j D]( } t |  j
 | ƒ } |  j j | ƒ qÃ Wt d d d d ƒ |  _ d S(   s�   
        @param url: The URL for the WSDL.
        @type url: str
        @param kwargs: keyword arguments.
        @see: L{Options}
        t   daysi   t   wsdlt   txt   rxN(   R   R   t	   transportt   optionsR   t   cachet   set_optionsR   R   t   openR   R   t   pluginst   initt   initializedR   t   factoryt   ServiceSelectort   servicest   servicet   sdR   t   appendR   t   Nonet   messages(   t   selft   urlt   kwargsR#   t   readerR'   t   sR.   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __init__c   s     			c         K   s    t  |  j ƒ } | j | ƒ d S(   sa   
        Set options.
        @param kwargs: keyword arguments.
        @see: L{Options}
        N(   R   R#   t   update(   R2   R4   t   p(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR%   {   s    c         C   sk   |  j  j } | j | d ƒ } | d k r> | j | | ƒ d S| d | k rg t d | | f ƒ ‚ n  d S(   s¬  
        Add I{static} mapping of an XML namespace prefix to a namespace.
        This is useful for cases when a wsdl and referenced schemas make heavy
        use of namespaces and those namespaces are subject to changed.
        @param prefix: An XML namespace prefix.
        @type prefix: str
        @param uri: An XML namespace URI.
        @type uri: str
        @raise Exception: when prefix is already mapped.
        Ni   s   "%s" already mapped as "%s"(   R   t   roott   resolvePrefixR0   t	   addPrefixt	   Exception(   R2   t   prefixt   uriR:   t   mapped(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt
   add_prefix„   s    c         C   s   |  j  j d ƒ S(   s|   
        Get last sent I{soap} message.
        @return: The last sent I{soap} message.
        @rtype: L{Document}
        R    (   R1   t   get(   R2   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt	   last_sent—   s    c         C   s   |  j  j d ƒ S(   s„   
        Get last received I{soap} message.
        @return: The last received I{soap} message.
        @rtype: L{Document}
        R!   (   R1   RB   (   R2   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   last_receivedŸ   s    c         C   s´   d t  f d „  ƒ  Y} | ƒ  } t ƒ  | _ t | j ƒ } t |  j ƒ } | j t | ƒ ƒ |  j | _ |  j | _ t | |  j j	 ƒ | _
 |  j | _ t d d d d ƒ | _ | S(   sê   
        Get a shallow clone of this object.
        The clone only shares the WSDL.  All other attributes are
        unique to the cloned object including options.
        @return: A shallow clone.
        @rtype: L{Client}
        t   Uninitializedc           B   s   e  Z d  „  Z RS(   c         S   s   d  S(   N(    (   R2   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7   °   s    (   t   __name__t
   __module__R7   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRE   ¯   s   R    R!   N(   R   R   R#   R   R8   R   R   R*   R+   R,   R-   R.   R   R0   R1   (   R2   RE   t   clonet   cpt   mp(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRH   §   s    	c         C   s
   t  |  ƒ S(   N(   t   unicode(   R2   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __str__¾   s    c         C   s�   d g } t  j j ƒ  } | j d ƒ | j d t  j ƒ | j d | d | d f ƒ x( |  j D] } | j d t | ƒ ƒ qb Wd j | ƒ S(	   Ns   
s'   Suds ( https://fedorahosted.org/suds/ )s     version: %ss    %s  build: %si    i   s   

%st    (   t   sudst	   __build__t   splitR/   t   __version__R.   RK   t   join(   R2   R6   t   buildR.   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __unicode__Á   s    	(   RF   RG   t   __doc__t   classmethodR   R   R   R7   R%   RA   RC   RD   RH   RL   RT   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR   1   s   								R   c           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sÙ   
    A factory for instantiating types defined in the wsdl
    @ivar resolver: A schema type resolver.
    @type resolver: L{PathResolver}
    @ivar builder: A schema object builder.
    @type builder: L{Builder}
    c         C   s.   | |  _  t | ƒ |  _ t |  j ƒ |  _ d S(   sW   
        @param wsdl: A schema object.
        @type wsdl: L{wsdl.Definitions}
        N(   R   R
   t   resolverR   t   builder(   R2   R   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7   Õ   s    	c         C   s	  t  j ƒ  } | j ƒ  |  j j | ƒ } | d k rC t | ƒ ‚ n  | j ƒ  r” t j	 | ƒ } x„ | j
 ƒ  D]" \ } } t | | j | j ƒ qk WnQ y |  j j | ƒ } Wn8 t k
 rä } t j d | d t ƒt | | ƒ ‚ n X| j ƒ  t  j j d | | ƒ | S(   sÂ   
        create a WSDL type by name
        @param name: The name of a type defined in the WSDL.
        @type name: str
        @return: The requested object.
        @rtype: L{Object}
        s   create '%s' failedt   exc_infos   %s created: %sN(   t   metricst   Timert   startRW   t   findR0   t   TypeNotFoundt   enumt   InstFactoryt   objectt   childrent   setattrt   nameRX   RS   R=   t   logt   errort   Truet
   BuildErrort   stopt   debug(   R2   Rd   t   timert   typet   resultt   et   a(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   createÞ   s"    

c         C   s   t  |  j | ƒ |  _ d S(   sk   
        Set the path separator.
        @param ps: The new path separator.
        @type ps: char
        N(   R
   R   RW   (   R2   t   ps(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt	   separatorù   s    (   RF   RG   RU   R7   Rp   Rr   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR   Ì   s   			R+   c           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sñ  
    The B{service} selector is used to select a web service.
    In most cases, the wsdl only defines (1) service in which access
    by subscript is passed through to a L{PortSelector}.  This is also the
    behavior when a I{default} service has been specified.  In cases
    where multiple services have been defined and no default has been
    specified, the service is found by name (or index) and a L{PortSelector}
    for the service is returned.  In all cases, attribute access is
    forwarded to the L{PortSelector} for either the I{first} service or the
    I{default} service (when specified).
    @ivar __client: A suds client.
    @type __client: L{Client}
    @ivar __services: A list of I{wsdl} services.
    @type __services: list
    c         C   s   | |  _  | |  _ d S(   s¡   
        @param client: A suds client.
        @type client: L{Client}
        @param services: A list of I{wsdl} services.
        @type services: list
        N(   t   _ServiceSelector__clientt   _ServiceSelector__services(   R2   t   clientR,   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7     s    	c         C   s=   |  j  ƒ  } | d k r* |  j d ƒ } n | } t | | ƒ S(   s9  
        Request to access an attribute is forwarded to the
        L{PortSelector} for either the I{first} service or the
        I{default} service (when specified).
        @param name: The name of a method.
        @type name: str
        @return: A L{PortSelector}.
        @rtype: L{PortSelector}. 
        i    N(   t   _ServiceSelector__dsR0   t   _ServiceSelector__findt   getattr(   R2   Rd   t   defaultt   port(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __getattr__  s
    
c         C   s_   t  |  j ƒ d k r, |  j d ƒ } | | S|  j ƒ  } | d k	 rR | } | | S|  j | ƒ S(   sª  
        Provides selection of the I{service} by name (string) or 
        index (integer).  In cases where only (1) service is defined
        or a I{default} has been specified, the request is forwarded
        to the L{PortSelector}.
        @param name: The name (or index) of a service.
        @type name: (int|str)
        @return: A L{PortSelector} for the specified service.
        @rtype: L{PortSelector}. 
        i   i    N(   t   lenRt   Rw   Rv   R0   (   R2   Rd   Rz   Ry   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __getitem__-  s    c         C   sÉ   d } t |  j ƒ s! t d ‚ n  t | t ƒ rn y |  j | } | j } Wq› t k
 rj t d | ‚ q› Xn- x* |  j D] } | | j k rx | } Pqx qx W| d k r³ t | ‚ n  t	 |  j
 | j | ƒ S(   sù   
        Find a I{service} by name (string) or index (integer).
        @param name: The name (or index) of a service.
        @type name: (int|str)
        @return: A L{PortSelector} for the found service.
        @rtype: L{PortSelector}. 
        s   No services defineds   at [%d]N(   R0   R|   Rt   R=   t
   isinstancet   intRd   t
   IndexErrort   ServiceNotFoundt   PortSelectorRs   t   ports(   R2   Rd   R-   R6   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __findA  s     c         C   s0   |  j  j j } | d k r d S|  j | ƒ Sd S(   s«   
        Get the I{default} service if defined in the I{options}.
        @return: A L{PortSelector} for the I{default} service.
        @rtype: L{PortSelector}. 
        N(   Rs   R#   R-   R0   Rw   (   R2   t   ds(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __ds[  s    (   RF   RG   RU   R7   R{   R}   Rw   Rv   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR+     s   	
			R‚   c           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sv  
    The B{port} selector is used to select a I{web service} B{port}.
    In cases where multiple ports have been defined and no default has been
    specified, the port is found by name (or index) and a L{MethodSelector}
    for the port is returned.  In all cases, attribute access is
    forwarded to the L{MethodSelector} for either the I{first} port or the
    I{default} port (when specified).
    @ivar __client: A suds client.
    @type __client: L{Client}
    @ivar __ports: A list of I{service} ports.
    @type __ports: list
    @ivar __qn: The I{qualified} name of the port (used for logging).
    @type __qn: str
    c         C   s   | |  _  | |  _ | |  _ d S(   sÝ   
        @param client: A suds client.
        @type client: L{Client}
        @param ports: A list of I{service} ports.
        @type ports: list
        @param qn: The name of the service.
        @type qn: str
        N(   t   _PortSelector__clientt   _PortSelector__portst   _PortSelector__qn(   R2   Ru   Rƒ   t   qn(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7   w  s    			c         C   s=   |  j  ƒ  } | d k r* |  j d ƒ } n | } t | | ƒ S(   s9  
        Request to access an attribute is forwarded to the
        L{MethodSelector} for either the I{first} port or the
        I{default} port (when specified).
        @param name: The name of a method.
        @type name: str
        @return: A L{MethodSelector}.
        @rtype: L{MethodSelector}. 
        i    N(   t   _PortSelector__dpR0   t   _PortSelector__findRx   (   R2   Rd   Ry   t   m(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR{   „  s
    
c         C   s-   |  j  ƒ  } | d k r% |  j | ƒ S| Sd S(   s¤  
        Provides selection of the I{port} by name (string) or 
        index (integer).  In cases where only (1) port is defined
        or a I{default} has been specified, the request is forwarded
        to the L{MethodSelector}.
        @param name: The name (or index) of a port.
        @type name: (int|str)
        @return: A L{MethodSelector} for the specified port.
        @rtype: L{MethodSelector}. 
        N(   R‹   R0   RŒ   (   R2   Rd   Ry   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR}   •  s    c         C   s	  d } t |  j ƒ s( t d |  j ‚ n  t | t ƒ r{ d |  j | f } y |  j | } WqÀ t k
 rw t | ‚ qÀ XnE d j	 |  j | f ƒ } x* |  j D] } | | j
 k r� | } Pq� q� W| d k rØ t | ‚ n  d j	 |  j | j
 f ƒ } t |  j | j | ƒ S(   sô   
        Find a I{port} by name (string) or index (integer).
        @param name: The name (or index) of a port.
        @type name: (int|str)
        @return: A L{MethodSelector} for the found port.
        @rtype: L{MethodSelector}. 
        s   No ports defined: %ss   %s[%d]t   .N(   R0   R|   Rˆ   R=   R‰   R~   R   R€   t   PortNotFoundRR   Rd   t   MethodSelectorR‡   t   methods(   R2   Rd   Rz   RŠ   R9   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR„   ¦  s$    c         C   s0   |  j  j j } | d k r d S|  j | ƒ Sd S(   s©   
        Get the I{default} port if defined in the I{options}.
        @return: A L{MethodSelector} for the I{default} port.
        @rtype: L{MethodSelector}. 
        N(   R‡   R#   Rz   R0   RŒ   (   R2   t   dp(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __dpÂ  s    (   RF   RG   RU   R7   R{   R}   RŒ   R‹   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR‚   h  s   				R�   c           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s,  
    The B{method} selector is used to select a B{method} by name.
    @ivar __client: A suds client.
    @type __client: L{Client}
    @ivar __methods: A dictionary of methods.
    @type __methods: dict
    @ivar __qn: The I{qualified} name of the method (used for logging).
    @type __qn: str
    c         C   s   | |  _  | |  _ | |  _ d S(   sè   
        @param client: A suds client.
        @type client: L{Client}
        @param methods: A dictionary of methods.
        @type methods: dict
        @param qn: The I{qualified} name of the port.
        @type qn: str
        N(   t   _MethodSelector__clientt   _MethodSelector__methodst   _MethodSelector__qn(   R2   Ru   R‘   RŠ   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7   Ù  s    			c         C   s   |  | S(   sõ   
        Get a method by name and return it in an I{execution wrapper}.
        @param name: The name of a method.
        @type name: str
        @return: An I{execution wrapper} for the specified method name.
        @rtype: L{Method}
        (    (   R2   Rd   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR{   æ  s    c         C   sR   |  j  j | ƒ } | d k rB d j |  j | f ƒ } t | ‚ n  t |  j | ƒ S(   sõ   
        Get a method by name and return it in an I{execution wrapper}.
        @param name: The name of a method.
        @type name: str
        @return: An I{execution wrapper} for the specified method name.
        @rtype: L{Method}
        RŽ   N(   R•   RB   R0   RR   R–   t   MethodNotFoundt   MethodR”   (   R2   Rd   R�   RŠ   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR}   ð  s
    (   RF   RG   RU   R7   R{   R}   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR�   Ï  s   			
R˜   c           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s¨   
    The I{method} (namespace) object.
    @ivar client: A client object.
    @type client: L{Client}
    @ivar method: A I{wsdl} method.
    @type I{wsdl} Method.
    c         C   s   | |  _  | |  _ d S(   s–   
        @param client: A client object.
        @type client: L{Client}
        @param method: A I{raw} method.
        @type I{raw} Method.
        N(   Ru   t   method(   R2   Ru   R™   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7     s    	c         O   sx   |  j  | ƒ } | |  j |  j ƒ } |  j ƒ  sd y | j | | ƒ SWqt t k
 r` } d | f SXn | j | | ƒ Sd S(   s$   
        Invoke the method.
        iô  N(   t   clientclassRu   R™   t   faultst   invoket   WebFault(   R2   t   argsR4   Rš   Ru   Rn   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __call__  s    c         C   s   |  j  j j S(   s    get faults option (   Ru   R#   R›   (   R2   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR›      s    c         C   s   t  j | ƒ r t  St Sd S(   s    get soap client class N(   t	   SimClientt
   simulationt
   SoapClient(   R2   R4   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRš   $  s    (   RF   RG   RU   R7   RŸ   R›   Rš   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR˜   ÿ  s
   	
		R¢   c           B   se   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d
 d „ Z d
 d	 „ Z RS(   sb  
    A lightweight soap based web client B{**not intended for external use}
    @ivar service: The target method.
    @type service: L{Service}
    @ivar method: A target method.
    @type method: L{Method}
    @ivar options: A dictonary of options.
    @type options: dict
    @ivar cookiejar: A cookie jar.
    @type cookiejar: libcookie.CookieJar
    c         C   s.   | |  _  | |  _ | j |  _ t ƒ  |  _ d S(   s—   
        @param client: A suds client.
        @type client: L{Client}
        @param method: A target method.
        @type method: L{Method}
        N(   Ru   R™   R#   R    t	   cookiejar(   R2   Ru   R™   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR7   9  s    		c         C   s¬   t  j ƒ  } | j ƒ  d } |  j j j } | j |  j | | ƒ } | j ƒ  t  j	 j
 d |  j j | ƒ | j ƒ  |  j | ƒ } | j ƒ  t  j	 j
 d |  j j | ƒ | S(   sm  
        Send the required soap message to invoke the specified method
        @param args: A list of args for the method invoked.
        @type args: list
        @param kwargs: Named (keyword) args for the method invoked.
        @type kwargs: dict
        @return: The result of the method invocation.
        @rtype: I{builtin}|I{subclass of} L{Object}
        s   message for '%s' created: %ss   method '%s' invoked: %sN(   RZ   R[   R\   R0   R™   t   bindingt   inputt   get_messageRi   Re   Rj   Rd   t   send(   R2   Rž   R4   Rk   Rm   R¤   t   soapenv(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRœ   E  s$    


		

		c         C   s¦  d } |  j ƒ  } |  j j j } |  j j } |  j j } |  j j } t	 j
 d | | ƒ y÷ |  j | ƒ t |  j j ƒ } | j j d | j ƒ  ƒ | r¨ | j ƒ  } n | j ƒ  } | j d ƒ } | j j d | ƒ t | | ƒ }	 |  j ƒ  |	 _ | j |	 ƒ }
 | j j d |
 j ƒ } | j |
 _ | r9|
 j } n |  j | |
 j ƒ } WnP t k
 r¡} | j d k ryd } q¢t	 j |  j ƒ  ƒ |  j | | ƒ } n X| S(	   sß   
        Send soap message.
        @param soapenv: A soap envelope to send.
        @type soapenv: L{Document}
        @return: The reply to the sent message.
        @rtype: I{builtin} or I{subclass of} L{Object}
        s   sending to (%s)
message:
%st   envelopes   utf-8t   replyiÊ   iÌ   N(   iÊ   iÌ   (   R0   t   locationR™   R¤   R¥   R#   R"   t   retxmlt	   prettyxmlRe   Rj   RC   R   R'   t   messaget
   marshalledR:   t   strt   plaint   encodet   sendingR   t   headersR§   t   receivedRª   t	   succeededR   t   httpcodeRf   t   failed(   R2   R¨   Rm   R«   R¤   R"   R¬   R­   R'   t   requestRª   t   ctxRn   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR§   b  s<    	c         C   sL   |  j  j j } i d d 6| d 6} t | |  j j � } t j d | ƒ | S(   s‚   
        Get http headers or the http/https request.
        @return: A dictionary of header/values.
        @rtype: dict
        s   text/xml; charset=utf-8s   Content-Typet
   SOAPActions   headers = %s(   R™   t   soapt   actionR   R#   R´   Re   Rj   (   R2   R½   t   stockRm   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR´   Œ  s
    c         C   s¡   t  j d | ƒ t |  j j ƒ } t | ƒ d k r_ | j |  j | ƒ \ } } |  j | ƒ n d } | j
 j d | ƒ } | j } |  j j r“ | Sd | f Sd S(   s_  
        Request succeeded, process the reply
        @param binding: The binding to be used to process the reply.
        @type binding: L{bindings.binding.Binding}
        @param reply: The raw reply text.
        @type reply: str
        @return: The method result.
        @rtype: I{builtin}, L{Object}
        @raise WebFault: On server.
        s   http succeeded:
%si    Rª   iÈ   N(   Re   Rj   R   R#   R'   R|   t	   get_replyR™   RD   R0   R®   t   unmarshalledRª   R›   (   R2   R¤   Rª   R'   Rm   Rº   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR¶   ˜  s    	c         C   s»   | j  t | ƒ } } | j j ƒ  } t j d | ƒ | d k rŒ t | ƒ d k r | j | ƒ \ } } |  j | ƒ | | f S| d f Sn  |  j
 j r­ t | | f ƒ ‚ n
 | d f Sd S(   s  
        Request failed, process reply based on reason
        @param binding: The binding to be used to process the reply.
        @type binding: L{suds.bindings.binding.Binding}
        @param error: The http error message
        @type error: L{transport.TransportError}
        s   http failed:
%siô  i    N(   R·   t   tostrt   fpt   readRe   Rj   R|   t	   get_faultRD   R0   R#   R›   R=   (   R2   R¤   Rf   t   statust   reasonRª   t   rR9   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR¸   ±  s    
c         C   s%   t  |  j ƒ } | j d |  j j ƒ S(   NR«   (   R   R#   RB   R™   R«   (   R2   R9   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR«   È  s    c         C   s9   d } |  j  j } | d  k r+ | j | ƒ S| | | <d  S(   NR    (   Ru   R1   R0   RB   (   R2   t   dt   keyR1   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRC   Ì  s
    c         C   s9   d } |  j  j } | d  k r+ | j | ƒ S| | | <d  S(   NR!   (   Ru   R1   R0   RB   (   R2   RÈ   RÉ   R1   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRD   Ô  s
    N(   RF   RG   RU   R7   Rœ   R§   R´   R¶   R¸   R«   R0   RC   RD   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR¢   ,  s   			*				R    c           B   s>   e  Z d  Z d Z e d „  ƒ Z d „  Z d „  Z d „  Z RS(   s<   
    Loopback client used for message/reply simulation.
    t   __injectc         C   s   | j  t j ƒ S(   s;    get whether loopback has been specified in the I{kwargs}. (   t   has_keyR    t   injkey(   R   R4   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR¡   ä  s    c         C   sµ   | |  j  } | j d ƒ } | j d ƒ } | j d ƒ } | d k r� | d k	 re |  j | | | ƒ S| d k	 r~ |  j | ƒ St d ƒ ‚ n  t ƒ  } | j d | ƒ } |  j | ƒ S(   sp  
        Send the required soap message to invoke the specified method
        @param args: A list of args for the method invoked.
        @type args: list
        @param kwargs: Named (keyword) args for the method invoked.
        @type kwargs: dict
        @return: The result of the method invocation.
        @rtype: I{builtin} or I{subclass of} L{Object}
        t   msgRª   t   faults$   (reply|fault) expected when msg=Nonet   stringN(	   RÌ   RB   R0   t   _SimClient__replyt   _SimClient__faultR=   R   t   parseR§   (   R2   Rž   R4   R¡   RÍ   Rª   RÎ   t   sax(    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyRœ   é  s    
	c         C   sV   |  j  j j } | j |  j  | | ƒ } t j d | ƒ |  j  j j } |  j | | ƒ S(   s    simulate the reply s#   inject (simulated) send message:
%s(   R™   R¤   R¥   R¦   Re   Rj   t   outputR¶   (   R2   Rª   Rž   R4   R¤   RÍ   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __reply  s
    c         C   sO   |  j  j j } |  j j rG | j | ƒ \ } } |  j | ƒ d | f Sd Sd S(   s    simulate the (fault) reply iô  N(   iô  N(   R™   R¤   RÔ   R#   R›   RÄ   RD   R0   (   R2   Rª   R¤   RÇ   R9   (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   __fault	  s    
(	   RF   RG   RU   RÌ   RV   R¡   Rœ   RÐ   RÑ   (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyR    Ý  s   		(    (    (    (    (    (    (4   RU   RN   t   suds.metricsRZ   t	   cookielibR    t   suds.readerR   t   suds.transportR   R   t   suds.transport.httpsR   t   suds.servicedefinitionR   R   R   R`   R	   t   suds.resolverR
   t   suds.builderR   t	   suds.wsdlR   t
   suds.cacheR   t   suds.sax.documentR   t   suds.sax.parserR   t   suds.optionsR   t   suds.propertiesR   R   t   copyR   t   suds.pluginR   t   loggingR   RF   Re   Ra   R   R+   R‚   R�   R˜   R¢   R    (    (    (    sE   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/suds/client.pyt   <module>   s@   
›6fg0-±