How to use kervi - 10 common examples

To help you get started, we’ve selected a few kervi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kervi / kervi / tests / test_value.py View on Github external
def test_number_set_value():
    spine = MockupSpine()
    number = NumberValue("Dynamic Number", value_id="dn", spine=spine)

    number.value = 10
    assert number.value == 10
github kervi / kervi / tests / test_kervi_component.py View on Github external
def test_instantiation():
    spine = MockupSpine()
    component = KerviComponent("test_component", "component", "Test component", spine=spine)

    assert component.component_id == "test_component"
    assert component.component_type == "component"
    assert component.name == "Test component"
    assert component.visible

    assert "getDashboardComponents" in spine.queryHandlers
    assert "getComponentInfo" in spine.queryHandlers
github kervi / kervi / kervi-core / kervi / controllers / __init__.py View on Github external
    def input(input_id, name, value_class=NumberValue):
        """Add input to controller"""
        def _init():
            return value_class(
                name,
                input_id=input_id,
                is_input=True,
                index=-1
            )
        def _decorator(cls):
            setattr(cls, input_id, _init())
            return cls
        return _decorator
github kervi / kervi / kervi / build / lib / kervi / application / __init__.py View on Github external
if opt in ("--start-service"):
                service_commands += ["start"]

            if opt in ("--stop-service"):
                service_commands = ["stop"]
            
            if opt in ("--restart-service"):
                service_commands = ["restart"]
            if opt in ("--service-status"):
                service_commands = ["status"]

        if service_commands:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                hal.service_commands(
                    service_commands,
                    self.config.application.name,
                    self.config.application.id,
                    script_path
                )
            exit()

        if detect_devices:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
            exit()
github kervi / kervi / kervi / kervi / module / __init__.py View on Github external
service_commands += ["uninstall"]

            if opt in ("--start-service"):
                service_commands += ["start"]

            if opt in ("--stop-service"):
                service_commands = ["stop"]
            
            if opt in ("--restart-service"):
                service_commands = ["restart"]
            if opt in ("--service-status"):
                service_commands = ["status"]

        if service_commands:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                hal.service_commands(
                    service_commands,
                    self.config.application.name,
                    self.config.application.id,
                    script_path
                )
            exit()

        if detect_devices:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
github kervi / kervi / kervi / build / lib / kervi / application / __init__.py View on Github external
service_commands += ["uninstall"]

            if opt in ("--start-service"):
                service_commands += ["start"]

            if opt in ("--stop-service"):
                service_commands = ["stop"]
            
            if opt in ("--restart-service"):
                service_commands = ["restart"]
            if opt in ("--service-status"):
                service_commands = ["status"]

        if service_commands:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                hal.service_commands(
                    service_commands,
                    self.config.application.name,
                    self.config.application.id,
                    script_path
                )
            exit()

        if detect_devices:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
github kervi / kervi / kervi / kervi / application / __init__.py View on Github external
import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                hal.service_commands(
                    service_commands,
                    self.config.application.name,
                    self.config.application.id,
                    script_path
                )
            exit()

        if detect_devices:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
            exit()
        self._log_handler = KerviLogHandler(self.config)
        self._log_queue = self._log_handler._log_queue 
        self._logger = KerviLog("application")
        #self._validateSettings()
        self.started = False
        self._webserver_port = None

        try:
            from kervi.version import VERSION
        except:
            VERSION="0.0.0"

        self._logger.verbose("kervi version: %s", VERSION)
github kervi / kervi / kervi / kervi / module / __init__.py View on Github external
import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                hal.service_commands(
                    service_commands,
                    self.config.application.name,
                    self.config.application.id,
                    script_path
                )
            exit()

        if detect_devices:
            import kervi.hal as hal
            hal_driver = hal._load(self.config.platform.driver)
            if hal_driver:
                devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
            exit()

        self._log_handler = KerviLogHandler(self.config)
        self._log_queue = self._log_handler._log_queue 
        self._logger = KerviLog("module")
        


        self._logger.info("Starting kervi module, please wait")

        try:
            from kervi.version import VERSION
        except:
            VERSION="0.0.0"
github kervi / kervi / kervi / build / lib / kervi / application / __init__.py View on Github external
devices = hal.detect_devices()
                print("devices:")
                _pretty_print(devices)
            exit()

        
        #if settings:
        #    self.settings = app_helpers._deep_update(self.settings, settings)
        #self._validateSettings()
        self.started = False
        import kervi.spine as spine
        from kervi.zmq_spine import _ZMQSpine
        self.spine = _ZMQSpine()
        self.config.network.ipc_root_port = nethelper.get_free_port([self.config.network.ipc_root_port])
        self.spine._init_spine("kervi-main", self.config.network.ipc_root_port, None, self.config.network.ipc_root_address)
        spine.set_spine(self.spine)
        #process._start_root_spine(self.config, True, _ZMQSpine)
        #spine._init_spine("application-" + self.settings["info"]["id"])
        self.spine = spine.Spine()
        self.spine.register_query_handler("GetApplicationInfo", self._get_application_info)
        self.spine.register_query_handler("getProcessInfo", self.get_process_info)
        self.spine.register_event_handler("modulePing", self._module_ping)
        self.spine.register_event_handler("processReady", self._process_ready, scope="app-" + self.config.application.id)
        self._module_processes = []
        self._process_info = []
        self._process_info_lock = threading.Lock()

        self._kervi_modules = []
        self._kervi_modules_lock = threading.Lock()

        #from kervi.utility.storage import init_db
        #init_db(script_name)
github kervi / kervi / kervi / kervi / module / __init__.py View on Github external
def stop(self, force_exit=True, restart=False):
        self.spine.send_command("kervi_action_module_exit")
        self.spine.trigger_event(
            "moduleStopped",
            self.config.module.id
        )
        self._logger.warn("stopping processes")
        process._stop_processes("module-" + self.config.module.id)
        self.spine.trigger_event("processTerminating", None, local_only=True)
        time.sleep(1)
        spine.Spine().stop()
        #for thread in threading.enumerate():
        #    print("running thread",thread.name)
        self._logger.info("module stopped")
        if force_exit:
            import os
            os._exit(0)