mirror of
https://github.com/romanz/amodem.git
synced 2026-04-20 13:16:42 +08:00
fix amodem script
- redirect stderr to /dev/null - use pylab if `--plot` is used
This commit is contained in:
@@ -18,6 +18,8 @@ from amodem import wave
|
|||||||
import argparse
|
import argparse
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
null = open('/dev/null', 'wb')
|
||||||
|
|
||||||
def FileType(mode, process=None):
|
def FileType(mode, process=None):
|
||||||
def opener(fname):
|
def opener(fname):
|
||||||
assert 'r' in mode or 'w' in mode
|
assert 'r' in mode or 'w' in mode
|
||||||
@@ -25,8 +27,8 @@ def FileType(mode, process=None):
|
|||||||
fname = '-'
|
fname = '-'
|
||||||
|
|
||||||
if fname is None:
|
if fname is None:
|
||||||
if 'r' in mode: return process(stdout=wave.sp.PIPE).stdout
|
if 'r' in mode: return process(stdout=wave.sp.PIPE, stderr=null).stdout
|
||||||
if 'w' in mode: return process(stdin=wave.sp.PIPE).stdin
|
if 'w' in mode: return process(stdin=wave.sp.PIPE, stderr=null).stdin
|
||||||
|
|
||||||
if fname == '-':
|
if fname == '-':
|
||||||
if 'r' in mode: return _stdin
|
if 'r' in mode: return _stdin
|
||||||
@@ -92,6 +94,9 @@ def main():
|
|||||||
args.input = args.input_type(args.input)
|
args.input = args.input_type(args.input)
|
||||||
if hasattr(args, 'output_type'):
|
if hasattr(args, 'output_type'):
|
||||||
args.output = args.output_type(args.output)
|
args.output = args.output_type(args.output)
|
||||||
|
if getattr(args, 'plt', 'None'):
|
||||||
|
import pylab
|
||||||
|
args.plt = pylab
|
||||||
args.main(args)
|
args.main(args)
|
||||||
|
|
||||||
def run(args, process):
|
def run(args, process):
|
||||||
|
|||||||
Reference in New Issue
Block a user