本文整理汇总了Python中java.util.Properties.put方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.put方法的具体用法?Python Properties.put怎么用?Python Properties.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DiscoveryMain
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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)
示例2: main
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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()
示例3: createSQLServerConnection
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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)
示例4: DiscoveryMain
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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())
示例5: _load_config
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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
示例6: _createSshClient
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
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())
示例7: properties
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def properties(props_dict):
"""
make a java.util.Properties from a python dict
"""
p = Properties()
for k in props_dict.iterkeys():
v = props_dict[k]
if isinstance(v,bool):
if v:
v = 'true'
else:
v = 'false'
p.put(k,v)
return p
示例8: getDBConnection
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def getDBConnection(userName, password, driverName, connectionURL):
"""
Return PyConnection to the database (see Jython's zxJDBC description)
@param userName: the username to connect to DB with
@param password: the password to connect to DB with
@param driverName: name of the driver to connect through
@return: com.ziclix.python.sql.PyConnection
"""
jdbcDriver = Class.forName(driverName, 1,
Thread.currentThread().getContextClassLoader()).newInstance()
props = Properties()
props.put('user', userName)
props.put('password', password)
return PyConnection(jdbcDriver.connect(connectionURL, props))
示例9: load_context
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def load_context(self):
""" Creates and configures the context. """
if not self.__context: # Avoid loading the same context twice
endpoint = "http://" + self.__config.address + "/api"
config = Properties()
config.put("abiquo.endpoint", endpoint)
config.put("jclouds.max-retries", "0") # Do not retry on 5xx errors
config.put("jclouds.max-redirects", "0") # Do not follow redirects on 3xx responses
# Wait at most 2 minutes in Machine discovery
config.put("jclouds.timeouts.InfrastructureClient.discoverSingleMachine", "120000")
config.put("jclouds.timeouts.InfrastructureClient.discoverMultipleMachines", "120000")
print "Connecting to: %s" % endpoint
self.__context = AbiquoContextFactory().createContext(self.__config.user, self.__config.password, config)
atexit.register(self.__del__) # Close context automatically when exiting
return self.__context
示例10: DiscoveryMain
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def DiscoveryMain(Framework):
OSHVResult = ObjectStateHolderVector()
logger.debug(" ###### Connecting to EView 400 client")
codePage = Framework.getCodePage()
properties = Properties()
properties.put(BaseAgent.ENCODING, codePage)
localshell = None
try:
client = Framework.createClient(ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
localshell = shellutils.ShellUtils(client, properties, ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME)
except Exception, ex:
exInfo = ex.getMessage()
errormessages.resolveAndReport(exInfo, ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME, Framework)
logger.error(exInfo)
示例11: createOracleConnection
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def createOracleConnection(serverName, port, sid, userName, password):
try:
url = "jdbc:mercury:oracle://" + serverName + ":" + str(port) + ";databaseName=" + sid
driverName = "com.mercury.jdbc.oracle.OracleDriver"
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)
示例12: DiscoveryMain
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def DiscoveryMain(Framework):
Framework = jee_connection.EnhancedFramework(Framework)
"""
create client
make discovery of domain and servers
"""
platform = jee.Platform.WEBSPHERE
properties = Properties()
properties.put(
"server_was_config",
"services:connectors:SOAP_CONNECTOR_ADDRESS:host,services:connectors:SOAP_CONNECTOR_ADDRESS:port,clusterName",
)
properties.put("datasource_was_config", "jndiName,URL,propertySet,connectionPool")
try:
client = Framework.createClient(properties)
except (Exception, JException), exc:
logger.warnException("Failed to establish connection")
jee_connection.reportError(Framework, str(exc), platform.getName())
示例13: _createClient
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def _createClient(framework, protocol):
'''
@types: Framework, str -> Client
@raise flow.ConnectionException
'''
codePage = framework.getCodePage()
properties = Properties()
properties.put(BaseAgent.ENCODING, codePage)
LOCAL_SHELL = ClientsConsts.LOCAL_SHELL_PROTOCOL_NAME
try:
client = (_isLocalShellRequired(protocol)
and framework.createClient(LOCAL_SHELL)
or framework.createClient(properties))
return client
except JException, je:
raise flow.ConnectionException(je.getMessage())
示例14: go
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def go(self):
props = Properties()
props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory")
props.put(Context.PROVIDER_URL,"iiop://127.0.0.1:3700")
context = InitialContext(props)
tfactory = context.lookup("jms/MyConnectionFactory")
tconnection = tfactory.createTopicConnection('receiver', 'receiver')
tconnection.setClientID('myClientId:recv')
tsession = tconnection.createTopicSession(False, Session.AUTO_ACKNOWLEDGE)
subscriber = tsession.createDurableSubscriber(context.lookup("jms/MyFirstTopic"), 'mysub')
subscriber.setMessageListener(self)
tconnection.start()
while True:
time.sleep(1)
示例15: DiscoveryMain
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import put [as 别名]
def DiscoveryMain(Framework):
protocolName = Framework.getDestinationAttribute('Protocol')
OSHVResult = ObjectStateHolderVector()
try:
HOST_IP = Framework.getDestinationAttribute('ip_address')
MANAGER_PORT = Framework.getParameter('port')
shellUtils = None
try:
codePage = Framework.getCodePage()
properties = Properties()
properties.put( BaseAgent.ENCODING, codePage)
shellUtils = shellutils.ShellUtils(Framework, properties)
discoveredOracleHomes = []
if shellUtils.isWinOs():
discoveredOracleHomes = OracleIASOracleHomeWindowsDiscoverer(shellUtils).discover()
else:
discoveredOracleHomes = OracleIASOracleHomeDiscoverer(shellUtils).discover()
logger.debug('Discovered Oracle Homes from the running processes: %s' % discoveredOracleHomes)
for oracleHomePath in discoveredOracleHomes:
pathExists = 0
if oracleHomePath and oracleHomePath.strip():
try:
opmnXML = shellUtils.safecat(str(oracleHomePath) + '/opmn/conf/opmn.xml')
parseOpmnXml(opmnXML, HOST_IP, oracleHomePath, MANAGER_PORT, shellUtils, OSHVResult, Framework)
pathExists = 1
except:
logger.debugException('')
if not pathExists:
Framework.reportWarning("Can't retrieve opmn.xml content.")
if OSHVResult.size() == 0:
Framework.reportError("Failed to discover Oracle AS")
finally:
shellUtils and shellUtils.closeClient()
except JavaException, ex:
logger.debugException('')
errormessages.resolveAndReport(ex.getMessage(), protocolName, Framework)