mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
Fix lint errors and adapt to latest Python
This commit is contained in:
@@ -236,11 +236,11 @@ def _main():
|
|||||||
|
|
||||||
args.pylab = None
|
args.pylab = None
|
||||||
if getattr(args, 'plot', False):
|
if getattr(args, 'plot', False):
|
||||||
import pylab # pylint: disable=import-error
|
import pylab # pylint: disable=import-error,import-outside-toplevel
|
||||||
args.pylab = pylab
|
args.pylab = pylab
|
||||||
|
|
||||||
if args.audio_library == 'ALSA':
|
if args.audio_library == 'ALSA':
|
||||||
from . import alsa
|
from . import alsa # pylint: disable=import-outside-toplevel
|
||||||
interface = alsa.Interface(config)
|
interface = alsa.Interface(config)
|
||||||
elif args.audio_library == '-':
|
elif args.audio_library == '-':
|
||||||
interface = _Dummy() # manually disable PortAudio
|
interface = _Dummy() # manually disable PortAudio
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class AsyncReader:
|
|||||||
queue.put(buf)
|
queue.put(buf)
|
||||||
total += len(buf)
|
total += len(buf)
|
||||||
log.debug('AsyncReader thread stopped (read %d bytes)', total)
|
log.debug('AsyncReader thread stopped (read %d bytes)', total)
|
||||||
except BaseException:
|
except BaseException: # pylint: disable=broad-except
|
||||||
log.exception('AsyncReader thread failed')
|
log.exception('AsyncReader thread failed')
|
||||||
queue.put(None)
|
queue.put(None)
|
||||||
|
|
||||||
|
|||||||
@@ -107,8 +107,7 @@ def volume_calibration(result_iterator, volume_ctl):
|
|||||||
def iter_window(iterable, size):
|
def iter_window(iterable, size):
|
||||||
# pylint: disable=stop-iteration-return
|
# pylint: disable=stop-iteration-return
|
||||||
block = []
|
block = []
|
||||||
while True:
|
for item in iterable:
|
||||||
item = next(iterable)
|
|
||||||
block.append(item)
|
block.append(item)
|
||||||
block = block[-size:]
|
block = block[-size:]
|
||||||
if len(block) == size:
|
if len(block) == size:
|
||||||
|
|||||||
@@ -75,10 +75,12 @@ def take(iterable, n):
|
|||||||
|
|
||||||
def izip(iterables):
|
def izip(iterables):
|
||||||
""" "Python 3" zip re-implementation for Python 2. """
|
""" "Python 3" zip re-implementation for Python 2. """
|
||||||
# pylint: disable=stop-iteration-return
|
|
||||||
iterables = [iter(iterable) for iterable in iterables]
|
iterables = [iter(iterable) for iterable in iterables]
|
||||||
while True:
|
try:
|
||||||
yield tuple([next(iterable) for iterable in iterables])
|
while True:
|
||||||
|
yield tuple([next(iterable) for iterable in iterables])
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Dummy:
|
class Dummy:
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ class Checksum:
|
|||||||
if received != expected:
|
if received != expected:
|
||||||
log.warning('Invalid checksum: %08x != %08x', received, expected)
|
log.warning('Invalid checksum: %08x != %08x', received, expected)
|
||||||
raise ValueError('Invalid checksum')
|
raise ValueError('Invalid checksum')
|
||||||
else:
|
log.debug('Good checksum: %08x', received)
|
||||||
log.debug('Good checksum: %08x', received)
|
|
||||||
return payload
|
return payload
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def recv(config, src, dst, dump_audio=None, pylab=None):
|
|||||||
freq=freq)
|
freq=freq)
|
||||||
receiver.run(sampler, gain=1.0/amplitude, output=dst)
|
receiver.run(sampler, gain=1.0/amplitude, output=dst)
|
||||||
return True
|
return True
|
||||||
except BaseException:
|
except BaseException: # pylint: disable=broad-except
|
||||||
log.exception('Decoding failed')
|
log.exception('Decoding failed')
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from amodem import stream
|
from amodem import stream
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
import sys
|
||||||
|
|
||||||
script = br"""
|
script = br"""
|
||||||
import sys
|
import sys
|
||||||
@@ -14,7 +15,7 @@ while True:
|
|||||||
|
|
||||||
|
|
||||||
def test_read():
|
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.write(script)
|
||||||
p.stdin.close()
|
p.stdin.close()
|
||||||
f = stream.Reader(p.stdout)
|
f = stream.Reader(p.stdout)
|
||||||
|
|||||||
Reference in New Issue
Block a user