diff options
author | Fred Wright <fw@fwright.net> | 2016-12-26 20:33:57 -0800 |
---|---|---|
committer | Fred Wright <fw@fwright.net> | 2016-12-26 20:41:11 -0800 |
commit | 328cf5039c058b4d26fb5b2e15ea982b889653f6 (patch) | |
tree | 8bf3dc4e8ba312e93379097d1f765b46fd8958ea /gpscat | |
parent | 5f0a605a1a4f987ef7ab21279d9d6dfd30c949ea (diff) | |
download | gpsd-328cf5039c058b4d26fb5b2e15ea982b889653f6.tar.gz |
Fixes gpscat to avoid the possibly missing select.poll().
Although poll() is generally preferred to select() in C code, in
Python, select.poll is considered OS-dependent, and is missing in some
Python versions, notably in some OSX cases. Since gpscat is not a
performance-critical application, simply using the older but more
portable select.select is preferable to some fancier scheme using
different methods on different OSes.
TESTED:
Ran gpscat on OSX with all supported Python versions.
Diffstat (limited to 'gpscat')
-rwxr-xr-x | gpscat | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -111,17 +111,14 @@ if __name__ == '__main__': termios.tcsetattr(tty, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]) - poller = select.poll() - poller.register(tty, select.POLLIN) - buf = bytes() if not rawmode: getter = sniffer.new() sniffer.register_report(reporter) seqno = 0 while True: - (fd, event) = poller.poll()[0] - if fd == tty and event == select.POLLIN: + rlist, wlist, xlist = select.select([tty], [], []) + if rlist == [tty]: if rawmode: buf += os.read(tty, NMEA_MAX) sys.stdout.write(hexdump(buf)) |