Skip to content

Commit

Permalink
buildmaster: Report better status information on console
Browse files Browse the repository at this point in the history
  • Loading branch information
kallisti5 committed Jan 10, 2025
1 parent 982945b commit a907ac4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
17 changes: 11 additions & 6 deletions HaikuPorter/BuildMaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'))
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 8 additions & 1 deletion HaikuPorter/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -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 != '':
Expand Down

0 comments on commit a907ac4

Please sign in to comment.