Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if self.config.module.app_connection_local and not self.config.network.ipc_root_address:
self._logger.verbose("Locating kervi application...{0}", "")
from kervi.utility.discovery import find_kervi_app
address, port = find_kervi_app(self.config.application.id)
if address:
self.config.network.ipc_root_address = address
self.config.network.ipc_root_port = port
else:
self._logger.error("Locate kervi application failed")
exit()
self._root_address = "tcp://" + self.config.network.ipc_root_address + ":" + str(self.config.network.ipc_root_port)
from kervi.plugin.message_bus.bus_manager import BusManager
self.bus_manager = BusManager()
self.config.network.ipc_root_port = nethelper.get_free_port([self.config.network.ipc_root_port])
if self.config.module.app_connection_local:
self.bus_manager.load(
"kervi-module",
self.config.network.ipc_module_port,
"tcp://" + self.config.network.ipc_root_address + ":" + str(self.config.network.ipc_root_port),
self.config.network.ip
)
else:
self.bus_manager.load(
"kervi-main",
self.config.network.ipc_root_port,
None,
self.config.network.ipc_root_address
)
module_port = pluginManager.load_plugins(module_port+1)
for module in self.config.modules:
module_port += 1
self._process_info_lock.acquire()
self._process_info += [{"id":module, "ready":False}]
self._process_info_lock.release()
self._module_processes += [
process._start_process(
"module-" + self.config.module.ip,
module,
self.config,
nethelper.get_free_port([module_port]),
app_helpers._KerviModuleLoader,
process_id=self.config.module.id + "-" + module
)
]
while not self._is_ready():
time.sleep(1)
self._logger.info("module connected to application at: %s", self._root_address)
self._logger.info("Press ctrl + c to stop your module")
self.spine.trigger_event(
"moduleReady",
self.config.module.id
)
self.spine.send_command("kervi_action_module_main")
self._process_info_lock.release()
module_port = pluginManager.load_plugins(module_port+1)
for module in self.config.modules:
self._process_info_lock.acquire()
self._process_info += [{"id":module, "ready":False, "pid":None}]
self._process_info_lock.release()
module_port += 1
self._module_processes += [
process._start_process(
"app-" + self.config.application.id,
module,
self.config,
nethelper.get_free_port([module_port]),
app_helpers._KerviModuleLoader,
log_queue = self._log_queue
)
]
#print("wait for ready")
try:
while not self.char_list and not self._is_ready():
#print(self.char_list)
time.sleep(1)
except KeyboardInterrupt:
pass
#print("pi", self._process_info)
if not self._in_stop:
def _start_plugin_process(self, module_port):
process._start_process(
"plugin-" + self._manager._config.application.id + "." + self._plugin_module,
"plugin_" + self._plugin_module,
self._manager._config,
nethelper.get_free_port([module_port]),
_KerviPluginProcess,
plugin_module=self._plugin_module,
plugin_config=self._config,
log_queue = self._manager._log_queue,
load_silent = self._manager._load_silent
)
"id": "kervi"
},
"module" : {
"name": "Kervi module",
"id": "kervi_module",
"app_connection_local": True
},
"discovery":{
"enabled": True,
"challenge": "kervi",
"port": 9434
},
"modules":[],
"network" : {
"ip": nethelper.get_ip_address(),
"ipc_module_port": nethelper.get_free_port([9800]),
"ipc_root_port": 9500,
"ipc_root_address": None
},
"encryption" :{
"ipc_secret":"",
},
"media":{
"folders":{
"images":"images",
"videos":"videos"
}
},
"plugin_manager":{
"plugin_types":{
"default": {
"managed": False,
app_helpers._KerviSocketIPC
)
]
for module in self.config.modules:
self._process_info_lock.acquire()
self._process_info += [{"id":module, "ready":False}]
self._process_info_lock.release()
module_port += 1
self._module_processes += [
process._start_process(
"app-" + self.config.application.id,
module,
self.config,
nethelper.get_free_port([module_port]),
app_helpers._KerviModuleLoader
)
]
# if self.config.routing.kervi_io.enabled:
# module_port += 1
# self._module_processes += [
# process._start_process(
# "app-" + self.config.application.id,
# "kervi_io",
# self.config,
# nethelper.get_free_port([module_port]),
# app_helpers._KerviIORouterProcess
# )
# ]
def __init__(self, camera_id, name, camera_source = None, **kwargs):
CameraBase.__init__(self, camera_id, name, type="frame", **kwargs)
self._device_driver = hal.get_camera_driver(camera_source)
self._device_driver.camera = self
self._frame_format = self._device_driver.buffer_type
protocol = "http://"
if encryption.enabled():
protocol = "https://"
self.ip_address = nethelper.get_ip_address()
self.ip_port = nethelper.get_free_port()
self.source = protocol + str(self.ip_address) + ":" + str(self.ip_port) + "/" + camera_id# + ".png"
self.source = {
"server": protocol + str(self.ip_address) + ":" + str(self.ip_port),
"path": "/"+camera_id
}
self.current_frame = None
self.current_frame_number = 0
from threading import Lock
self.mutex = Lock()
self.server = _HTTPFrameServer(
(self.ip_address, self.ip_port),
_HTTPFrameHandler,
self,
def __init__(self, camera_id, name, camera_source = None, **kwargs):
CameraBase.__init__(self, camera_id, name, type="frame", **kwargs)
self._device_driver = hal.get_camera_driver(camera_source)
self._device_driver.camera = self
self._frame_format = self._device_driver.buffer_type
protocol = "http://"
if encryption.enabled():
protocol = "https://"
self.ip_address = nethelper.get_ip_address()
self.ip_port = nethelper.get_free_port()
self.source = protocol + str(self.ip_address) + ":" + str(self.ip_port) + "/" + camera_id# + ".png"
self.source = {
"server": protocol + str(self.ip_address) + ":" + str(self.ip_port),
"path": "/"+camera_id
}
self.current_frame = None
self.current_frame_number = 0
from threading import Lock
self.mutex = Lock()
self.server = _HTTPFrameServer(
(self.ip_address, self.ip_port),
_HTTPFrameHandler,
self,
def __init__(self, camera_id, name, camera_source = None, **kwargs):
CameraBase.__init__(self, camera_id, name, type="frame", **kwargs)
self._device_driver = hal.get_camera_driver(camera_source)
self._device_driver.camera = self
self._frame_format = self._device_driver.buffer_type
protocol = "http://"
if encryption.enabled():
protocol = "https://"
self.ip_address = nethelper.get_ip_address()
self.ip_port = nethelper.get_free_port()
self.source = protocol + str(self.ip_address) + ":" + str(self.ip_port) + "/" + camera_id# + ".png"
self.source = {
"server": protocol + str(self.ip_address) + ":" + str(self.ip_port),
"path": "/"+camera_id
}
self.current_frame = None
self.current_frame_number = 0
from threading import Lock
self.mutex = Lock()
self.server = _HTTPFrameServer(
(self.ip_address, self.ip_port),
_HTTPFrameHandler,
self,
self.mutex