fix printing errors in project reload hooks

This commit is contained in:
Jörg Thalheim 2024-04-30 17:38:50 +02:00
parent 6ae08b645c
commit 56899cd29c
2 changed files with 12 additions and 8 deletions

View file

@ -5,7 +5,7 @@ from collections.abc import Generator
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from typing import Any from typing import Any, TYPE_CHECKING
from buildbot.config.builder import BuilderConfig from buildbot.config.builder import BuilderConfig
from buildbot.plugins import util from buildbot.plugins import util
@ -20,6 +20,9 @@ from twisted.internet import defer, threads
from twisted.python import log from twisted.python import log
from twisted.python.failure import Failure from twisted.python.failure import Failure
if TYPE_CHECKING:
from buildbot.process.log import StreamLog
from .common import ( from .common import (
http_request, http_request,
paginated_github_request, paginated_github_request,
@ -259,9 +262,8 @@ class ReloadGiteaProjects(BuildStep):
os.kill(os.getpid(), signal.SIGHUP) os.kill(os.getpid(), signal.SIGHUP)
return util.SUCCESS return util.SUCCESS
else: else:
yield self.addLog("log").addStderr( log: StreamLog = yield self.addLog("log")
f"Failed to reload project list: {self.error_msg}" log.addStderr(f"Failed to reload project list: {self.error_msg}")
)
return util.FAILURE return util.FAILURE

View file

@ -5,7 +5,7 @@ from collections.abc import Generator
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from typing import Any from typing import TYPE_CHECKING, Any
from buildbot.config.builder import BuilderConfig from buildbot.config.builder import BuilderConfig
from buildbot.plugins import util from buildbot.plugins import util
@ -20,6 +20,9 @@ from twisted.internet import defer, threads
from twisted.python import log from twisted.python import log
from twisted.python.failure import Failure from twisted.python.failure import Failure
if TYPE_CHECKING:
from buildbot.process.log import StreamLog
from .common import ( from .common import (
http_request, http_request,
paginated_github_request, paginated_github_request,
@ -57,9 +60,8 @@ class ReloadGithubProjects(BuildStep):
os.kill(os.getpid(), signal.SIGHUP) os.kill(os.getpid(), signal.SIGHUP)
return util.SUCCESS return util.SUCCESS
else: else:
yield self.addLog("log").addStderr( log: StreamLog = yield self.addLog("log")
f"Failed to reload project list: {self.error_msg}" log.addStderr(f"Failed to reload project list: {self.error_msg}")
)
return util.FAILURE return util.FAILURE