Gentoo Archives: gentoo-commits

From: Magnus Granberg <zorry@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/tinderbox-cluster:master commit in: buildbot_gentoo_ci/db/, buildbot_gentoo_ci/steps/
Date: Sat, 17 Apr 2021 17:28:23
Message-Id: 1618680471.0fbd4c06d15a194eb41e56e69583b31ccd847e29.zorry@gentoo
1 commit: 0fbd4c06d15a194eb41e56e69583b31ccd847e29
2 Author: Magnus Granberg <zorry <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 17 17:27:51 2021 +0000
4 Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 17 17:27:51 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=0fbd4c06
7
8 Add support for search type in search pattern
9
10 Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>
11
12 buildbot_gentoo_ci/db/model.py | 2 +-
13 buildbot_gentoo_ci/db/projects.py | 6 +--
14 buildbot_gentoo_ci/steps/logs.py | 94 ++++++++++++++++++---------------------
15 3 files changed, 46 insertions(+), 56 deletions(-)
16
17 diff --git a/buildbot_gentoo_ci/db/model.py b/buildbot_gentoo_ci/db/model.py
18 index ede5cb7..ca9932a 100644
19 --- a/buildbot_gentoo_ci/db/model.py
20 +++ b/buildbot_gentoo_ci/db/model.py
21 @@ -225,11 +225,11 @@ class Model(base.DBConnectorComponent):
22 sa.ForeignKey('projects.uuid', ondelete='CASCADE'),
23 nullable=False),
24 sa.Column('search', sa.String(50), nullable=False),
25 - sa.Column('search_end', sa.String(50), nullable=True),
26 sa.Column('start', sa.Integer, default=0),
27 sa.Column('end', sa.Integer, default=0),
28 sa.Column('status', sa.Enum('info', 'warning', 'ignore', 'error'), default='info'),
29 sa.Column('type', sa.Enum('info', 'qa', 'compile', 'configure', 'install', 'postinst', 'prepare', 'setup', 'test', 'unpack', 'ignore'), default='info'),
30 + sa.Column('search_type', sa.Enum('in', 'startswith', 'endswith', 'search'), default='in'),
31 )
32
33 keywords = sautils.Table(
34
35 diff --git a/buildbot_gentoo_ci/db/projects.py b/buildbot_gentoo_ci/db/projects.py
36 index 2393011..176be92 100644
37 --- a/buildbot_gentoo_ci/db/projects.py
38 +++ b/buildbot_gentoo_ci/db/projects.py
39 @@ -266,15 +266,11 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
40 )
41
42 def _row2dict_projects_pattern(self, conn, row):
43 - if row.search_end == '':
44 - search_end = None
45 - else:
46 - search_end = row.search_end
47 return dict(
48 id=row.id,
49 project_uuid=row.project_uuid,
50 search=row.search,
51 - search_end=search_end,
52 + search_type=row.search_type,
53 start=row.start,
54 end=row.end,
55 status=row.status,
56
57 diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py
58 index 4c3bf01..178d71e 100644
59 --- a/buildbot_gentoo_ci/steps/logs.py
60 +++ b/buildbot_gentoo_ci/steps/logs.py
61 @@ -75,13 +75,13 @@ class ParserBuildLog(BuildStep):
62 match = False
63 if match:
64 self.log_search_pattern_list.append(project_pattern)
65 - print(self.log_search_pattern_list)
66
67 def search_buildlog(self, tmp_index):
68 # get text line to search
69 text_line = self.logfile_text_dict[tmp_index]
70 # loop true the pattern list for match
71 for search_pattern in self.log_search_pattern_list:
72 + search_hit = False
73 # we add all line that start with ' * ' as info
74 # we add all line that start with '>>>' but not '>>> /' as info
75 if text_line.startswith(' * ') or (text_line.startswith('>>>') and not text_line.startswith('>>> /')):
76 @@ -89,63 +89,57 @@ class ParserBuildLog(BuildStep):
77 self.summery_dict[tmp_index]['text'] = text_line
78 self.summery_dict[tmp_index]['type'] = 'info'
79 self.summery_dict[tmp_index]['status'] = 'info'
80 - if re.search(search_pattern['search'], text_line):
81 + self.summery_dict[tmp_index]['search_pattern_id'] = 0
82 + if search_pattern['search_type'] == 'in':
83 + if search_pattern['search'] in text_line:
84 + search_hit = True
85 + if search_pattern['search_type'] == 'startswith':
86 + if text_line.startswith(search_pattern['search']):
87 + search_hit = True
88 + if search_pattern['search_type'] == 'endswith':
89 + if text_line.endswith(search_pattern['search']):
90 + search_hit = True
91 + if search_pattern['search_type'] == 'search':
92 + if search_pattern['search'] in text_line:
93 + search_hit = True
94 + if search_hit:
95 + print(text_line)
96 + print(search_pattern['search'])
97 self.summery_dict[tmp_index] = {}
98 self.summery_dict[tmp_index]['text'] = text_line
99 self.summery_dict[tmp_index]['type'] = search_pattern['type']
100 self.summery_dict[tmp_index]['status'] = search_pattern['status']
101 + self.summery_dict[tmp_index]['search_pattern_id'] = search_pattern['id']
102 # add upper text lines if requested
103 # max 10
104 - if search_pattern['start'] != 0:
105 - i = tmp_index
106 - i_start = i - search_pattern['start']
107 - match = True
108 - while match:
109 - i = i - 1
110 - if i < 0 or i < i_start:
111 - match = False
112 - else:
113 - self.summery_dict[i] = {}
114 - self.summery_dict[i]['text'] = self.logfile_text_dict[i]
115 - self.summery_dict[i]['type'] = search_pattern['type']
116 - self.summery_dict[i]['status'] = 'info'
117 + if search_pattern['start'] != 0 and search_hit:
118 + i = tmp_index
119 + i_start = i - search_pattern['start']
120 + match = True
121 + while match:
122 + i = i - 1
123 + if i < 0 or i < i_start:
124 + match = False
125 + else:
126 + self.summery_dict[i] = {}
127 + self.summery_dict[i]['text'] = self.logfile_text_dict[i]
128 + self.summery_dict[i]['type'] = search_pattern['type']
129 + self.summery_dict[i]['status'] = 'info'
130 # add lower text lines if requested
131 # max 10
132 - if search_pattern['end'] != 0:
133 - i = tmp_index
134 - i_end = i + search_pattern['end']
135 - match = True
136 - while match:
137 - i = i + 1
138 - if i > self.max_text_lines or i > i_end:
139 - match = False
140 - else:
141 - self.summery_dict[i] = {}
142 - self.summery_dict[i]['text'] = self.logfile_text_dict[i]
143 - self.summery_dict[i]['type'] = search_pattern['type']
144 - self.summery_dict[i]['status'] = 'info'
145 - # add text lines if requested that we need to search for the end
146 - # max 10
147 - if search_pattern['search_end'] is not None:
148 - i = tmp_index
149 - match = True
150 - while match:
151 - i = i + 1
152 - if i > self.max_text_lines:
153 - match = False
154 - if re.search(search_pattern['search_end'], self.logfile_text_dict[i]):
155 - if not i + 1 > self.max_text_lines or not re.search(search_pattern['search_end'], self.logfile_text_dict[i + 1]):
156 - self.summery_dict[i] = {}
157 - self.summery_dict[i]['text'] = self.logfile_text_dict[i]
158 - self.summery_dict[i]['type'] = search_pattern['type']
159 - self.summery_dict[i]['status'] = 'info'
160 - else:
161 - match = False
162 - else:
163 - self.summery_dict[i] = {}
164 - self.summery_dict[i]['text'] = self.logfile_text_dict[i]
165 - self.summery_dict[i]['type'] = search_pattern['type']
166 - self.summery_dict[i]['status'] = 'info'
167 + if search_pattern['end'] != 0 and search_hit:
168 + i = tmp_index
169 + i_end = i + search_pattern['end']
170 + match = True
171 + while match:
172 + i = i + 1
173 + if i > self.max_text_lines or i > i_end:
174 + match = False
175 + else:
176 + self.summery_dict[i] = {}
177 + self.summery_dict[i]['text'] = self.logfile_text_dict[i]
178 + self.summery_dict[i]['type'] = search_pattern['type']
179 + self.summery_dict[i]['status'] = 'info'
180
181 @defer.inlineCallbacks
182 def run(self):