diff options
Diffstat (limited to 'buildbot_gentoo_ci/steps/logs.py')
-rw-r--r-- | buildbot_gentoo_ci/steps/logs.py | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py index 896778c..6b8eba5 100644 --- a/buildbot_gentoo_ci/steps/logs.py +++ b/buildbot_gentoo_ci/steps/logs.py @@ -7,6 +7,7 @@ import gzip import io import hashlib import json +import lzma from portage.versions import catpkgsplit, cpv_getversion @@ -74,6 +75,18 @@ def PersOutputOfEmergeInfo(rc, stdout, stderr): 'emerge_info_output' : emerge_info_output } +@defer.inlineCallbacks +def WriteTextToFile(path, text_list, separator=False): + separator2 = '\n' + if separator: + text_string = separator2.join(text_list) + else: + text_string = text_list + text_string = text_string + separator2 + with lzma.open(path,"wt") as f: + yield f.write(text_string) + yield f.close + class SetupPropertys(BuildStep): name = 'SetupPropertys' @@ -109,14 +122,16 @@ class SetupPropertys(BuildStep): # get steps/log id's from build build_log_steps_data = {} steps_data = yield self.master.db.steps.getSteps(self.getProperty("project_build_data")['buildbot_build_id']) - print(steps_data) for step in steps_data: + log_data = None logs_data = yield self.master.db.logs.getLogs(step['id']) - print(logs_data) + for log_info in logs_data: + if log_info['name'] != 'property changes': + log_data = log_info step_info = {} step_info['name'] = step['name'] step_info['number'] = step['number'] - step_info['log_data'] = logs_data + step_info['log_data'] = log_data build_log_steps_data[step['id']] = step_info self.setProperty("build_log_steps_data", build_log_steps_data, 'build_log_steps_data') return SUCCESS @@ -509,6 +524,38 @@ class ParserPkgCheckLog(BuildStep): returnstatus = WARNINGS return returnstatus +class writeStepLogsToFile(BuildStep): + + name = 'writeStepLogsToFile' + description = 'Running' + descriptionDone = 'Ran' + descriptionSuffix = None + haltOnFailure = False + flunkOnFailure = True + warnOnWarnings = True + + def __init__(self, **kwargs): + super().__init__(**kwargs) + + @defer.inlineCallbacks + def run(self): + buildsteplogfile_path = yield os.path.join(self.getProperty('logsdir'), 'buildsteps.log.xz') + stepstologlist = ['Run emerge step build', 'Run emerge step build_1'] + logs_texts = [] + for k, v in self.getProperty('build_log_steps_data').items(): + if v['name'] in stepstologlist: + logs_texts.append(f">>> BEGINING OF STEP: {v['name']}") + logs_texts.append('') + log_data = v['log_data'] + log_text = yield self.master.db.logs.getLogLines(log_data['id'], 1, log_data['num_lines']) + for line in log_text.split('\n'): + if line.startswith('h BUILDMASTER='): + line = 'h BUILDMASTER=XXX.XXX.XXX.XXX' + logs_texts.append(line[1:]) + logs_texts.append(f">>> END OF STEP: {v['name']}") + yield WriteTextToFile(buildsteplogfile_path, logs_texts, separator=True) + return SUCCESS + class SetupBugReportSteps(BuildStep): name = 'SetupBugReportSteps' description = 'Running' |