python - 使用 Scapy 生成数据包的 PDF 时如何抑制 PyX 警告消息?
问题描述
我正在使用 Scapy 的pdfdump
方法生成一个数据包的 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手册没有太多关于如何调整这些消息的详细程度的内容。
解决方案
此输出是使用标准 python 日志框架在日志级别 logging.INFO 创建的。默认情况下,此类日志记录输出被静音,因为默认值为 logging.WARNING (IIRC)。无论如何,只需调整您的日志记录级别,以防止通知打扰您。此外,您可以查看 pyxinfo 调用,这是 PyX 提供的启用此输出的解决方案。(也许您正在使用的库在某处调用它,并且您想禁用它。)请注意,PyX 的这种行为也记录在http://pyx.sourceforge.net/manual/text.html#debugging
推荐阅读
- android - 如何为 canvas.drawText 制作背景
- c - 推送期间的分段错误 {lr}
- sql - 选择学生在最少的时间内完成大部分项目
- azure-devops - 我们可以从 workItem 表单中隐藏系统默认字段吗?
- google-assistant-sdk - 调用操作后如何从 webhook 更改谷歌助手的对话语言
- php - 如何将base64转换为php POST表单中的图像
- electron - Electron app.getLoginItemSettings 在主进程中不起作用
- shopify - laravel-shopify osiset 卸载 webhook 没有工作
- css - 为什么 inline-flex 容器的边距不会崩溃?
- css - 内部使用剪辑路径 CSS 的不同颜色三角形的六边形多边形