Search code examples
pythonpython-3.xpdfscapypyx

How to suppress PyX warning messages when using Scapy to generate a PDF of a packet?


I am generating a PDF of a packet using Scapy's pdfdump method:

from scapy.layers.inet import ICMP, IP

packet = IP(dst="192.168.111.1") / ICMP()
packet.pdfdump("report.pdf")

When this code is executred, there are lots of messages printed out from the PyX library.

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

Is there a way to disable or suppress these messages so they are not printed out? The PyX manual doesn't have much on how to tune the verbosity of these messages.


Solution

  • This output is created using the standard python logging framework at the logging level logging.INFO. Such logging output is silenced by default, as the default is logging.WARNING (IIRC). Anyway, just adjust your logging level to prevent the notice from bugging you. Also, you may have a look at the pyxinfo call, which is the solution provided by PyX to enable this output. (Maybe this is called somewhere by the library you're using, and you want to disable that.) Note, that this behavior of PyX is also documented at http://pyx.sourceforge.net/manual/text.html#debugging