def __loadDriverProperties(self, node):
     for properties in node.getElementsByTagName("properties"):
         
         for property in properties.getElementsByTagName("property"):
             name = str(property.getAttribute("name"))
             if name is None or len(name)==0:
                 raise ConfigError("Cannot find driver property name")
             for pchild in property.childNodes:
                 if pchild.nodeType == Node.TEXT_NODE:
                     value = pchild.data
                     if value is None or len(value)==0:
                         raise ConfigError("Cannot find driver property value")
                     self[name] = str(value)
                     break
예제 #2
0
    def __loadExecutorConfig(self, reader, node):
        elements = node.getElementsByTagName("executor")
        if elements is None or len(elements)==0:
            return
        self.__executorConfig = {}
        # First get the common defaults
        commons = reader.getSection(EXECUTOR)
        if commons:
            self.__executorConfig.update(commons)
            
        # Now override with context defaults
        for database in elements:
            for property in database.getElementsByTagName("property"):
                name = str(property.getAttribute("name"))
                if name is None or len(name)==0:
                    raise ConfigError("Cannot find property name")
                for pchild in property.childNodes:
                    if pchild.nodeType == Node.TEXT_NODE:
                        try:
                            value = eval(str(pchild.data))
                            self.__executorConfig[name] = value
                        except:
                            LOG("Cannot process executor parameter " + name, LOG_ERROR)

        for param in self.__executorConfig:
            LOG("Executor parameter " + param + "=" + str(self.__executorConfig[param]), level = LOG_CNFG)
예제 #3
0
 def __loadDriverConfig(self, node):
     elements = node.getElementsByTagName("driverconfig")
     if elements is None or len(elements)==0:
         raise ConfigError("Could not find driver information for context")
     for driverinfo in elements:
         for property in driverinfo.getElementsByTagName("property"):
             name = str(property.getAttribute("name"))
             if name is None or len(name)==0:
                 raise ConfigError("Cannot find driverconfig property name")
             for pchild in property.childNodes:
                 if pchild.nodeType == Node.TEXT_NODE:
                     value = pchild.data
                     if value is None or len(value)==0:
                         raise ConfigError("Cannot find driverinfo property value")
                     self.__driverConfig[name] = str(value)
                     break
예제 #4
0
파일: socks5.py 프로젝트: zry69p/TcpRoute
    def __init__(self, config):
        UpstreamBase.__init__(self, config)

        self.socks5_hostname = config.get('host')
        self.socks5_port = config.get('port')

        if self.socks5_hostname is None or self.socks5_port is None:
            ms = u'[配置错误] host、port 不能为空! upstream-type:%s' % self.type
            raise ConfigError(ms)

        class socket(SocketBase):
            # TODO: 停掉一些不支持方法。
            def __init__(self,
                         family=_socket.AF_INET,
                         type=_socket.SOCK_STREAM,
                         proto=0,
                         _sock=None):
                if _sock is None:
                    _sock = socket.upstream.socket(family=family,
                                                   type=type,
                                                   proto=proto)
                SocketBase.__init__(self, _sock)

        socket.socks5_hostname = self.socks5_hostname
        socket.socks5_port = self.socks5_port
        socket.upstream = self.upstream

        self.socket = socket
 def __init__(self, configFile):
     if not os.path.exists(configFile):
         raise ConfigError("Cannot find driver configuration file: " + configFile) 
     document = xml.dom.minidom.parse(configFile)
     node = document.getElementsByTagName(DRIVER)[0]
     ConfigItem.__init__(self,node, PROPERTIES)
     # Load the driver properties node
     self.__loadDriverProperties(node)
 def __loadDatabases(self, node):
     elements = node.getElementsByTagName("databases")
     if elements is None or len(elements) == 0:
         raise ConfigError(
             "Could not find database information for context")
     for database in elements:
         for property in database.getElementsByTagName("database"):
             name = str(property.getAttribute("name"))
             location = str(property.getAttribute("location"))
             if name is None or len(name) == 0:
                 raise ConfigError("Cannot find database name")
             if location is None or len(location) == 0:
                 raise ConfigError("Cannot find database location")
             for pchild in property.childNodes:
                 if pchild.nodeType == Node.TEXT_NODE:
                     filename = pchild.data
                     if filename is None or len(filename) == 0:
                         raise ConfigError(
                             "Cannot find db info property filename")
                     self.__databaseInfo[name] = [
                         str(location), str(filename)
                     ]
                     break
예제 #7
0
 def __init__(self, reader, configFile):
     if not os.path.exists(configFile):
         raise ConfigError("Cannot find context configuration file: " + configFile) 
     document = xml.dom.minidom.parse(configFile)
     node = document.getElementsByTagName(CONTEXT)[0]
     ConfigItem.__init__(self,node,PROPERTIES)
     self.__driverConfig = {}
     self.__databaseInfo = {}
     self.__databaseLocations = {}
     self.__languageConfig = {}
     self.__functionConfig = {}
     self.__executorConfig = {}
     self.__loadDriverConfig(node)
     self.__loadDatabases(node)
     self.__loadLanguage(reader, node)
     self.__loadExecutorConfig(reader, node)