scripts
scripts copied to clipboard
lnotify 0.34 + Python 3.7: malformed ps call
subprocess.check_output() returns bytes.
The result of the call on line 103 (bytes) is then used to form the command passed to another call of subprocess.check_output() on the following line.
This fails on Python 3.
When lnotify is run on Python 2, the shell command on line 104 is obtained by using % string formatting (a Python 2 default), with a bytes object used as the value of the singular %s. This provides a clean output in Python 2 (say, since it's a PID, 1102) and a mangled one in Python 3 : b'1102', since there is no implicit bytes -> str conversion (apart from bytes' __str__).
window_pid, the bytes instance, must be converted to str (unicode string) in Python 3, before using it as an argument to %.
I'll submit a PR fixing this using from __future__ import unicode_literals.
I was just looking at another issue related to this chunk of code. I'm curious if you have an opinion on my comments in #339.