Example #1
0
def initialize(debug=False):
    """
    Currently, always called before running commands. This may change in case
    commands that conflict with this behavior show up.

    :param: debug: Tells initialization to setup logging etc.
    """

    if not os.path.isfile(VERSION_FILE):
        django.setup()

        setup_logging(debug=debug)

        _first_run()
    else:
        # Do this here so that we can fix any issues with our configuration file before
        # we attempt to setup django.
        from kolibri.utils.conf import autoremove_unavailable_plugins, enable_default_plugins
        autoremove_unavailable_plugins()

        version = open(VERSION_FILE, "r").read()
        change_version = kolibri.__version__ != version.strip()
        if change_version:
            enable_default_plugins()

        django.setup()

        setup_logging(debug=debug)

        if change_version:
            logger.info("Version was {old}, new version: {new}".format(
                old=version, new=kolibri.__version__))
            update()
Example #2
0
def test_bogus_plugin_autoremove_no_path(conf):
    """
    Checks that a plugin without a dotted path is also auto-removed
    """
    plugin_name = "giraffehorse"
    conf.config["INSTALLED_APPS"].append(plugin_name)
    conf.save()
    conf.autoremove_unavailable_plugins()
    assert plugin_name not in conf.config["INSTALLED_APPS"]
Example #3
0
def test_bogus_plugin_autoremove(conf):
    """
    Checks that a plugin is auto-removed when it cannot be imported
    """
    plugin_name = "giraffe.horse"
    conf.config["INSTALLED_APPS"].append(plugin_name)
    conf.save()
    conf.autoremove_unavailable_plugins()
    assert plugin_name not in conf.config["INSTALLED_APPS"]
Example #4
0
def test_bogus_plugin_autoremove_no_path(conf):
    """
    Checks that a plugin without a dotted path is also auto-removed
    """
    plugin_name = "giraffehorse"
    conf.config["INSTALLED_APPS"].append(plugin_name)
    conf.save()
    conf.autoremove_unavailable_plugins()
    assert plugin_name not in conf.config["INSTALLED_APPS"]
Example #5
0
def test_bogus_plugin_autoremove(conf):
    """
    Checks that a plugin is auto-removed when it cannot be imported
    """
    plugin_name = "giraffe.horse"
    conf.config["INSTALLED_APPS"].append(plugin_name)
    conf.save()
    conf.autoremove_unavailable_plugins()
    assert plugin_name not in conf.config["INSTALLED_APPS"]
Example #6
0
def initialize(debug=False):
    """
    Currently, always called before running commands. This may change in case
    commands that conflict with this behavior show up.

    :param: debug: Tells initialization to setup logging etc.
    """
    if not os.path.isfile(version_file()):
        django.setup()

        setup_logging(debug=debug)

        _first_run()
    else:
        # Do this here so that we can fix any issues with our configuration file before
        # we attempt to setup django.
        from kolibri.utils.conf import autoremove_unavailable_plugins, enable_default_plugins
        autoremove_unavailable_plugins()

        version = open(version_file(), "r").read()
        version = version.strip() if version else ""
        change_version = kolibri.__version__ != version
        if change_version:
            # Version changed, make a backup no matter what.
            from kolibri.core.deviceadmin.utils import dbbackup
            try:
                backup = dbbackup(version)
                logger.info(
                    "Backed up database to: {path}".format(path=backup))
            except IncompatibleDatabase:
                logger.warning(
                    "Skipped automatic database backup, not compatible with "
                    "this DB engine.")
            enable_default_plugins()

        django.setup()

        setup_logging(debug=debug)

        if change_version:
            logger.info(
                "Version was {old}, new version: {new}".format(
                    old=version,
                    new=kolibri.__version__
                )
            )
            update()
Example #7
0
def initialize(debug=False):
    """
    Currently, always called before running commands. This may change in case
    commands that conflict with this behavior show up.

    :param: debug: Tells initialization to setup logging etc.
    """
    if not os.path.isfile(version_file()):
        django.setup()

        setup_logging(debug=debug)

        _first_run()
    else:
        # Do this here so that we can fix any issues with our configuration file before
        # we attempt to setup django.
        from kolibri.utils.conf import autoremove_unavailable_plugins, enable_default_plugins
        autoremove_unavailable_plugins()

        version = open(version_file(), "r").read()
        version = version.strip() if version else ""
        change_version = kolibri.__version__ != version
        if change_version:
            # Version changed, make a backup no matter what.
            from kolibri.core.deviceadmin.utils import dbbackup
            try:
                backup = dbbackup(version)
                logger.info(
                    "Backed up database to: {path}".format(path=backup))
            except IncompatibleDatabase:
                logger.warning(
                    "Skipped automatic database backup, not compatible with "
                    "this DB engine.")
            enable_default_plugins()

        django.setup()

        setup_logging(debug=debug)

        if change_version:
            logger.info(
                "Version was {old}, new version: {new}".format(
                    old=version,
                    new=kolibri.__version__
                )
            )
            update()