使用 Scapy 生成数据包的 PDF 时如何抑制 PyX 警告消息?
Posted
技术标签:
【中文标题】使用 Scapy 生成数据包的 PDF 时如何抑制 PyX 警告消息?【英文标题】:How to suppress PyX warning messages when using Scapy to generate a PDF of a packet? 【发布时间】:2018-11-15 18:55:44 【问题描述】:我正在使用 Scapy 的 pdfdump
method 生成一个数据包的 PDF:
from scapy.layers.inet import ICMP, IP
packet = IP(dst="192.168.111.1") / ICMP()
packet.pdfdump("report.pdf")
执行此代码时,会从PyX
库中打印出大量消息。
PyX executes tex with args ['--output-directory', '/tmp/pyx1ojf7_d9'] located at /usr/bin/tex
PyX filelocator found 10pt.lfs by method internal
PyX executes kpsewhich with args ['--format', 'vf', 'cmss10'] located at /usr/bin/kpsewhich
PyX filelocator failed to find cmss10 of type ('vf',) and extensions '', '.vf'
PyX executes kpsewhich with args ['--format', 'tfm', 'cmss10'] located at /usr/bin/kpsewhich
PyX filelocator found cmss10 by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmss10.tfm
PyX executes kpsewhich with args ['--format', 'vf', 'cmtt10'] located at /usr/bin/kpsewhich
PyX filelocator failed to find cmtt10 of type ('vf',) and extensions '', '.vf'
PyX executes kpsewhich with args ['--format', 'tfm', 'cmtt10'] located at /usr/bin/kpsewhich
PyX filelocator found cmtt10 by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmtt10.tfm
PyX executes kpsewhich with args ['--format', 'map', 'pdftex.map'] located at /usr/bin/kpsewhich
PyX filelocator found pdftex.map by method kpsewhich at /var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map
PyX executes kpsewhich with args ['--format', 'type1 fonts', 'cmss10.pfb'] located at /usr/bin/kpsewhich
PyX filelocator found cmss10.pfb by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmss10.pfb
PyX executes kpsewhich with args ['--format', 'afm', 'cmss10'] located at /usr/bin/kpsewhich
PyX filelocator found cmss10 by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/afm/public/amsfonts/cm/cmss10.afm
PyX executes kpsewhich with args ['--format', 'type1 fonts', 'cmtt10.pfb'] located at /usr/bin/kpsewhich
PyX filelocator found cmtt10.pfb by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmtt10.pfb
PyX executes kpsewhich with args ['--format', 'afm', 'cmtt10'] located at /usr/bin/kpsewhich
PyX filelocator found cmtt10 by method kpsewhich at /usr/share/texlive/texmf-dist/fonts/afm/public/amsfonts/cm/cmtt10.afm
有没有办法禁用或禁止这些消息,以免它们被打印出来? PyX manual 没有太多关于如何调整这些消息的详细程度的内容。
【问题讨论】:
【参考方案1】:此输出是使用标准 python 日志框架在日志级别 logging.INFO 创建的。默认情况下,此类日志记录输出是静音的,因为默认值为 logging.WARNING (IIRC)。无论如何,只需调整您的日志记录级别,以防止通知打扰您。此外,您可以查看 pyxinfo 调用,这是 PyX 提供的用于启用此输出的解决方案。 (也许您正在使用的库在某处调用了它,而您想禁用它。)请注意,PyX 的这种行为也记录在 http://pyx.sourceforge.net/manual/text.html#debugging
【讨论】:
以上是关于使用 Scapy 生成数据包的 PDF 时如何抑制 PyX 警告消息?的主要内容,如果未能解决你的问题,请参考以下文章