pylint warnings fixed
This commit is contained in:
parent
07dbe57641
commit
0b05d7d8de
1 changed files with 46 additions and 54 deletions
|
@ -12,7 +12,7 @@ from platypush.config import Config
|
|||
from platypush.message.response import Response
|
||||
from platypush.message.event.camera import CameraRecordingStartedEvent, \
|
||||
CameraRecordingStoppedEvent, CameraVideoRenderedEvent, \
|
||||
CameraPictureTakenEvent, CameraFrameCapturedEvent, CameraEvent
|
||||
CameraPictureTakenEvent, CameraFrameCapturedEvent
|
||||
|
||||
from platypush.plugins import Plugin, action
|
||||
|
||||
|
@ -52,8 +52,7 @@ class CameraPlugin(Plugin):
|
|||
sleep_between_frames=_default_sleep_between_frames,
|
||||
max_stored_frames=_max_stored_frames,
|
||||
color_transform=_default_color_transform,
|
||||
scale_x=None, scale_y=None, rotate=None, flip=None,
|
||||
*args, **kwargs):
|
||||
scale_x=None, scale_y=None, rotate=None, flip=None, **kwargs):
|
||||
"""
|
||||
:param device_id: Index of the default video device to be used for
|
||||
capturing (default: 0)
|
||||
|
@ -115,7 +114,7 @@ class CameraPlugin(Plugin):
|
|||
:type flip: int
|
||||
"""
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.default_device_id = device_id
|
||||
self.frames_dir = os.path.abspath(os.path.expanduser(frames_dir))
|
||||
|
@ -153,7 +152,6 @@ class CameraPlugin(Plugin):
|
|||
|
||||
return self._devices[device_id]
|
||||
|
||||
|
||||
def _release_device(self, device_id, wait_thread_termination=True):
|
||||
if device_id in self._is_recording:
|
||||
self._is_recording[device_id].clear()
|
||||
|
@ -174,8 +172,8 @@ class CameraPlugin(Plugin):
|
|||
if device_id in self._recording_info:
|
||||
del self._recording_info[device_id]
|
||||
|
||||
|
||||
def _store_frame_to_file(self, frame, frames_dir, image_file):
|
||||
@staticmethod
|
||||
def _store_frame_to_file(frame, frames_dir, image_file):
|
||||
if image_file:
|
||||
filepath = image_file
|
||||
else:
|
||||
|
@ -185,7 +183,6 @@ class CameraPlugin(Plugin):
|
|||
cv2.imwrite(filepath, frame)
|
||||
return filepath
|
||||
|
||||
|
||||
def _get_stored_frames_files(self, frames_dir):
|
||||
ret = sorted([
|
||||
os.path.join(frames_dir, f) for f in os.listdir(frames_dir)
|
||||
|
@ -194,7 +191,6 @@ class CameraPlugin(Plugin):
|
|||
])
|
||||
return ret
|
||||
|
||||
|
||||
def _get_avg_fps(self, frames_dir):
|
||||
files = self._get_stored_frames_files(frames_dir)
|
||||
frame_time_diff = 0.0
|
||||
|
@ -214,13 +210,11 @@ class CameraPlugin(Plugin):
|
|||
|
||||
return n_frames / frame_time_diff if n_frames and frame_time_diff else 0
|
||||
|
||||
|
||||
def _remove_expired_frames(self, frames_dir, max_stored_frames):
|
||||
files = self._get_stored_frames_files(frames_dir)
|
||||
for f in files[:len(files) - max_stored_frames]:
|
||||
os.unlink(f)
|
||||
|
||||
|
||||
def _make_video_file(self, frames_dir, video_file, video_type):
|
||||
files = self._get_stored_frames_files(frames_dir)
|
||||
if not files:
|
||||
|
@ -239,7 +233,6 @@ class CameraPlugin(Plugin):
|
|||
self.fire_event(CameraVideoRenderedEvent(filename=video_file))
|
||||
shutil.rmtree(frames_dir, ignore_errors=True)
|
||||
|
||||
|
||||
def _recording_thread(self):
|
||||
def thread(duration, video_file, image_file, device_id,
|
||||
frames_dir, n_frames, sleep_between_frames,
|
||||
|
@ -326,7 +319,6 @@ class CameraPlugin(Plugin):
|
|||
|
||||
return thread
|
||||
|
||||
|
||||
@action
|
||||
def start_recording(self, duration=None, video_file=None, video_type=None,
|
||||
device_id=None, frames_dir=None,
|
||||
|
@ -360,6 +352,7 @@ class CameraPlugin(Plugin):
|
|||
return self.status(device_id=device_id)
|
||||
|
||||
recording_started = threading.Event()
|
||||
|
||||
def on_recording_started(event):
|
||||
recording_started.set()
|
||||
|
||||
|
@ -520,7 +513,6 @@ class CameraPlugin(Plugin):
|
|||
}, disable_logging=True)
|
||||
return resp
|
||||
|
||||
|
||||
@action
|
||||
def get_default_device_id(self):
|
||||
return self.default_device_id
|
||||
|
|
Loading…
Reference in a new issue