当前位置: 首页>>代码示例>>Python>>正文


Python util.Properties类代码示例

本文整理汇总了Python中java.util.Properties的典型用法代码示例。如果您正苦于以下问题:Python Properties类的具体用法?Python Properties怎么用?Python Properties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Properties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

def main():
  # Create the new layer
  newProjection = currentView().getProjectionCode()
  newLayerSchema = createSchema()
  newLayerSchema.append("ID","INTEGER")
  newLayerSchema.append("GEOMETRY","GEOMETRY")
  geometryType = getGeometryType(POINT,D2)
  newLayerSchema.get("GEOMETRY").setGeometryType(geometryType)
  newLayerName = "/APLICACIONES/GIS/gvSIG-desktop-2.2.0/mynewlayer.shp"
  newLayer = createShape(newLayerSchema,newLayerName,CRS=newProjection,geometryType=POINT)
  # Connect to the database
  props = Properties()
  props.put("user","YOUR_USER")
  props.put("password","YOUR_PASSWD")
  db = Driver().connect("jdbc:postgresql://localhost/YOUR_DB", props)
  # Get geometry info from database and insert it into the new layer
  c = db.createStatement()
  rs = c.executeQuery("select table.id, ST_X(table.coordinatesxy),ST_Y(table.coordenatesxy) from YOUR_TABLES where YOUR_WHERE_CLAUSE")
  data = {}
  while rs.next():
    id = rs.getInt(1)
    newX = rs.getObject(2)
    newY = rs.getObject(3)
    print(id,newX,newY)
    newGeom = createPoint(newX,newY)
    dbValues = {"ID":id,"GEOMETRY":newGeom}
    newLayer.append(dbValues)
  rs.close()
  c.close()
  db.close()
  
  currentView().addLayer(newLayer)
  newLayer.commit()
开发者ID:WeekendArchaeo,项目名称:python,代码行数:33,代码来源:dbaccess.py

示例2: DiscoveryMain

def DiscoveryMain(Framework):
    Framework = jee_connection.EnhancedFramework(Framework)
    isAppResourcesDiscoveryEnabled = _asBoolean(Framework.getParameter('discoverAppResources'))
    isJmsResourcesDiscoveryEnabled = _asBoolean(Framework.getParameter('discoverJMSResources'))

    platform = jee.Platform.JBOSS
    try:
        r'''In addition to the credentials we have to specify port number and
        version of the platform.
        Credentials may be defined without such information that is very important
        for establishing connections
        '''
        port = entity.WeakNumeric(int)
        port.set(Framework.getDestinationAttribute('port'))
        version = Framework.getDestinationAttribute('version')

        properties = Properties()
        properties.put(CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, str(port.value()))
        properties.put(AgentConstants.VERSION_PROPERTY, version)

        client = Framework.createClient(properties)

        jmxProvider = jmx.Provider(client)
    except (Exception, JException), exc:
        logger.warnException("Failed to establish connection")
        jee_connection.reportError(Framework, str(exc), platform.getName())
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:26,代码来源:JMX_J2EE_JBoss.py

示例3: DiscoveryMain

def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    CmdbOIDFactory = CmdbObjectID.Factory
    hostId = CmdbOIDFactory.restoreObjectID(Framework.getDestinationAttribute('hostId'))
    sqlServerId = CmdbOIDFactory.restoreObjectID(Framework.getDestinationAttribute('id'))

    try:
        props = Properties()
 
        instance_name = Framework.getDestinationAttribute('instanceName')
        if instance_name and instance_name != 'NA' and instance_name.find('\\') != -1:
            props.setProperty('sqlprotocol_dbsid', instance_name[instance_name.find('\\')+1:])
        mssqlClient = Framework.createClient(props)
        connection = SqlServerConnection.ClientSqlServerConnection(mssqlClient)
        logger.debug("got connection")
        discoveryOptions = SqlServerDiscoveryOptions()
        discoveryOptions.discoverConfigs = Boolean.parseBoolean(Framework.getParameter('discoverConfigs'))
        discoveryOptions.discoverDbUser = Boolean.parseBoolean(Framework.getParameter('discoverDbUser'))
        discoveryOptions.discoverSqlFile = Boolean.parseBoolean(Framework.getParameter('discoverSqlFile'))
        discoveryOptions.discoverSqlJob = Boolean.parseBoolean(Framework.getParameter('discoverSqlJob'))
        discoveryOptions.discoverProcedures = Boolean.parseBoolean(Framework.getParameter('discoverStoredProcedures'))
        discoveryOptions.discoverInternalProcedures = Boolean.parseBoolean(Framework.getParameter('discoverInternalProcedures'))

        sqlServer = SqlServer.SqlServer(connection, discoveryOptions)
        OSHVResult.addAll(sqlServer.collectData(hostId, sqlServerId, discoveryOptions.discoverConfigs))
        mssqlClient.close()
    except JavaException, ex:
        strException = ex.getMessage()
        errormessages.resolveAndReport(strException, ClientsConsts.SQL_PROTOCOL_NAME, Framework)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:29,代码来源:MSSqlScript.py

示例4: createSQLServerConnection

def createSQLServerConnection(serverName, port, schemaName, userName, password):
    try:
        url = (
            "jdbc:mercury:sqlserver://"
            + serverName
            + ":"
            + str(port)
            + ";DatabaseName="
            + schemaName
            + ";allowPortWithNamedInstance=true"
        )
        logger.info("URL: ", url)
        driverName = "com.mercury.jdbc.sqlserver.SQLServerDriver"
        props = Properties()
        props.put("user", userName)
        props.put("password", password)
        cl = Class.forName(driverName, 1, Thread.currentThread().getContextClassLoader())
        jdbcDriver = cl.newInstance()
        conn = jdbcDriver.connect(url, props)
        unlockConnection(conn)
        return conn
    except Exception, e:
        logger.error("setConnection: ")
        logger.error(e)
        raise Exception(e)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:25,代码来源:pushDBScript.py

示例5: DiscoveryMain

def DiscoveryMain(Framework):
	OSHVResult = ObjectStateHolderVector()	
	ipAddress = Framework.getDestinationAttribute('ip_address')
	credentialsId = Framework.getDestinationAttribute('credentialsId')
	hostId = Framework.getDestinationAttribute('hostId')
	
	hostOsh = ms_exchange_utils.restoreHostById(hostId)
	hostName = Framework.getDestinationAttribute('hostName')	
	if not hostName or hostName == 'N/A':
		hostName = ms_exchange_utils.getHostNameFromWmi(Framework)
	
	if not hostName:
		errobj = errorobject.createError(errorcodes.FAILED_GETTING_INFORMATION_NO_PROTOCOL, ['host name'], 'Failed to obtain host name')
		logger.reportErrorObject(errobj)
		return
	
	props = Properties()
	props.put(AgentConstants.PROP_WMI_NAMESPACE, WMI_NAMESPACE)	
	try:
		wmiClient = Framework.createClient(props)
		wmiAgent = WmiAgent(wmiClient, Framework)
		try:
			discoverExchangeServer(wmiAgent, ipAddress, credentialsId, OSHVResult, Framework, hostOsh, hostName)
		finally:			
			wmiClient.close()
	except Exception, ex:
		message = ex.getMessage()
		if (re.search("Invalid\sclass", message)):
			message = 'Unable to get Exchange data from WMI'
		logger.debugException(message)
		errormessages.resolveAndReport(message, WMI_PROTOCOL, Framework)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:31,代码来源:ms_exchange_connection_by_wmi.py

示例6: connectToDb

def connectToDb(localFramework, ipAddress, dbPort):
    try:
        theDbClient = None
        ## Get protocols
        protocols = localFramework.getAvailableProtocols(ipAddress, ClientsConsts.SQL_PROTOCOL_NAME)
        for protocolID in protocols:
            ## If this protocol entry is not for a Sybase DB, ignore it
            if localFramework.getProtocolProperty(protocolID, CollectorsConstants.SQL_PROTOCOL_ATTRIBUTE_DBTYPE) != 'Sybase':
                debugPrint(5, '[' + SCRIPT_NAME + ':DiscoveryMain] Ignoring non Sybase protocol entry...')
                continue
            ## Don't bother reconnecting if a connection has already been established
            if not theDbClient:
                ## Set DB properties
                dbConnectionProperties = Properties()
                dbConnectionProperties.setProperty(CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, dbPort)
                # Establish JDBC connection
                debugPrint(5, '[' + SCRIPT_NAME + ':connectToDb] Attempting connection to CiscoWorks database at port <%s>...' % dbPort)
                try:
                    theDbClient = localFramework.createClient(protocolID, dbConnectionProperties)
                except:
                    theDbClient and theDBClient.close()
        return theDbClient
    except:
        excInfo = logger.prepareJythonStackTrace('')
        logger.warn('[' + SCRIPT_NAME + ':connectToDb] Exception: <%s>' % excInfo)
        pass
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:26,代码来源:ciscoworks_utils.py

示例7: _sapJmxConnect

def _sapJmxConnect(credId, ip, Framework):
    r'''@types: str, str, Framework -> Result
    '''
    message = None
    status = False
    for version in SAPJmxAgent.getAvailableVersions():
        props = Properties()
        props.setProperty(AgentConstants.VERSION_PROPERTY, version)
        logger.debug('Trying to connect to ip=%s by \'%s\' '\
                     'protocol (assuming version %s)...' % (ip,
                                                             _PROTOCOL_NAME,
                                                             version))
        try:
            sap = Framework.getAgent(AgentConstants.SAP_JMX_AGENT,
                                     ip, credId, props)
            sap.connect()

        except:
            message = 'error: %s' % sys.exc_info()[1]
            logger.debug('connection to ip=%s by \'%s\' '\
                         'protocol failed. %s' % (ip,
                                                  _PROTOCOL_NAME, message))
            continue
        else:
            logger.debug('connection to ip=%s by \'%s\' '\
                         'protocol is successful' % (ip, _PROTOCOL_NAME))
            status = True
            break
        finally:
            sap and sap.disconnect()
    return Result(status, message)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:31,代码来源:sapjmx_check_credential.py

示例8: getShellUtils

def getShellUtils(Framework, shellName, credentials, ip, codepage, warningsList, errorsList):
    failedPorts = []
    #check which credential is good for the shell:
    client = None
    for credentialId in credentials:
        try:
            port = None
            props = Properties()
            props.setProperty(BaseAgent.ENCODING, codepage)
            props.setProperty(CollectorsConstants.ATTR_CREDENTIALS_ID, credentialId)
            logger.debug('try credential %s' % credentialId)
            client = Framework.createClient(props)
            shellUtils = shellutils.ShellUtils(client, None, shellName)
            if shellUtils:
                return (shellUtils, credentialId)
        except IOException, ioEx:
            strException = str(ioEx.getMessage())
            errormessages.resolveAndAddToObjectsCollections(strException, shellName, warningsList, errorsList)
            if client:
                client.close()
            # we failed to connect - add the problematic port to failedPorts list
            if port:
                failedPorts.append(port)
        except (UnsupportedEncodingException, UnsupportedCharsetException), ex:
            strException = str(ex.getClass().getName())
            shouldStop = errormessages.resolveAndAddToObjectsCollections(strException, shellName, warningsList, errorsList)
            if client:
                client.close()
            if shouldStop:
                return (None, None)
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:30,代码来源:Host_Connection_by_powershell.py

示例9: __createConnection

 def __createConnection(self):
     "create database"
     self.__connection = None
     try:
         logger.info("RegisterJDBC driver: com.mysql.jdbc.Driver")
         driver = com.mysql.jdbc.Driver.newInstance()
         if driver and driver.acceptsURL(self.__rootJdbcUrl):
             props = Properties()
             props.setProperty("user", "root")
             props.setProperty("password", self.__rootPwd)
        
             logger.info("Create JDBC connection:" + self.__rootJdbcUrl)
             self.__connection = driver.connect(self.__rootJdbcUrl, props)
         if self.__connection:
             logger.info("Create db select prepared statement")
             self.__dbstmt = self.__connection.prepareStatement("show databases;")
             
             rs = self.__dbstmt.executeQuery()
             self.__databases = []
             while (rs.next()):
                 db = rs.getString(1)
                 self.__databases.append(db)
     except:
         self.__connection = None
         type, value, traceback = sys.exc_info()
         logger.severe("create connection error:" + `value`)
开发者ID:ajayvohra2005,项目名称:mysql-ce-enabler,代码行数:26,代码来源:MySQLServer.py

示例10: _createSshClient

def _createSshClient(framework, cred_id, port=1000):
    try:
        from java.util import Properties
        props = Properties()
        props.put(Protocol.PROTOCOL_ATTRIBUTE_PORT, str(port))
        return framework.createClient(cred_id, props)
    except JException, je:
        raise ovm_flow.ConnectionException(je.getMessage())
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:8,代码来源:manager_by_ovm_cli.py

示例11: read_versions

 def read_versions(self):
     versionsProperties = Properties()
     fin = FileInputStream(self.versionsFileName)
     versionsProperties.load(fin)
     scriptVersion = versionsProperties.getProperty("script")
     toolsVersion = versionsProperties.getProperty("tools")
     fin.close()
     return scriptVersion, toolsVersion
开发者ID:alex85k,项目名称:qat_script,代码行数:8,代码来源:config_reader.py

示例12: loadProperties

def loadProperties(fileName):
	properties = Properties()
	input = FileInputStream(fileName)
	properties.load(input)
	input.close()
	result= {}
	for entry in properties.entrySet(): result[entry.key] = entry.value
	return result
开发者ID:osanchezhuerta,项目名称:weblogicjmsclustered-module,代码行数:8,代码来源:weblogicjms-cluster.py

示例13: load_redback_registry

def load_redback_registry():
    reg = Properties()
    reg_file = 'redback.properties'
    if os.path.isfile(reg_file):
        reg_fd = FileInputStream(reg_file)
        reg.load(reg_fd)
        reg_fd.close()
    return reg
开发者ID:Integral-Technology-Solutions,项目名称:ConfigNOW,代码行数:8,代码来源:redback.py

示例14: _buildConnectionProps

def _buildConnectionProps(instNr, connClient=None):
    props = Properties()
    logger.debug('Connecting to a SAP instance number:', str(instNr))
    props.setProperty(Protocol.SAP_PROTOCOL_ATTRIBUTE_SYSNUMBER, instNr)
    if connClient:
        logger.debug('Connecting to a SAP system with client: %s' % connClient)
        props.setProperty(Protocol.SAP_PROTOCOL_ATTRIBUTE_CLIENT, connClient)
    return props
开发者ID:ddonnelly19,项目名称:dd-git,代码行数:8,代码来源:sap_solman_topology.py

示例15: _load_config

 def _load_config(self):
     """ Returns the default jclouds client configuration. """
     endpoint = "http://" + self.__config.address + "/api"
     props = Properties()
     props.put("abiquo.endpoint", endpoint)
     [props.put(name, value)
             for (name, value) in self.__config.client_config]
     return props
开发者ID:Marc-Morata-Fite,项目名称:kahuna,代码行数:8,代码来源:session.py


注:本文中的java.util.Properties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。