Fix lint errors and adapt to latest Python

This commit is contained in:
Roman Zeyde
2020-07-03 14:28:18 +03:00
parent 9192a8ff67
commit 4cd3def507
7 changed files with 13 additions and 12 deletions

View File

@@ -236,11 +236,11 @@ def _main():
args.pylab = None
if getattr(args, 'plot', False):
import pylab # pylint: disable=import-error
import pylab # pylint: disable=import-error,import-outside-toplevel
args.pylab = pylab
if args.audio_library == 'ALSA':
from . import alsa
from . import alsa # pylint: disable=import-outside-toplevel
interface = alsa.Interface(config)
elif args.audio_library == '-':
interface = _Dummy() # manually disable PortAudio

View File

@@ -29,7 +29,7 @@ class AsyncReader:
queue.put(buf)
total += len(buf)
log.debug('AsyncReader thread stopped (read %d bytes)', total)
except BaseException:
except BaseException: # pylint: disable=broad-except
log.exception('AsyncReader thread failed')
queue.put(None)

View File

@@ -107,8 +107,7 @@ def volume_calibration(result_iterator, volume_ctl):
def iter_window(iterable, size):
# pylint: disable=stop-iteration-return
block = []
while True:
item = next(iterable)
for item in iterable:
block.append(item)
block = block[-size:]
if len(block) == size:

View File

@@ -75,10 +75,12 @@ def take(iterable, n):
def izip(iterables):
""" "Python 3" zip re-implementation for Python 2. """
# pylint: disable=stop-iteration-return
iterables = [iter(iterable) for iterable in iterables]
while True:
yield tuple([next(iterable) for iterable in iterables])
try:
while True:
yield tuple([next(iterable) for iterable in iterables])
except StopIteration:
pass
class Dummy:

View File

@@ -29,8 +29,7 @@ class Checksum:
if received != expected:
log.warning('Invalid checksum: %08x != %08x', received, expected)
raise ValueError('Invalid checksum')
else:
log.debug('Good checksum: %08x', received)
log.debug('Good checksum: %08x', received)
return payload

View File

@@ -63,7 +63,7 @@ def recv(config, src, dst, dump_audio=None, pylab=None):
freq=freq)
receiver.run(sampler, gain=1.0/amplitude, output=dst)
return True
except BaseException:
except BaseException: # pylint: disable=broad-except
log.exception('Decoding failed')
return False
finally:

View File

@@ -1,5 +1,6 @@
from amodem import stream
import subprocess as sp
import sys
script = br"""
import sys
@@ -14,7 +15,7 @@ while True:
def test_read():
p = sp.Popen(args=['python', '-'], stdin=sp.PIPE, stdout=sp.PIPE)
p = sp.Popen(args=[sys.executable, '-'], stdin=sp.PIPE, stdout=sp.PIPE)
p.stdin.write(script)
p.stdin.close()
f = stream.Reader(p.stdout)