本文整理汇总了Python中java.util.Hashtable.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Python Hashtable.containsKey方法的具体用法?Python Hashtable.containsKey怎么用?Python Hashtable.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Hashtable
的用法示例。
在下文中一共展示了Hashtable.containsKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WriteMsgToFile
# 需要导入模块: from java.util import Hashtable [as 别名]
# 或者: from java.util.Hashtable import containsKey [as 别名]
writer = WriteMsgToFile(HOME_FILE)
while True:
try:
delivery = consumer.nextDelivery()
message = delivery.getBody()
message = StringUtil.fromBytes(message)
token = message.split(":",1)[0]
rest = message.split(":",1)[1]
message = str(message)
# If message is a "token_request", process request and add new token to hashmap
if message[0:13] == ("TOKEN_REQUEST"):
makeToken = ProcessTokenRequest(message, channel)
tokenID = makeToken.sendToken()
permissions.put(tokenID[0], tokenID[1])
# Otherwise, check if message has valid token (token in hashmap).
# If so, accept message, then delete token from valid list.
else:
if permissions.containsKey(token):
print (" [x] Received '" + rest + "' from: " + permissions.get(token))
writer.writeMsg(rest, permissions.get(token)) #Write message to text file
permissions.remove(token)
else:
print " ERROR: INVALID TOKEN PROVIDED IN MESSAGE"
except BaseException:
print "Consumer encountered an exception."
channel.queueDelete(queueName)
channel.close()
connection.close()