I recently imported some new python modules:
# https://stackoverflow.com/a/36419702/6929343 import logging import sys
Some unexpected output now appears on my terminal:
2021-05-01 18:11:21,331 DEBUG STREAM IHDR 16 13 2021-05-01 18:11:21,331 DEBUG STREAM bKGD 41 6 2021-05-01 18:11:21,331 DEBUG bKGD 41 6 (unknown) 2021-05-01 18:11:21,331 DEBUG STREAM pHYs 59 9 2021-05-01 18:11:21,331 DEBUG STREAM tIME 80 7 2021-05-01 18:11:21,331 DEBUG tIME 80 7 (unknown) 2021-05-01 18:11:21,331 DEBUG STREAM IDAT 99 88 2021-05-01 18:11:21,334 DEBUG STREAM IHDR 16 13 2021-05-01 18:11:21,334 DEBUG STREAM bKGD 41 6 2021-05-01 18:11:21,334 DEBUG bKGD 41 6 (unknown) 2021-05-01 18:11:21,334 DEBUG STREAM pHYs 59 9 2021-05-01 18:11:21,334 DEBUG STREAM tIME 80 7 2021-05-01 18:11:21,334 DEBUG tIME 80 7 (unknown) 2021-05-01 18:11:21,334 DEBUG STREAM IDAT 99 68 2021-05-01 18:11:21,335 DEBUG STREAM IHDR 16 13 2021-05-01 18:11:21,335 DEBUG STREAM bKGD 41 6 2021-05-01 18:11:21,335 DEBUG bKGD 41 6 (unknown) 2021-05-01 18:11:21,335 DEBUG STREAM pHYs 59 9 2021-05-01 18:11:21,335 DEBUG STREAM tIME 80 7 2021-05-01 18:11:21,335 DEBUG tIME 80 7 (unknown) 2021-05-01 18:11:21,335 DEBUG STREAM IDAT 99 160
Does anyone recognize what library / function might be generating these messages? If so how can they be suppressed if they are unimportant?
Additional information
Here’s the code that was added but, I don’t think it’s causing the DEBUG lines:
def get_active_window(): """ Get the currently active window. Returns ------- string : Name of the currently active window. """ import sys active_window_name = None if sys.platform in ['linux', 'linux2']: # Alternatives: http://unix.stackexchange.com/q/38867/4784 try: import wnck except ImportError: logging.info("wnck not installed") wnck = None if wnck is not None: screen = wnck.screen_get_default() screen.force_update() window = screen.get_active_window() if window is not None: pid = window.get_pid() with open("/proc/{pid}/cmdline".format(pid=pid)) as f: active_window_name = f.read() else: try: # Next 3 limes from: https://stackoverflow.com/a/43349245/6929343 import gi gi.require_version('Gtk', '3.0') gi.require_version('Wnck', '3.0') # Continue with original code: from gi.repository import Gtk, Wnck gi = "Installed" except ImportError: logging.info("gi.repository not installed") gi = None if gi is not None: Gtk.init([]) # necessary if not using a Gtk.main() loop screen = Wnck.Screen.get_default() screen.force_update() # recommended per Wnck documentation active_window = screen.get_active_window() pid = active_window.get_pid() with open("/proc/{pid}/cmdline".format(pid=pid)) as f: active_window_name = f.read() elif sys.platform in ['Windows', 'win32', 'cygwin']: # http://stackoverflow.com/a/608814/562769 import win32gui window = win32gui.GetForegroundWindow() active_window_name = win32gui.GetWindowText(window) elif sys.platform in ['Mac', 'darwin', 'os2', 'os2emx']: # http://stackoverflow.com/a/373310/562769 from AppKit import NSWorkspace active_window_name = (NSWorkspace.sharedWorkspace() .activeApplication()['NSApplicationName']) else: print("sys.platform={platform} is unknown. Please report." .format(platform=sys.platform)) print(sys.version) return active_window_name print("Active window: %s" % str(get_active_window()))
The program output is excpeted and proceeds the DEBUG lines:
2021-05-01 18:11:20,645 INFO wnck not installed Active window: /usr/lib/gnome-terminal/gnome-terminal-server Heigh: 2160, Width: 3840 default display: <pyglet.window.xlib.XlibDisplayDevice object at 0x7fb163cf81d0> XlibScreen(screen=0, x=3840, y=2160, width=1920, height=1080, xinerama=1) XlibScreen(screen=0, x=0, y=0, width=1920, height=1080, xinerama=1) XlibScreen(screen=0, x=1920, y=0, width=3840, height=2160, xinerama=1) splash_image pyimage1 width: 5760 height: 3240 geometry: 4608.0 2592.0 576.0 324.0 toplevel: 1x1+0+0 Width 200 Height 200 splash.geometry( 2780 1520 ) Songs on disk: 3822 Added count: 0 Added meta count: 0 Songs with lyrics: 1433 Added count: 2 Added time count: 0
There’s about 10K of python code lines I’ve written but I’m fairly certain the debug lines are coming from ALSA in python or something similar. I could provide a list of all modules imported but I’m hoping someone already recognizes the DEBUG lines and which module they are from.
Advertisement
Answer
Turns out it’s a glitch in tkinter’s pillow (PIL).
The solution is a simple one-liner after the import:
import logging logging.getLogger('PIL').setLevel(logging.WARNING)