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_base_path = os.path.abspath(os.path.expanduser(resource_dirs[base_path]))
|
||||||
real_path = real_base_path
|
real_path = real_base_path
|
||||||
|
|
||||||
file_path = [s for s in re.sub(r'^{}(.*)$'.format(base_path), '\\1', path)
|
file_path = [
|
||||||
.split('/') if s]
|
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]:
|
for p in file_path[:-1]:
|
||||||
real_path += os.sep + p
|
real_path += os.sep + p
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import threading
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from platypush.backend import Backend
|
from platypush.backend import Backend
|
||||||
|
@ -175,7 +174,7 @@ class SensorBackend(Backend):
|
||||||
if plugin and hasattr(plugin, 'close'):
|
if plugin and hasattr(plugin, 'close'):
|
||||||
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 ({}, []):
|
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__))
|
self.bus.post(SensorDataChangeEvent(data=new_data, source=self.plugin or self.__class__.__name__))
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Event(Message):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_id():
|
def _generate_id():
|
||||||
""" Generate a unique event 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):
|
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
|
from platypush.utils import get_plugin_name_by_class
|
||||||
|
|
||||||
__all__ = ['Camera', 'CameraInfo', 'CameraException', 'CameraPlugin', 'CaptureAlreadyRunningException',
|
__all__ = ['Camera', 'CameraInfo', 'CameraException', 'CameraPlugin', 'CaptureAlreadyRunningException',
|
||||||
'StreamWriter']
|
'VideoWriter', 'StreamWriter', 'PreviewWriter']
|
||||||
|
|
||||||
|
|
||||||
class CameraPlugin(Plugin, ABC):
|
class CameraPlugin(Plugin, ABC):
|
||||||
|
@ -539,7 +539,10 @@ class CameraPlugin(Plugin, ABC):
|
||||||
def _prepare_server_socket(camera: Camera) -> socket.socket:
|
def _prepare_server_socket(camera: Camera) -> socket.socket:
|
||||||
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
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.listen(1)
|
||||||
server_socket.settimeout(1)
|
server_socket.settimeout(1)
|
||||||
return server_socket
|
return server_socket
|
||||||
|
@ -653,7 +656,8 @@ class CameraPlugin(Plugin, ABC):
|
||||||
return {
|
return {
|
||||||
**camera.info.to_dict(),
|
**camera.info.to_dict(),
|
||||||
'active': True if camera.capture_thread and camera.capture_thread.is_alive() else False,
|
'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(),
|
'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()
|
return value.strip()
|
||||||
|
|
||||||
|
|
||||||
class DateTime(fields.Function):
|
class DateTime(fields.Function): # lgtm [py/missing-call-to-init]
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.metadata = {
|
self.metadata = {
|
||||||
|
@ -38,7 +38,7 @@ class DateTime(fields.Function):
|
||||||
return normalize_datetime(value)
|
return normalize_datetime(value)
|
||||||
|
|
||||||
|
|
||||||
class Date(fields.Function):
|
class Date(fields.Function): # lgtm [py/missing-call-to-init]
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.metadata = {
|
self.metadata = {
|
||||||
|
|
Loading…
Reference in a new issue