From a907ac4d3bf787d2b8127300a1bac16f99aefe23 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck Date: Fri, 10 Jan 2025 15:22:45 -0600 Subject: [PATCH] buildmaster: Report better status information on console --- HaikuPorter/BuildMaster.py | 17 +++++++++++------ HaikuPorter/Utils.py | 9 ++++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/HaikuPorter/BuildMaster.py b/HaikuPorter/BuildMaster.py index a0182eb0..702ea972 100644 --- a/HaikuPorter/BuildMaster.py +++ b/HaikuPorter/BuildMaster.py @@ -22,7 +22,7 @@ from .Port import Port from .ReporterJson import ReporterJson from .ReporterMongo import ReporterMongo -from .Utils import ensureCommandIsAvailable, info, sysExit, warn +from .Utils import ensureCommandIsAvailable, info, sysExit, warn, important class ThreadFilter(object): @@ -194,8 +194,6 @@ def __init__(self, portsTreePath, packageRepository, options): self.localBuilders = getOption('localBuilders') self.remoteAvailable = False - print('Local builders count: ' + str(self.localBuilders)) - logHandler = logging.FileHandler( os.path.join(self.buildOutputBaseDir, 'master.log')) logHandler.setFormatter(logging.Formatter('%(asctime)s: %(message)s')) @@ -338,7 +336,11 @@ def runBuilds(self): if len(self.scheduledBuilds) == 0: break - exitStatus = 'complete' + failures = len(self.failedBuilds) + len(self.lostBuilds) + if failures > 0: + exitStatus = 'complete (with ' + str(failures) + ' failures)' + else: + exitStatus = 'complete' except KeyboardInterrupt: exitStatus = 'aborted' except Exception as exception: @@ -387,7 +389,8 @@ def _waitForBuildsToComplete(self): with self.builderCondition: if len(self.availableBuilders) == len(self.activeBuilders): break - self._setBuildStatus('waiting for all builds to complete') + worker_names = list(map(lambda x: x.name, self.activeBuilders)) + self._setBuildStatus('waiting for workers ' + ','.join(worker_names) + ' to complete') self.builderCondition.wait(1) def _getBuildNumber(self): @@ -608,7 +611,9 @@ def summary(self): } def _setBuildStatus(self, buildStatus): - self.buildStatus = buildStatus + if buildStatus != self.buildStatus: + important('Update: ' + buildStatus) + self.buildStatus = buildStatus self._reportStatus() def _reportStatus(self): diff --git a/HaikuPorter/Utils.py b/HaikuPorter/Utils.py index bf317cf7..afeb42fb 100644 --- a/HaikuPorter/Utils.py +++ b/HaikuPorter/Utils.py @@ -19,10 +19,12 @@ from subprocess import PIPE, Popen if sys.stdout.isatty(): + colorStatus = '\033[1;34m' colorWarning = '\033[1;36m' colorError = '\033[1;35m' colorReset = '\033[1;m' else: + colorStatus = '' colorWarning = '' colorError = '' colorReset = '' @@ -68,11 +70,16 @@ def sysExit(message): def warn(message): """print a warning""" - message = '\n'.join([colorWarning + 'Warning: ' + line + colorReset for line in message.split('\n')]) logging.getLogger("buildLogger").warn(message) +def important(message): + """print an important""" + message = '\n'.join([colorStatus + '=== ' + line + colorReset + for line in message.split('\n')]) + logging.getLogger("buildLogger").warn(message) + def info(message): """print an info""" if message is not None and message != '':