diff --git a/platypush/backend/http/app/routes/resources.py b/platypush/backend/http/app/routes/resources.py index b556f02e..8705caab 100644 --- a/platypush/backend/http/app/routes/resources.py +++ b/platypush/backend/http/app/routes/resources.py @@ -41,8 +41,11 @@ def resources_path(path): real_base_path = os.path.abspath(os.path.expanduser(resource_dirs[base_path])) real_path = real_base_path - file_path = [s for s in re.sub(r'^{}(.*)$'.format(base_path), '\\1', path) - .split('/') if s] + file_path = [ + s for s in re.sub( + r'^{}(.*)$'.format(base_path), '\\1', path # lgtm [py/regex-injection] + ).split('/') if s + ] for p in file_path[:-1]: real_path += os.sep + p diff --git a/platypush/backend/sensor/__init__.py b/platypush/backend/sensor/__init__.py index 7a577289..31cb35af 100644 --- a/platypush/backend/sensor/__init__.py +++ b/platypush/backend/sensor/__init__.py @@ -1,4 +1,3 @@ -import threading import time from platypush.backend import Backend @@ -175,7 +174,7 @@ class SensorBackend(Backend): if plugin and hasattr(plugin, 'close'): plugin.close() - def process_data(self, new_data): + def process_data(self, *, new_data, **_): if new_data is not None and new_data not in ({}, []): self.bus.post(SensorDataChangeEvent(data=new_data, source=self.plugin or self.__class__.__name__)) diff --git a/platypush/message/event/__init__.py b/platypush/message/event/__init__.py index 8bd0ed98..dc69214a 100644 --- a/platypush/message/event/__init__.py +++ b/platypush/message/event/__init__.py @@ -65,7 +65,7 @@ class Event(Message): @staticmethod def _generate_id(): """ Generate a unique event ID """ - return hashlib.md5(str(uuid.uuid1()).encode()).hexdigest() + return hashlib.md5(str(uuid.uuid1()).encode()).hexdigest() # lgtm [py/weak-sensitive-data-hashing] def matches_condition(self, condition): """ diff --git a/platypush/plugins/camera/__init__.py b/platypush/plugins/camera/__init__.py index 2182add2..ec81f155 100644 --- a/platypush/plugins/camera/__init__.py +++ b/platypush/plugins/camera/__init__.py @@ -24,7 +24,7 @@ from platypush.plugins.camera.model.writer.preview import PreviewWriter, Preview from platypush.utils import get_plugin_name_by_class __all__ = ['Camera', 'CameraInfo', 'CameraException', 'CameraPlugin', 'CaptureAlreadyRunningException', - 'StreamWriter'] + 'VideoWriter', 'StreamWriter', 'PreviewWriter'] class CameraPlugin(Plugin, ABC): @@ -539,7 +539,10 @@ class CameraPlugin(Plugin, ABC): def _prepare_server_socket(camera: Camera) -> socket.socket: server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server_socket.bind((camera.info.bind_address or '0.0.0.0', camera.info.listen_port)) + server_socket.bind(( + camera.info.bind_address or '0.0.0.0', # lgtm [py/bind-socket-all-network-interfaces] + camera.info.listen_port + )) server_socket.listen(1) server_socket.settimeout(1) return server_socket @@ -653,7 +656,8 @@ class CameraPlugin(Plugin, ABC): return { **camera.info.to_dict(), 'active': True if camera.capture_thread and camera.capture_thread.is_alive() else False, - 'capturing': True if camera.capture_thread and camera.capture_thread.is_alive() and camera.start_event.is_set() else False, + 'capturing': True if camera.capture_thread and camera.capture_thread.is_alive() and + camera.start_event.is_set() else False, 'streaming': camera.stream_thread and camera.stream_thread.is_alive() and camera.stream_event.is_set(), } diff --git a/platypush/schemas/__init__.py b/platypush/schemas/__init__.py index c0f4a71b..ca280562 100644 --- a/platypush/schemas/__init__.py +++ b/platypush/schemas/__init__.py @@ -21,7 +21,7 @@ class StrippedString(fields.Function): # lgtm [py/missing-call-to-init] return value.strip() -class DateTime(fields.Function): +class DateTime(fields.Function): # lgtm [py/missing-call-to-init] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.metadata = { @@ -38,7 +38,7 @@ class DateTime(fields.Function): return normalize_datetime(value) -class Date(fields.Function): +class Date(fields.Function): # lgtm [py/missing-call-to-init] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.metadata = {