本文整理汇总了Python中java.lang.Integer.parseInt方法的典型用法代码示例。如果您正苦于以下问题:Python Integer.parseInt方法的具体用法?Python Integer.parseInt怎么用?Python Integer.parseInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Integer
的用法示例。
在下文中一共展示了Integer.parseInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_zones
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def load_zones(app):
"""Read favourite zones
"""
app.zones = []
favZonesDir = File(File.separator.join([app.SCRIPTDIR,
"configuration",
"favourite_zones"]))
for zoneFile in sorted(favZonesDir.listFiles()):
name = zoneFile.getName()[:-4]
fileName = zoneFile.getPath()
zoneFile = open(fileName)
fileContent = zoneFile.read()
if len(fileContent.split("|")) == 2:
geomString, country = fileContent.split("|")
country = country.upper()
else:
geomString = fileContent
country = ""
zoneFile.close()
zType = "rectangle"
try:
Integer.parseInt(geomString[0])
except NumberFormatException:
zType = "polygon"
zone = Zone(app, name, zType, geomString, country)
app.zones.append(zone)
if name == app.favZoneName:
app.favZone = zone
#Fav zone is active but its data is missing
if app.favouriteZoneStatus and app.favZone is None:
app.favouriteZoneStatus = False
示例2: retrieve_an_archive
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def retrieve_an_archive(cust_id, archive_name, user_id, chunk_hint, file_name, output_ids):
print "\nretrieve_a_chunk routine:: output file_name is :", file_name
try:
outfile_stream = FileOutputStream(file_name)
except:
print "retrieve_a_chunk routine:: Failed to open output stream on file : ", file_name, "..returning"
return None
# retrieve data
mc = ManagementContainer.getInstance()
rm = mc.getRecoveryManager()
l_cust_id = Integer.parseInt(cust_id);
l_user_id = Integer.parseInt(user_id);
sosw = IRecoveryManager.SimpleOutputStreamWrapper(outfile_stream)
try:
rm.createPerUserActiveRecoveryArchiveFile(l_cust_id, archive_name, l_user_id, sosw, chunk_hint)
except:
print "retrieve_a_chunk routine:: `Exception while creating active recovery archive..returning"
sys.exc_info()[1].printStackTrace()
print("*** print_exc:")
traceback.print_exc(file=sys.stdout)
outfile_stream.close()
raise
outfile_stream.close()
return get_chunk_hint(file_name, output_ids)
示例3: test_number_format
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def test_number_format(self):
try:
Integer.parseInt('asdf')
except Exception as ex:
if jep.USE_MAPPED_EXCEPTIONS:
self.assertTrue(isinstance(ex, jep.NumberFormatException))
else:
self.assertEquals(ex.java_name, 'java.lang.NumberFormatException')
示例4: warn
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def warn(self, e):
errorNumber = self.textfield.getText()
if errorNumber == "":
self.textfield.setBorder(self.defaultborder)
return
try:
Integer.parseInt(errorNumber)
except NumberFormatException:
self.textfield.setBorder(BorderFactory.createLineBorder(Color.RED, 1))
return
self.textfield.setBorder(BorderFactory.createLineBorder(Color.GREEN, 1))
示例5: initializeServices
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def initializeServices(self):
self.updateUtilizationInfo = 1
self.discoverDependLinks = Boolean.parseBoolean(self.getParameterValue('discoverDependLinks'))
self.onlyHostDependLinks = 0
self.ignoreUnackedTcpConn = 0
self.shouldCountClients = 1
self.discoverIP = self.Framework.getDestinationAttribute('ip_address')
self.hostId = self.Framework.getDestinationAttribute('hostId')
self.minimalClients = Integer.parseInt(self.Framework.getParameter('minClients'))
self.minimalOctets = Integer.parseInt(self.Framework.getParameter('minOctets'))
self.minimalPackets = Integer.parseInt(self.Framework.getParameter('minPackets'))
self.protocols = self.Framework.getParameter('protocols')
self.disregardListenPorts = Boolean.parseBoolean(self.getParameterValue('disregardListenPorts'))
示例6: servicesPorts
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def servicesPorts(self, onlyKnownPorts = 1):
services = self.Framework.getParameter('services')
if logger.isDebugEnabled():
logger.debug('Requested services:', services)
if (services == None) or (len(services) == 0) or (services == '*'):
if onlyKnownPorts:
portsInfo = self.knownPortsConfigFile.getTcpPorts()
services = ''
delimiter = ''
for info in portsInfo:
services = services + delimiter + str(info.getPortNumber())
delimiter = ','
if len(services) == 0:
return services
else:
return ''
names = services.split(',')
ports = ''
delimiter = ''
for name in names:
portNums = self.knownPortsConfigFile.getPortByName(name)
if (portNums == None) or (len(portNums) == 0):
try:
portNums = [Integer.parseInt(name)]
except:
logger.debug('Failed to resolve service port number:', name)
continue
for portNum in portNums:
ports = ports + delimiter + str(portNum)
delimiter = ','
if logger.isDebugEnabled():
logger.debug('Requested services ports:', ports)
return ports
示例7: convertToIp
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def convertToIp(self, encodedIp):
#TODO: Make it Python
ipParts = []
for i in range(4):
ipParts.append(encodedIp[:2])
encodedIp = encodedIp[2:]
ip = ''
for ipPart in ipParts:
ip += str(Integer.parseInt(ipPart, 16)) + '.'
ip = ip[:len(ip)-1]
return ip
示例8: updateWithPrePostScriptCmd
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def updateWithPrePostScriptCmd(Framework, commandLine):
isPrePostScriptAllowed = Boolean.parseBoolean(Framework.getParameter('IsPrePostScriptAllowed'))
prePostScriptExecTimeout = Integer.parseInt(Framework.getParameter('PrePostScriptExecTimeout'))
logger.debug("isPrePostScriptAllowed:", isPrePostScriptAllowed)
if isPrePostScriptAllowed:
deltaParams = ' -scripts:. '
scriptTimeoutParam = ''
if prePostScriptExecTimeout > 0:
scriptTimeoutParam = ' -scriptstimeout:' + str(prePostScriptExecTimeout) + ' '
index = String(commandLine).indexOf(ENTERPRISE_MODE) + String(ENTERPRISE_MODE).length()
commandLine = commandLine[0:index] + deltaParams + scriptTimeoutParam + commandLine[index + 1:]
logger.debug('After apply pre/post scripts, scanner execution command updated to ', commandLine)
return commandLine
示例9: parseMappingString
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def parseMappingString(mappingString):
bitPositions = TreeSet()
bytesNumber = len(mappingString) / SYMBOLS_PER_BYTE
for i in range(bytesNumber):
currentPosition = i * SYMBOLS_PER_BYTE
currentByteString = mappingString[currentPosition : currentPosition + SYMBOLS_PER_BYTE]
currentByte = Integer.parseInt(currentByteString, 16)
for j in range(BITS_IN_SYMBOL):
if (currentByte & 1) == 1:
bitPositions.add(i * BITS_IN_SYMBOL + BITS_IN_SYMBOL - j)
currentByte = currentByte >> 1
return list(ArrayList(bitPositions))
示例10: read_gui
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def read_gui(self):
"""Read preferences from gui
"""
username = self.userTextField.getText()
level = self.levelsCombo.getSelectedItem()
limit = self.limitTextField.getText()
try:
limit = Integer.parseInt(limit)
if limit > 500:
limit = 500
limit = str(limit)
except NumberFormatException:
limit = ""
preferences = {"username": username.strip(),
"level": level,
"limit": limit}
return preferences
示例11: getRequestedPortsSet
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def getRequestedPortsSet(self):
services = self.Framework.getParameter('P2PServerPorts')
if logger.isDebugEnabled():
logger.debug('Requested services:', services)
if (services == None) or (len(services) == 0) or (services == '*'):
return None
names = services.split(',')
portsSet = HashSet()
for name in names:
portNums = self.knownPortsConfigFile.getPortByName(name)
if portNums == None:
try:
portNums = [Integer.parseInt(name)]
except:
logger.debug('Failed to resolve service port number:', name)
continue
for portNum in portNums:
portsSet.add(portNum)
return portsSet
示例12: getKnownListeningPortsSet
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def getKnownListeningPortsSet(self):
ports = self.Framework.getParameter('knownListeningPorts')
portsSet = HashSet()
if logger.isDebugEnabled():
logger.debug('Known Listening Ports:', ports)
if (ports == None) or (len(ports) == 0):
return None
if (ports == '*'):
portsSet.add('*')
return portsSet
names = ports.split(',')
for name in names:
portNums = self.knownPortsConfigFile.getPortByName(name)
if portNums == None:
try:
portNums = [Integer.parseInt(name)]
except:
logger.debug('Failed to resolve service port number:', name)
continue
for portNum in portNums:
portsSet.add(portNum)
return portsSet
示例13: get_port
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def get_port(self):
return Integer.parseInt(
self.get("rabbitmq", "port")
)
示例14: test_number_format
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def test_number_format(self):
try:
Integer.parseInt('asdf')
except Exception as ex:
self.assertIn('java.lang.NumberFormatException', str(ex.message))
示例15: parameterScan
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import parseInt [as 别名]
def parameterScan():
global scan_device_server_name
global scan_1d_front
global scan_2d_front
global path
global data_file
global file_extension
global actuators
global sensors
global n_steps
global integration_time
global start_position_actuators_1D
global end_position_actuators_1D
global n_steps2
global start_position_actuators_2D
global end_position_actuators_2D
global timebase
global scan_number
global scan_type
global has_trajectory
global file_path
global actuators2D
#open the file in read only mode
#file = DataInputStream(FileInputStream("D:\eclipse\workspace\passerelle-soleil\sample-models\paramscan.txt"))
file = open(file_path,'r')
parameters = {}
for line in file.readlines():
#print "line ",line
tokens = line.split('=')
#print "tokens ",tokens
if(len(tokens) == 2):
tok0 = String(tokens[0])
tok1 = String(tokens[1])
tok0 = tok0.trim()
tok1 = tok1.trim()
parameters[tok0] = tok1
print tok0,":",tok1
if(parameters.has_key("scan_device_server_name")):
scan_device_server_name = parameters["scan_device_server_name"]
if(parameters.has_key("scan_1d_front")):
scan_1d_front = parameters["scan_1d_front"]
if(parameters.has_key("scan_2d_front")):
scan_2d_front = parameters["scan_2d_front"]
if(parameters.has_key("path")):
path = parameters["path"]
if(parameters.has_key("data_file")):
data_file = parameters["data_file"]
if(parameters.has_key("file_extension")):
file_extension = parameters["file_extension"]
if(parameters.has_key("actuators")):
actuators = parameters["actuators"].split(",")
#print "parameterScan actuators ",parameters["actuators"].split(",")
if(parameters.has_key("sensors")):
sensors = parameters["sensors"].split(",")
#if(parameters.has_key("n_steps")):
#n_steps = Integer.parseInt(parameters["n_steps"])
#if(parameters.has_key("integration_time")):
#integration_time = Double.parseDouble(parameters["integration_time"])
#if(parameters.has_key("start_position_actuators_1D")):
# stringTable = parameters["start_position_actuators_1D"].split(",")
# start_position_actuators_1D = []
# for i in stringTable:
# start_position_actuators_1D.append(Double.parseDouble(i))
if(parameters.has_key("end_position_actuators_1D")):
stringTable = parameters["end_position_actuators_1D"].split(",")
end_position_actuators_1D = []
for i in stringTable:
end_position_actuators_1D.append(Double.parseDouble(i))
if(parameters.has_key("actuators2D")):
actuators2D = parameters["actuators2D"].split(",")
#print "parameterScan actuators ",parameters["actuators"].split(",")
if(parameters.has_key("n_steps2")):
n_steps2 = Integer.parseInt(parameters["n_steps2"])
if(parameters.has_key("start_position_actuators_2D")):
stringTable = parameters["start_position_actuators_2D"].split(",")
start_position_actuators_2D = []
for i in stringTable:
start_position_actuators_2D.append(Double.parseDouble(i))
if(parameters.has_key("end_position_actuators_2D")):
stringTable = parameters["end_position_actuators_2D"].split(",")
end_position_actuators_2D = []
for i in stringTable:
end_position_actuators_2D.append(Double.parseDouble(i))
#.........这里部分代码省略.........