Example #1
0
def run(arguments: argparse.Namespace, old_site_id: SiteId,
        new_site_id: SiteId) -> bool:
    has_errors = False
    logger.debug("Initializing application...")

    main_modules.load_plugins()

    with gui_context(), SuperUserContext():
        logger.debug("Starting actions...")
        actions = sorted(rename_action_registry.values(),
                         key=lambda a: a.sort_index)
        total = len(actions)
        for count, rename_action in enumerate(actions, start=1):
            logger.log(VERBOSE, " %i/%i %s...", count, total,
                       rename_action.title)
            try:
                rename_action.run(old_site_id, new_site_id)
            except Exception:
                has_errors = True
                logger.error(' + "%s" failed',
                             rename_action.title,
                             exc_info=True)
                if arguments.debug:
                    raise

    logger.log(VERBOSE, "Done")
    return has_errors
Example #2
0
def fixture_gui_context():
    with gui_context(), SuperUserContext():
        yield
Example #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2021 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.
"""Initialize the Checkmk default configuration in case it is necessary.
"""
# pylint: disable=cmk-module-layer-violation
from cmk.gui import watolib
from cmk.gui import main_modules
from cmk.gui.utils.script_helpers import gui_context

if __name__ == "__main__":
    main_modules.load_plugins()
    with gui_context():
        watolib.init_wato_datastructures()