forked from platypush/platypush
Fixed/suppressed LGTM warnings
This commit is contained in:
parent
d13e4fc271
commit
29a7eff15a
5 changed files with 16 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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__))
|
||||
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue