Ejemplo n.º 1
0
    def __run_kolibri_start(self):
        if not self.__context.await_setup_result():
            self.__context.is_starting = False
            return

        self.__context.is_starting = True

        self.__active_extensions.update_kolibri_environ(os.environ)

        from kolibri.plugins.registry import registered_plugins
        from kolibri.utils.cli import initialize, setup_logging, start

        registered_plugins.register_plugins(["kolibri.plugins.app"])

        setup_logging(debug=False)
        initialize()

        self.__automatic_provisiondevice()
        self.__update_app_key()

        try:
            from ..kolibri_globals import KOLIBRI_HTTP_PORT

            # TODO: Start on port 0 and get randomized port number from
            #       Kolibri. This requires some changes in Kolibri itself.
            #       After doing this, we should be able to remove some weird
            #       dependencies with Kolibri in the globals module.
            start.callback(KOLIBRI_HTTP_PORT, background=False)
        except SystemExit:
            # Kolibri sometimes calls sys.exit, but we don't want to exit
            pass
Ejemplo n.º 2
0
def start_django(port=5000):
    from kolibri.utils.cli import initialize, setup_logging, start

    logging.info("Starting server...")
    setup_logging(debug=False)
    initialize()
    start.callback(port, background=False)
def init_kolibri():
    from kolibri.plugins.registry import registered_plugins
    from kolibri.utils.cli import initialize, setup_logging

    registered_plugins.register_plugins(["kolibri.plugins.app"])

    if importlib.util.find_spec("kolibri_app_desktop_xdg_plugin"):
        registered_plugins.register_plugins(["kolibri_app_desktop_xdg_plugin"])

    setup_logging(debug=False)
    initialize()
Ejemplo n.º 4
0
def start_kolibri_server():
    from kolibri.utils.cli import initialize, setup_logging, start
    from kolibri.plugins.registry import registered_plugins

    registered_plugins.register_plugins(['kolibri.plugins.app'])

    logging.info("Starting server...")
    setup_logging(debug=False)
    initialize()
    automatic_provisiondevice()
    start.callback(KOLIBRI_PORT, background=False)
    def __run_kolibri_start(self):
        self.__context.await_is_stopped()
        setup_result = self.__context.await_setup_result()

        if setup_result != self.__context.SetupResult.SUCCESS:
            self.__context.is_starting = False
            return

        init_logging("kolibri-daemon-main.txt")

        self.__context.is_starting = True
        self.__context.is_stopped = False
        self.__context.start_result = None

        # Crudely ignore if there is already a server.pid file
        # This is probably safe because we are inside a (unique) dbus service.
        try:
            KOLIBRI_HOME_PATH.joinpath("server.pid").unlink()
        except FileNotFoundError:
            pass

        self.__active_extensions.update_kolibri_environ(os.environ)

        from kolibri.plugins.registry import registered_plugins
        from kolibri.utils.cli import initialize, setup_logging, start_with_ready_cb

        registered_plugins.register_plugins(["kolibri.plugins.app"])

        setup_logging(debug=False)
        initialize()

        self.__update_app_key()
        self.__update_kolibri_home()

        try:
            KOLIBRI_HTTP_PORT = 0
            start_with_ready_cb(
                port=KOLIBRI_HTTP_PORT,
                background=False,
                ready_cb=self.__kolibri_ready_cb,
            )
        except SystemExit:
            # Kolibri sometimes calls sys.exit, but we don't want to stop this process
            raise Exception("Caught SystemExit")
        except Exception as error:
            raise error
Ejemplo n.º 6
0
 def test_old_log_file_exists(self, path_exists_mock, move_mock,
                              get_version):
     cli.setup_logging()
     # Check if the number of calls to shutil.move equals to the number of times
     # os.path.exists returns True
     self.assertEqual(move_mock.call_count, 2)