def _notify_movement(self): value = find_plugin(self, Process.CAMERA).triggered proc = active_process() for plugin_name, plugin in active_plugins().items(): if plugin[proc] is None or not isinstance(plugin[proc], MotionDetectorResponder): continue # noinspection PyBroadException try: plugin[proc].motion_status_changed(value) except: # pragma: no cover _log.exception('Plugin %s has triggered an exception during motion_status_changed.', plugin_name)
def _dispatch_media_locally(self, media): for media_receiver in MediaManagerPlugin.active_local_media_receivers( ): media_receiver.handle_media(media) owning_manager = find_plugin(self, media.owning_process) if owning_manager is None: _log.warning( 'Could not consume media %s at %s, no media manager on process %s', str(media.uuid), media.path, media.owning_process.value.upper()) else: owning_manager.consume_media(media, active_process())
def deliver_media(self, path, kind, info=None): media_mgr_pack = find_plugin(self) with self._media_lock: uuid = None while uuid is None or uuid in self._media: uuid = uuid4() media = Media(uuid, active_process(), kind, path, info) self._media[uuid] = media # Assume not necessarily we have a media manager on every single process. This makes easier testing. self._media_in_use[uuid] = ProcessPack( *[entry is not None for entry in media_mgr_pack.values()]) _log.info('Dispatching media %s at path %s.', str(media.uuid), os.path.abspath(media.path)) # Dispatch to all the other media managers. for media_mgr in media_mgr_pack.nonempty_values(): media_mgr.dispatch_media(media) return media
def process(cls): # pragma: no cover return active_process()
def process(cls): return active_process()
def active_local_media_receivers(): for plugin_pack in active_plugins(): plugin = plugin_pack[active_process()] if plugin is None or not isinstance(plugin, MediaReceiver): continue yield plugin
def process(cls): # pragma: no cover # This plugin can run on any process return active_process()