本文整理汇总了Python中packet.Packet.packet_from_fh方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.packet_from_fh方法的具体用法?Python Packet.packet_from_fh怎么用?Python Packet.packet_from_fh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packet.Packet
的用法示例。
在下文中一共展示了Packet.packet_from_fh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _read
# 需要导入模块: from packet import Packet [as 别名]
# 或者: from packet.Packet import packet_from_fh [as 别名]
def _read(self):
"""
Read one packet, publish if appropriate, then return.
We must not read all packets in a loop here, or we will not actually publish them until the end...
"""
if self._filehandle is None and not self.files:
log.msg('Completed reading specified port agent logs, exiting...')
reactor.stop()
return
if self._filehandle is None:
name = self.files.pop(0)
log.msg('Begin reading:', name)
self._filehandle = open(name, 'r')
packet = Packet.packet_from_fh(self._filehandle)
if packet is not None:
if packet.header.packet_type in self.target_types:
self.router.got_data([packet])
else:
self._filehandle.close()
self._filehandle = None
# allow the reactor loop to process other events
reactor.callLater(0.01, self._read)