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 24, 2024
1 parent 7464068 commit 48371f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
26 changes: 16 additions & 10 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 @@ -236,17 +239,20 @@ def postWriteHook(self, dump_info):

util.ipmi_report(IPMI_FAILED)

def _run_kickstart_scripts(self, dump_info):
def _run_kickstart_scripts(self, _dump_info):
"""Run the %traceback and %onerror kickstart scripts."""
anaconda = dump_info.object
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)

try:
util.runOnErrorScripts(anaconda.ksdata.scripts)
kickstart.runTracebackScripts(anaconda.ksdata.scripts)
# pylint: disable=bare-except
# ruff: noqa: E722
except:
pass

def runDebug(self, exc_info):
if conf.system.can_switch_tty and self._intf_tty_num != 1:
Expand Down
6 changes: 5 additions & 1 deletion pyanaconda/modules/runtime/kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
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 @@ -46,6 +47,9 @@ class RuntimeKickstartSpecification(KickstartSpecification):
}

sections = {
"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 48371f1

Please sign in to comment.