本文整理汇总了Python中packet.Packet.is_unknown方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.is_unknown方法的具体用法?Python Packet.is_unknown怎么用?Python Packet.is_unknown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packet.Packet
的用法示例。
在下文中一共展示了Packet.is_unknown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pp
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import is_unknown [as 别名]
def pp(self):
def fmtlist(a, showAmt=False):
newArr = []
for i,v in enumerate(a):
amt = ""
if showAmt:
amt = "%d " % v[1]
newArr += ["%d. %s%s (0x%02x)" % (i+1, amt, v[2], v[0])]
return "\n".join(newArr)
def fmtlistDest(a):
newArr = []
for i, (pid,v,n,d) in enumerate(a):
dst = ""
if d == PacketDest.Server.value:
dst = "Server"
elif d == PacketDest.Client.value:
dst = "Client"
else:
dst = "Either"
newArr += ["%d. %s (0x%02x) -> %s" % (i+1, n, pid, dst)]
return "\n".join(newArr)
unseenControlList = []
unseenGameList = []
controlFreq = []
gameFreq = []
singleDstControl = []
singleDstGame = []
for i,v in enumerate(self.control_types):
controlFreq += [[i, v, Packet.get_name_by_id(PacketType.Control, i)]]
for i,v in enumerate(self.game_types):
gameFreq += [[i, v, Packet.get_name_by_id(PacketType.Game, i)]]
controlFreqS = sorted(controlFreq, key=lambda x: x[1], reverse=True)
gameFreqS = sorted(gameFreq, key=lambda x: x[1], reverse=True)
for (i, v, n) in gameFreqS:
if v == 0 and not Packet.is_unknown(PacketType.Game, i):
unseenGameList += [[i, v, n]]
for (i, v, n) in controlFreqS:
if v == 0 and not Packet.is_unknown(PacketType.Control, i):
unseenControlList += [[i, v, n]]
for i,dst in enumerate(self.game_dst):
(i, v, n) = gameFreq[i]
if v > 0: # did we have packets of this type?
if dst[PacketDest.Server.value] == 0:
singleDstGame += [[i, v, n, PacketDest.Server.value]]
elif dst[PacketDest.Client.value] == 0:
singleDstGame += [[i, v, n, PacketDest.Client.value]]
else:
singleDstGame += [[i, v, n, 2]]
for i,dst in enumerate(self.control_dst):
(i, v, n) = controlFreq[i]
if v > 0: # did we have packets of this type?
if dst[PacketDest.Server.value] == 0:
singleDstControl += [[i, v, n, PacketDest.Server.value]]
elif dst[PacketDest.Client.value] == 0:
singleDstControl += [[i, v, n, PacketDest.Client.value]]
else:
singleDstControl += [[i, v, n, 2]]
singleDstControl = sorted(singleDstControl, key=lambda x: x[3])
singleDstGame = sorted(singleDstGame, key=lambda x: x[3])
#####################
statistics = \
"""\
Records: %d
- Control: %d
- Game: %d
Invalid: %d
Unknown: %d
""" % (self.records, self.control, self.game, self.invalid, self.unknown)
#####################
frequency = \
"""\
Frequency (highest to lowest)
== Game ==
%s
#.........这里部分代码省略.........