From d5511cbe29b952ee8311ad4b0a473cc2bc581b10 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Mon, 19 Dec 2016 17:32:28 +0100 Subject: Examples: Don't use the logging module, proper exit codes --- examples/play_long_file.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'examples/play_long_file.py') diff --git a/examples/play_long_file.py b/examples/play_long_file.py index 9c464ff..cdc37d1 100755 --- a/examples/play_long_file.py +++ b/examples/play_long_file.py @@ -10,12 +10,13 @@ of audio blocks in memory and is therefore able to play files that are larger than the available RAM. """ -from __future__ import division +from __future__ import division, print_function import argparse try: import queue # Python 3.x except ImportError: import Queue as queue # Python 2.x +import sys import threading def int_or_str(text): @@ -47,12 +48,13 @@ event = threading.Event() def callback(outdata, frames, time, status): assert frames == args.blocksize if status.output_underflow: - parser.error('An output underflow occurred: increase blocksize?') + print('Output underflow: increase blocksize?', file=sys.stderr) raise sd.CallbackAbort + assert not status try: data = q.get_nowait() except queue.Empty: - parser.error('Buffer is empty: increase buffersize?') + print('Buffer is empty: increase buffersize?', file=sys.stderr) raise sd.CallbackAbort if len(data) < len(outdata): outdata[:len(data)] = data -- cgit v1.2.3