Skip to content

Commit

Permalink
Migrate the %onerror and %traceback script
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkankovsky committed Jul 23, 2024
1 parent 169e180 commit 305d912
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 16 additions & 3 deletions pyanaconda/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@
from meh.dump import ReverseExceptionDump
from meh.handler import ExceptionHandler

from pyanaconda import kickstart
from pyanaconda.core import util
from pyanaconda.core.async_utils import run_in_loop
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.constants import THREAD_EXCEPTION_HANDLING_TEST, IPMI_FAILED
from pyanaconda.core.product import get_product_is_final_release
from pyanaconda.errors import NonInteractiveError
from pyanaconda.core.i18n import _
from pyanaconda.modules.common.constants.objects import SCRIPTS
from pyanaconda.modules.common.constants.services import RUNTIME
from pyanaconda.modules.common.errors.storage import UnusableStorageError
from pyanaconda.core.threads import thread_manager
from pyanaconda.modules.common.task import sync_run_task
from pyanaconda.ui.communication import hubQ

from simpleline import App
from simpleline.event_loop.signals import ExceptionSignal
from pykickstart.constants import KS_SCRIPT_ONERROR, KS_SCRIPT_TRACEBACK

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)
Expand Down Expand Up @@ -241,8 +244,18 @@ def _run_kickstart_scripts(self, dump_info):
anaconda = dump_info.object

try:
util.runOnErrorScripts(anaconda.ksdata.scripts)
kickstart.runTracebackScripts(anaconda.ksdata.scripts)
scripts_proxy = RUNTIME.get_proxy(SCRIPTS)

# OnError script call
onerror_task_path = scripts_proxy.RunScriptsWithTask(KS_SCRIPT_ONERROR)
onerror_task_proxy = RUNTIME.get_proxy(onerror_task_path)
sync_run_task(onerror_task_proxy)

# Traceback script call
traceback_task_path = scripts_proxy.RunScriptsWithTask(KS_SCRIPT_TRACEBACK)
traceback_task_proxy = RUNTIME.get_proxy(traceback_task_path)
sync_run_task(traceback_task_proxy)

# pylint: disable=bare-except
# ruff: noqa: E722
except:
Expand Down
5 changes: 4 additions & 1 deletion pyanaconda/modules/runtime/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
# Red Hat, Inc.
#
from pykickstart.parser import Script
from pykickstart.sections import PreScriptSection, PreInstallScriptSection, PostScriptSection
from pykickstart.sections import (PreScriptSection, PreInstallScriptSection,
PostScriptSection, TracebackScriptSection, OnErrorScriptSection)

from pyanaconda.core.kickstart import KickstartSpecification, commands as COMMANDS
from pyanaconda.kickstart import AnacondaKSScript
Expand Down Expand Up @@ -50,4 +51,6 @@ class RuntimeKickstartSpecification(KickstartSpecification):
"pre": lambda handler: PreScriptSection(handler, dataObj=AnacondaKSScript),
"pre-install": lambda handler: PreInstallScriptSection(handler, dataObj=AnacondaKSScript),
"post": lambda handler: PostScriptSection(handler, dataObj=AnacondaKSScript),
"onerror": lambda handler: OnErrorScriptSection(handler, dataObj=AnacondaKSScript),
"traceback": lambda handler: TracebackScriptSection(handler, dataObj=AnacondaKSScript),
}

0 comments on commit 305d912

Please sign in to comment.