当前位置: 首页>>代码示例>>Python>>正文


Python Packet.is_unknown方法代码示例

本文整理汇总了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

#.........这里部分代码省略.........
开发者ID:Brandy-92,项目名称:gcapy,代码行数:103,代码来源:stats.py


注:本文中的packet.Packet.is_unknown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。