diff --git a/platypush/backend/http/app/routes/plugins/camera/pi.py b/platypush/backend/http/app/routes/plugins/camera/pi.py index 0e3c2234d..539ed1ef9 100644 --- a/platypush/backend/http/app/routes/plugins/camera/pi.py +++ b/platypush/backend/http/app/routes/plugins/camera/pi.py @@ -29,8 +29,9 @@ def video_feed(): frame = output.frame if frame and len(frame): - yield (b'--frame\r\n' - b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n') + yield ( + b'--frame\r\n' b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n' + ) @camera_pi.route('/camera/pi/frame', methods=['GET']) @@ -38,18 +39,18 @@ def video_feed(): def get_frame_img(): filename = os.path.join(tempfile.gettempdir(), 'camera_pi.jpg') response = send_request('camera.pi.take_picture', image_file=filename) - frame_file = (response.output or {}).get('image_file') + frame_file = (response or {}).get('image_file') assert frame_file is not None - return send_from_directory(os.path.dirname(frame_file), - os.path.basename(frame_file)) + return send_from_directory( + os.path.dirname(frame_file), os.path.basename(frame_file) + ) @camera_pi.route('/camera/pi/stream', methods=['GET']) @authenticate() def get_stream_feed(): - return Response(video_feed(), - mimetype='multipart/x-mixed-replace; boundary=frame') + return Response(video_feed(), mimetype='multipart/x-mixed-replace; boundary=frame') # vim:sw=4:ts=4:et: diff --git a/platypush/backend/http/app/streaming/plugins/sound.py b/platypush/backend/http/app/streaming/plugins/sound.py index 4101da841..14f94a49e 100644 --- a/platypush/backend/http/app/streaming/plugins/sound.py +++ b/platypush/backend/http/app/streaming/plugins/sound.py @@ -29,16 +29,12 @@ class SoundRoute(StreamingRoute): @contextmanager def _audio_stream(self, **kwargs) -> Generator[None, None, None]: - response = send_request( + send_request( 'sound.record', dtype='int16', **kwargs, ) - assert response and not response.is_error(), ( - 'Streaming error: ' + str(response.errors) if response else '(unknown)' - ) - yield send_request('sound.stop_recording') diff --git a/platypush/backend/http/app/utils/bus.py b/platypush/backend/http/app/utils/bus.py index 72f85658f..168e44fb8 100644 --- a/platypush/backend/http/app/utils/bus.py +++ b/platypush/backend/http/app/utils/bus.py @@ -64,4 +64,9 @@ def send_request(action, wait_for_response=True, **kwargs): if kwargs: msg['args'] = kwargs - return send_message(msg, wait_for_response=wait_for_response) + rs = send_message(msg, wait_for_response=wait_for_response) + assert rs, 'Got an empty response from the server' + if rs: + assert not rs.errors, '\n'.join(rs.errors) + + return rs.output