mirror of
https://github.com/romanz/amodem.git
synced 2026-04-03 11:06:24 +08:00
Fix lint errors and adapt to latest Python
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user