本文整理汇总了Python中netzob.Common.Type.TypeConvertor.TypeConvertor.bool2str方法的典型用法代码示例。如果您正苦于以下问题:Python TypeConvertor.bool2str方法的具体用法?Python TypeConvertor.bool2str怎么用?Python TypeConvertor.bool2str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netzob.Common.Type.TypeConvertor.TypeConvertor
的用法示例。
在下文中一共展示了TypeConvertor.bool2str方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addPropertiesToElement
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bool2str [as 别名]
def addPropertiesToElement(xmlMessage, message, namespace):
# direction
subDirection = etree.SubElement(xmlMessage, "{" + namespace + "}direction")
subDirection.text = message.getDirection()
# major
subMajor = etree.SubElement(xmlMessage, "{" + namespace + "}major")
subMajor.text = message.getMajor()
# minor
subMinor = etree.SubElement(xmlMessage, "{" + namespace + "}minor")
subMinor.text = str(message.getMinor())
# requestMode
subRequestMode = etree.SubElement(xmlMessage, "{" + namespace + "}requestMode")
subRequestMode.text = message.getRequestMode()
# pid
subPid = etree.SubElement(xmlMessage, "{" + namespace + "}pid")
subPid.text = str(message.getPID())
# status
subStatus = etree.SubElement(xmlMessage, "{" + namespace + "}status")
subStatus.text = str(message.getStatus())
# information
subInformation = etree.SubElement(xmlMessage, "{" + namespace + "}information")
subInformation.text = str(message.getInformation())
# cancel
subCancel = etree.SubElement(xmlMessage, "{" + namespace + "}cancel")
subCancel.text = TypeConvertor.bool2str(message.getCancel())
# sizeIn
subSizeIn = etree.SubElement(xmlMessage, "{" + namespace + "}sizeIn")
subSizeIn.text = str(message.getSizeIn())
# sizeOut
subSizeOut = etree.SubElement(xmlMessage, "{" + namespace + "}sizeOut")
subSizeOut.text = str(message.getSizeOut())
示例2: save
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bool2str [as 别名]
def save(self, root, namespace):
"""Save in the XML tree the actor definition"""
xmlActor = etree.SubElement(root, "{" + namespace + "}actor")
xmlActor.set('id', str(self.getID()))
xmlActor.set('name', str(self.getName()))
xmlActor.set('initiator', TypeConvertor.bool2str(self.isInitiator()))
self.abstractionLayer.save(xmlActor, namespace)
示例3: save
# 需要导入模块: from netzob.Common.Type.TypeConvertor import TypeConvertor [as 别名]
# 或者: from netzob.Common.Type.TypeConvertor.TypeConvertor import bool2str [as 别名]
def save(message, xmlMessages, namespace_project, namespace):
root = etree.SubElement(xmlMessages, "{" + namespace + "}message")
root.set("id", str(message.getID()))
root.set("timestamp", str(message.getTimestamp()))
root.set("{http://www.w3.org/2001/XMLSchema-instance}type", "netzob-common:IRPDeviceIoControlMessage")
# data
subData = etree.SubElement(root, "{" + namespace + "}data")
subData.text = str(message.getData())
# direction
subDirection = etree.SubElement(root, "{" + namespace + "}direction")
subDirection.text = message.getDirection()
# major
subMajor = etree.SubElement(root, "{" + namespace + "}major")
subMajor.text = message.getMajor()
# minor
subMinor = etree.SubElement(root, "{" + namespace + "}minor")
subMinor.text = str(message.getMinor())
# requestMode
subRequestMode = etree.SubElement(root, "{" + namespace + "}requestMode")
subRequestMode.text = message.getRequestMode()
# pid
subPid = etree.SubElement(root, "{" + namespace + "}pid")
subPid.text = str(message.getPID())
# status
subStatus = etree.SubElement(root, "{" + namespace + "}status")
subStatus.text = str(message.getStatus())
# information
subInformation = etree.SubElement(root, "{" + namespace + "}information")
subInformation.text = str(message.getInformation())
# cancel
subCancel = etree.SubElement(root, "{" + namespace + "}cancel")
subCancel.text = TypeConvertor.bool2str(message.getCancel())
# sizeIn
subSizeIn = etree.SubElement(root, "{" + namespace + "}sizeIn")
subSizeIn.text = str(message.getSizeIn())
# sizeOut
subSizeOut = etree.SubElement(root, "{" + namespace + "}sizeOut")
subSizeOut.text = str(message.getSizeOut())
# ioctl
subIoctl = etree.SubElement(root, "{" + namespace + "}ioctl")
subIoctl.text = str(message.getIOCTL())
#pattern
subPattern = etree.SubElement(root, "{" + namespace + "}pattern")
subsubDirection = etree.SubElement(subPattern, "{" + namespace + "}direction")
subsubDirection.text = str(message.getPattern()[0])
for t in message.getPattern()[1]:
subsubToken = etree.SubElement(subPattern, "{" + namespace + "}token")
subsubToken.set("format", t.getFormat())
subsubToken.set("length", str(t.getLength()))
subsubToken.set("type", t.getType())
subsubToken.set("value", t.getValue().encode("base-64"))
return etree.tostring(root)