From 7ce5efaf2e99c7cec602260142f9b3ea07fd3d9b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 24 Mar 2020 10:25:25 +0100 Subject: [PATCH] Removed numpy and PIL top-level imports that could break the HTTP server if not installed on the system --- platypush/plugins/qrcode.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/qrcode.py b/platypush/plugins/qrcode.py index d1c0e083..e16c49a8 100644 --- a/platypush/plugins/qrcode.py +++ b/platypush/plugins/qrcode.py @@ -5,9 +5,6 @@ import threading import time from typing import Optional, List -import numpy as np -from PIL import Image - from platypush import Config from platypush.context import get_bus from platypush.message.event.qrcode import QrcodeScannedEvent @@ -105,7 +102,8 @@ class QrcodePlugin(Plugin): results = pyzbar.decode(img) return QrcodeDecodedResponse(results) - def _convert_frame(self, frame) -> Image: + def _convert_frame(self, frame): + import numpy as np assert isinstance(frame, np.ndarray), \ 'Image conversion only works with numpy arrays for now (got {})'.format(type(frame)) mode = 'RGB'