コード例 #1
0
    def clone(self):
        """
        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}

        """
        class Uninitialized(Client):
            def __init__(self):
                pass

        clone = Uninitialized()
        clone.options = Options()
        cp = Unskin(clone.options)
        mp = Unskin(self.options)
        cp.update(deepcopy(mp))
        clone.wsdl = self.wsdl
        clone.factory = self.factory
        clone.service = ServiceSelector(clone, self.wsdl.services)
        clone.sd = self.sd
        return clone
コード例 #2
0
ファイル: client.py プロジェクト: jonathan-hepp/suds
 def set_options(self, **kwargs):
     """
     Set options.
     @param kwargs: keyword arguments.
     @see: L{Options}
     """
     p = Unskin(self.options)
     p.update(kwargs)
コード例 #3
0
ファイル: client.py プロジェクト: zhangxuan1340/odooX64
 def set_options(self, **kwargs):
     """
     Set options.
     @param kwargs: keyword arguments.
     @see: L{Options}
     """
     p = Unskin(self.options)
     p.update(kwargs)
コード例 #4
0
ファイル: client.py プロジェクト: jonathan-hepp/suds
 def clone(self):
     """
     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}
     """
     class Uninitialized(Client):
         def __init__(self):
             pass
     clone = Uninitialized()
     clone.options = Options()
     cp = Unskin(clone.options)
     mp = Unskin(self.options)
     cp.update(deepcopy(mp))
     clone.wsdl = self.wsdl
     clone.factory = self.factory
     clone.service = ServiceSelector(clone, self.wsdl.services)
     clone.sd = self.sd
     clone.messages = dict(tx=None, rx=None)
     return clone
コード例 #5
0
 def __deepcopy__(self, memo={}):
     clone = self.__class__()
     p = Unskin(self.options)
     cp = Unskin(clone.options)
     cp.update(p)
     return clone
コード例 #6
0
ファイル: http.py プロジェクト: EASYMARKETING/suds-jurko
 def __deepcopy__(self, memo={}):
     clone = self.__class__()
     p = Unskin(self.options)
     cp = Unskin(clone.options)
     cp.update(p)
     return clone
コード例 #7
0
ファイル: client.py プロジェクト: rzenker/psphere-daemon
 def __init__(self, server=None, username=None, password=None,
              wsdl_location="local", timeout=30, init_clone=False, clone=None):
     #self._init_logging()
     self._logged_in = False
     if server is None:
         server = _config_value("general", "server")
     if username is None:
         username = _config_value("general", "username")
     if password is None:
         password = _config_value("general", "password")
     if server is None:
         raise ConfigError("server must be set in config file or Client()")
     if username is None:
         raise ConfigError("username must be set in config file or Client()")
     if password is None:
         raise ConfigError("password must be set in config file or Client()")
     self.server = server
     self.username = username
     self.password = password
     url = "https://%s/sdk" % self.server
     if wsdl_location == "local":
         current_path = os.path.abspath(os.path.dirname(__file__))            
         current_path = current_path.replace('\\', '/')
         if not current_path.startswith('/') :
             current_path = '/' + current_path
         if current_path.endswith('/') :
             current_path = current_path[:-1]
         wsdl_uri = ("file://%s/wsdl/vimService.wsdl" % current_path)
     elif wsdl_location == "remote":
         wsdl_uri = url + "/vimService.wsdl"
     else:
         print("FATAL: wsdl_location must be \"local\" or \"remote\"")
         sys.exit(1)
     # Init the base class
     if clone:
         self.sd=clone.sd
         self.options = Options()
         cp = Unskin(self.options)
         mp = Unskin(clone.options)
         cp.update(deepcopy(mp))
         self.wsdl = clone.wsdl
         self.factory = clone.factory
         self.service = ServiceSelector(self, clone.wsdl.services)
         self.messages = dict(tx=None, rx=None)
     else:
         try:
             suds.client.Client.__init__(self, wsdl_uri)
         except URLError:
             logger.critical("Failed to connect to %s" % self.server)
             raise
         except IOError:
             logger.critical("Failed to load the local WSDL from %s" % wsdl_uri)
             raise
         except TransportError:
             logger.critical("Failed to load the remote WSDL from %s" % wsdl_uri)
             raise
     if init_clone:
         return
     self.options.transport.options.timeout = timeout
     self.set_options(location=url)
     mo_ref = soap.ManagedObjectReference("ServiceInstance",
                                          "ServiceInstance")
     self.si = ServiceInstance(mo_ref, self) 
     try:
         self.sc = self.si.RetrieveServiceContent()
     except URLError, e:
         #print("Failed to connect to %s" % self.server)
         #print("urllib2 said: %s" % e.reason) 
         #sys.exit(1)
         raise