From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1272009-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D80DF1382C5 for <garchives@archives.gentoo.org>; Sat, 17 Apr 2021 17:28:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 152C4E0845; Sat, 17 Apr 2021 17:28:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E0CA4E0845 for <gentoo-commits@lists.gentoo.org>; Sat, 17 Apr 2021 17:28:22 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8C4D933BE6B for <gentoo-commits@lists.gentoo.org>; Sat, 17 Apr 2021 17:28:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 18B214A5 for <gentoo-commits@lists.gentoo.org>; Sat, 17 Apr 2021 17:28:17 +0000 (UTC) From: "Magnus Granberg" <zorry@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Magnus Granberg" <zorry@gentoo.org> Message-ID: <1618680471.0fbd4c06d15a194eb41e56e69583b31ccd847e29.zorry@gentoo> Subject: [gentoo-commits] proj/tinderbox-cluster:master commit in: buildbot_gentoo_ci/db/, buildbot_gentoo_ci/steps/ X-VCS-Repository: proj/tinderbox-cluster X-VCS-Files: buildbot_gentoo_ci/db/model.py buildbot_gentoo_ci/db/projects.py buildbot_gentoo_ci/steps/logs.py X-VCS-Directories: buildbot_gentoo_ci/steps/ buildbot_gentoo_ci/db/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: 0fbd4c06d15a194eb41e56e69583b31ccd847e29 X-VCS-Branch: master Date: Sat, 17 Apr 2021 17:28:17 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 31fc4aa9-6498-4cfb-8d17-2099b9dac2c0 X-Archives-Hash: f0f6a5a7d9c62837aaa12410c2dad0df commit: 0fbd4c06d15a194eb41e56e69583b31ccd847e29 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> AuthorDate: Sat Apr 17 17:27:51 2021 +0000 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> CommitDate: Sat Apr 17 17:27:51 2021 +0000 URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=0fbd4c06 Add support for search type in search pattern Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org> buildbot_gentoo_ci/db/model.py | 2 +- buildbot_gentoo_ci/db/projects.py | 6 +-- buildbot_gentoo_ci/steps/logs.py | 94 ++++++++++++++++++--------------------- 3 files changed, 46 insertions(+), 56 deletions(-) diff --git a/buildbot_gentoo_ci/db/model.py b/buildbot_gentoo_ci/db/model.py index ede5cb7..ca9932a 100644 --- a/buildbot_gentoo_ci/db/model.py +++ b/buildbot_gentoo_ci/db/model.py @@ -225,11 +225,11 @@ class Model(base.DBConnectorComponent): sa.ForeignKey('projects.uuid', ondelete='CASCADE'), nullable=False), sa.Column('search', sa.String(50), nullable=False), - sa.Column('search_end', sa.String(50), nullable=True), sa.Column('start', sa.Integer, default=0), sa.Column('end', sa.Integer, default=0), sa.Column('status', sa.Enum('info', 'warning', 'ignore', 'error'), default='info'), sa.Column('type', sa.Enum('info', 'qa', 'compile', 'configure', 'install', 'postinst', 'prepare', 'setup', 'test', 'unpack', 'ignore'), default='info'), + sa.Column('search_type', sa.Enum('in', 'startswith', 'endswith', 'search'), default='in'), ) keywords = sautils.Table( diff --git a/buildbot_gentoo_ci/db/projects.py b/buildbot_gentoo_ci/db/projects.py index 2393011..176be92 100644 --- a/buildbot_gentoo_ci/db/projects.py +++ b/buildbot_gentoo_ci/db/projects.py @@ -266,15 +266,11 @@ class ProjectsConnectorComponent(base.DBConnectorComponent): ) def _row2dict_projects_pattern(self, conn, row): - if row.search_end == '': - search_end = None - else: - search_end = row.search_end return dict( id=row.id, project_uuid=row.project_uuid, search=row.search, - search_end=search_end, + search_type=row.search_type, start=row.start, end=row.end, status=row.status, diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py index 4c3bf01..178d71e 100644 --- a/buildbot_gentoo_ci/steps/logs.py +++ b/buildbot_gentoo_ci/steps/logs.py @@ -75,13 +75,13 @@ class ParserBuildLog(BuildStep): match = False if match: self.log_search_pattern_list.append(project_pattern) - print(self.log_search_pattern_list) def search_buildlog(self, tmp_index): # get text line to search text_line = self.logfile_text_dict[tmp_index] # loop true the pattern list for match for search_pattern in self.log_search_pattern_list: + search_hit = False # we add all line that start with ' * ' as info # we add all line that start with '>>>' but not '>>> /' as info if text_line.startswith(' * ') or (text_line.startswith('>>>') and not text_line.startswith('>>> /')): @@ -89,63 +89,57 @@ class ParserBuildLog(BuildStep): self.summery_dict[tmp_index]['text'] = text_line self.summery_dict[tmp_index]['type'] = 'info' self.summery_dict[tmp_index]['status'] = 'info' - if re.search(search_pattern['search'], text_line): + self.summery_dict[tmp_index]['search_pattern_id'] = 0 + if search_pattern['search_type'] == 'in': + if search_pattern['search'] in text_line: + search_hit = True + if search_pattern['search_type'] == 'startswith': + if text_line.startswith(search_pattern['search']): + search_hit = True + if search_pattern['search_type'] == 'endswith': + if text_line.endswith(search_pattern['search']): + search_hit = True + if search_pattern['search_type'] == 'search': + if search_pattern['search'] in text_line: + search_hit = True + if search_hit: + print(text_line) + print(search_pattern['search']) self.summery_dict[tmp_index] = {} self.summery_dict[tmp_index]['text'] = text_line self.summery_dict[tmp_index]['type'] = search_pattern['type'] self.summery_dict[tmp_index]['status'] = search_pattern['status'] + self.summery_dict[tmp_index]['search_pattern_id'] = search_pattern['id'] # add upper text lines if requested # max 10 - if search_pattern['start'] != 0: - i = tmp_index - i_start = i - search_pattern['start'] - match = True - while match: - i = i - 1 - if i < 0 or i < i_start: - match = False - else: - self.summery_dict[i] = {} - self.summery_dict[i]['text'] = self.logfile_text_dict[i] - self.summery_dict[i]['type'] = search_pattern['type'] - self.summery_dict[i]['status'] = 'info' + if search_pattern['start'] != 0 and search_hit: + i = tmp_index + i_start = i - search_pattern['start'] + match = True + while match: + i = i - 1 + if i < 0 or i < i_start: + match = False + else: + self.summery_dict[i] = {} + self.summery_dict[i]['text'] = self.logfile_text_dict[i] + self.summery_dict[i]['type'] = search_pattern['type'] + self.summery_dict[i]['status'] = 'info' # add lower text lines if requested # max 10 - if search_pattern['end'] != 0: - i = tmp_index - i_end = i + search_pattern['end'] - match = True - while match: - i = i + 1 - if i > self.max_text_lines or i > i_end: - match = False - else: - self.summery_dict[i] = {} - self.summery_dict[i]['text'] = self.logfile_text_dict[i] - self.summery_dict[i]['type'] = search_pattern['type'] - self.summery_dict[i]['status'] = 'info' - # add text lines if requested that we need to search for the end - # max 10 - if search_pattern['search_end'] is not None: - i = tmp_index - match = True - while match: - i = i + 1 - if i > self.max_text_lines: - match = False - if re.search(search_pattern['search_end'], self.logfile_text_dict[i]): - if not i + 1 > self.max_text_lines or not re.search(search_pattern['search_end'], self.logfile_text_dict[i + 1]): - self.summery_dict[i] = {} - self.summery_dict[i]['text'] = self.logfile_text_dict[i] - self.summery_dict[i]['type'] = search_pattern['type'] - self.summery_dict[i]['status'] = 'info' - else: - match = False - else: - self.summery_dict[i] = {} - self.summery_dict[i]['text'] = self.logfile_text_dict[i] - self.summery_dict[i]['type'] = search_pattern['type'] - self.summery_dict[i]['status'] = 'info' + if search_pattern['end'] != 0 and search_hit: + i = tmp_index + i_end = i + search_pattern['end'] + match = True + while match: + i = i + 1 + if i > self.max_text_lines or i > i_end: + match = False + else: + self.summery_dict[i] = {} + self.summery_dict[i]['text'] = self.logfile_text_dict[i] + self.summery_dict[i]['type'] = search_pattern['type'] + self.summery_dict[i]['status'] = 'info' @defer.inlineCallbacks def run(self):