Merge lp:~cr3/checkbox-editor/attachments into lp:checkbox-editor

Proposed by Marc Tardif
Status: Merged
Approved by: Javier Collado
Approved revision: 149
Merged at revision: 148
Proposed branch: lp:~cr3/checkbox-editor/attachments
Merge into: lp:checkbox-editor
Diff against target: 251 lines (+95/-26)
7 files modified
README (+21/-0)
checkbox_editor/editor.py (+2/-1)
checkbox_editor/glade/preferences.glade (+23/-2)
checkbox_editor/model.py (+25/-13)
checkbox_editor/preferences.py (+4/-2)
checkbox_editor/whitelist.py (+19/-8)
templates/checkbox/data/.checkbox-editor.cfg.tmpl (+1/-0)
To merge this branch: bzr merge lp:~cr3/checkbox-editor/attachments
Reviewer Review Type Date Requested Status
Javier Collado (community) Approve
Marc Tardif (community) Needs Resubmitting
Review via email: mp+117609@code.launchpad.net

Description of the change

To test these changes, I created a whitelist using checkbox-editor without the attachments_whitelist preference disabled. I then created another whitelist with the same preference enabled and this was the diff:

2c2
< # Date: 2012-08-01 06:34:01
---
> # Date: 2012-08-01 06:34:23
21a22,42
> \_\_info\_\_
> codecs\_attachment
> cpuinfo\_attachment
> dmesg\_attachment
> dmi\_attachment
> dmidecode\_attachment
> efi\_attachment
> lspci\_attachment
> lspci\_network\_attachment
> lsusb\_attachment
> meminfo\_attachment
> modprobe\_attachment
> modules\_attachment
> sysctl\_attachment
> sysfs\_attachment
> udev\_attachment
> gcov\_attachment
> lsmod\_attachment
> acpi\_sleep\_attachment
> installer\_bootchart\.tgz
> installer\_debug\.gz

Looks good to me!

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

Looking at the merge proposal, it's not clear to me why it's needed to check 'depends' and 'name' fields to whitelist jobs based on the plugin type like this:

if ('depends' not in description
    and '/' not in description['name']
    and description.get('plugin') == plugin):

Please could you add a brief explanation as a comment to the code for future reference?

review: Needs Information
lp:~cr3/checkbox-editor/attachments updated
149. By Marc Tardif

Added comments when checking for resource and attachment plugins.

Revision history for this message
Marc Tardif (cr3) wrote :

Agreed, I added a comment and took the opportunity to refactor that logic into a function in the model module.

review: Needs Resubmitting
Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks, it looks good now.

I've also run a test to generate a whitelist with/without the attachments option selected and the diff between the two of them makes sense.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'README'
2--- README 1970-01-01 00:00:00 +0000
3+++ README 2012-08-02 01:37:20 +0000
4@@ -0,0 +1,21 @@
5+README
6+======
7+
8+Editor for the checkbox test integration framework.
9+
10+
11+Building
12+--------
13+
14+To build the project, install the packager package and run:
15+
16+ packager config set extension 'mako'
17+ packager render
18+
19+
20+Running
21+-------
22+
23+To run the project, build it and run:
24+
25+ PYTHONPATH=. ./bin/checkbox-editor
26
27=== modified file 'checkbox_editor/editor.py'
28--- checkbox_editor/editor.py 2011-10-10 13:12:05 +0000
29+++ checkbox_editor/editor.py 2012-08-02 01:37:20 +0000
30@@ -879,8 +879,9 @@
31 """
32 Return whitelist patterns for selected row
33 """
34+ whitelist_attachments = self.preferences.general['whitelist_attachments']
35 whitelist_resources = self.preferences.general['whitelist_resources']
36- for row in model.get_selected_rows(include_resources=whitelist_resources):
37+ for row in model.get_selected_rows(include_attachments=whitelist_attachments, include_resources=whitelist_resources):
38 description = row[model.DESCRIPTION]
39 if description and 'name' in description:
40 if ('plugin' in description
41
42=== modified file 'checkbox_editor/glade/preferences.glade'
43--- checkbox_editor/glade/preferences.glade 2011-08-05 16:57:03 +0000
44+++ checkbox_editor/glade/preferences.glade 2012-08-02 01:37:20 +0000
45@@ -384,6 +384,27 @@
46 </packing>
47 </child>
48 <child>
49+ <object class="GtkCheckButton" id="whitelist_attachments">
50+ <property name="label" translatable="yes">Whitelist attachment jobs</property>
51+ <property name="visible">True</property>
52+ <property name="can_focus">True</property>
53+ <property name="receives_default">False</property>
54+ <property name="tooltip_text" translatable="yes">All attachments will be implicitly selected when launching a whitelist so that the submission.xml file contains all necessary data</property>
55+ <property name="use_action_appearance">False</property>
56+ <property name="draw_indicator">True</property>
57+ <child internal-child="accessible">
58+ <object class="AtkObject" id="whitelist_attachments-atkobject">
59+ <property name="AtkObject::accessible-name" translatable="yes">preferences_whitelist_attachments</property>
60+ </object>
61+ </child>
62+ </object>
63+ <packing>
64+ <property name="expand">False</property>
65+ <property name="fill">True</property>
66+ <property name="position">2</property>
67+ </packing>
68+ </child>
69+ <child>
70 <object class="GtkCheckButton" id="whitelist_resources">
71 <property name="label" translatable="yes">Whitelist resource jobs</property>
72 <property name="visible">True</property>
73@@ -401,7 +422,7 @@
74 <packing>
75 <property name="expand">False</property>
76 <property name="fill">True</property>
77- <property name="position">2</property>
78+ <property name="position">3</property>
79 </packing>
80 </child>
81 <child>
82@@ -451,7 +472,7 @@
83 <packing>
84 <property name="expand">False</property>
85 <property name="fill">True</property>
86- <property name="position">3</property>
87+ <property name="position">4</property>
88 </packing>
89 </child>
90 </object>
91
92=== modified file 'checkbox_editor/model.py'
93--- checkbox_editor/model.py 2012-07-06 09:24:48 +0000
94+++ checkbox_editor/model.py 2012-08-02 01:37:20 +0000
95@@ -103,41 +103,53 @@
96 yield subjob_row
97
98
99- def get_selected_rows(self, parent=None, include_resources=False):
100+ def get_selected_rows(self, parent=None, include_attachments=False, include_resources=False):
101 """
102 Return all selected rows
103 possibly including resources depending on configuration
104 """
105- if include_resources:
106- def has_child_resources(row):
107+ if include_resources or include_attachments:
108+ def check_plugins(description, plugins):
109+ # Only check descriptions without dependencies,
110+ # to skip attachments output by other jobs, and names
111+ # without a slash, to skip jobs in suites.
112+ return (description
113+ and 'depends' not in description
114+ and '/' not in description['name']
115+ and description.get('plugin') in plugins)
116+
117+ def has_child_plugins(row, plugins):
118 """
119- Return True if any child is a resource
120+ Return True if any child has a matching plugin
121 """
122 for child_row in self.get_all_rows(row):
123- description = child_row[self.DESCRIPTION]
124- if (description
125- and description.get('plugin') == 'resource'):
126+ if check_plugins(child_row[self.DESCRIPTION], plugins):
127 return True
128 return False
129
130 def is_row_selected(row):
131 """
132- Filter selected rows
133- and resources rows according to configuration
134+ Filter selected rows, resources rows
135+ and attachments rows according to configuration
136 """
137 # Filter selected rows
138 if row[self.SELECTED]:
139 return True
140
141- # Filter resources rows
142+ # Filter resources or attachments rows
143+ plugins = []
144 if self.preferences.general['whitelist_resources']:
145+ plugins.append('resource')
146+ if self.preferences.general['whitelist_attachments']:
147+ plugins.append('attachment')
148+
149+ if plugins:
150 description = row[self.DESCRIPTION]
151 if description:
152- plugin = description.get('plugin')
153- if plugin == 'resource':
154+ if check_plugins(description, plugins):
155 return True
156 else:
157- return has_child_resources(row)
158+ return has_child_plugins(row, plugins)
159
160 return False
161 else:
162
163=== modified file 'checkbox_editor/preferences.py'
164--- checkbox_editor/preferences.py 2012-04-19 11:07:42 +0000
165+++ checkbox_editor/preferences.py 2012-08-02 01:37:20 +0000
166@@ -54,6 +54,7 @@
167 'replace_tabs_with_spaces': True,
168 'number_of_spaces': 4,
169 'checkbox_data_cleanup': True,
170+ 'whitelist_attachments': True,
171 'whitelist_resources': True,
172 }
173 self.environment = {}
174@@ -86,7 +87,7 @@
175 if option in general_options:
176 self.general[option] = parser.get('general', option)
177 for option in ('checkbox_data_cleanup', 'replace_tabs_with_spaces',
178- 'whitelist_resources'):
179+ 'whitelist_attachments', 'whitelist_resources'):
180 if option in general_options:
181 self.general[option] = parser.getboolean('general', option)
182 if 'number_of_spaces' in general_options:
183@@ -325,7 +326,8 @@
184 """
185 GENERAL_WIDGET_NAMES = ('checkbox_binary', 'checkbox_data_cleanup',
186 'replace_tabs_with_spaces', 'number_of_spaces',
187- 'whitelist_resources', 'extra_validation_file'
188+ 'whitelist_attachments', 'whitelist_resources',
189+ 'extra_validation_file'
190 )
191 VC_WIDGET_NAMES = ('pull_on_open', 'commit_on_save', 'push_on_close',
192 'pull_branch', 'push_branch',
193
194=== modified file 'checkbox_editor/whitelist.py'
195--- checkbox_editor/whitelist.py 2012-07-06 14:24:29 +0000
196+++ checkbox_editor/whitelist.py 2012-08-02 01:37:20 +0000
197@@ -7,6 +7,7 @@
198
199 import re, logging
200 from datetime import datetime
201+from functools import partial
202
203 from .data import Reporter
204 from .util import handle_exceptions, MessageDialogRunner
205@@ -459,18 +460,28 @@
206
207 selected_patterns = []
208
209+ def is_plugin(row, plugin):
210+ # Only check descriptions without dependencies,
211+ # to skip attachments output by other jobs, and names
212+ # without a slash, to skip jobs in suites.
213+ description = row[self.main_model.DESCRIPTION]
214+ return (description
215+ and 'depends' not in description
216+ and '/' not in description['name']
217+ and description.get('plugin') == plugin)
218+
219 if self.main_model.preferences.general['whitelist_resources']:
220- def is_resource(row):
221- description = row[self.main_model.DESCRIPTION]
222- if description:
223- plugin = description.get('plugin')
224- if plugin == 'resource':
225- return True
226- return False
227- resource_rows = self.main_model.get_matching_rows(is_resource)
228+ resource_func = partial(is_plugin, plugin='resource')
229+ resource_rows = self.main_model.get_matching_rows(resource_func)
230 for resource_row in resource_rows:
231 self.main_model.set_selected(resource_row, True)
232
233+ if self.main_model.preferences.general['whitelist_attachments']:
234+ attachment_func = partial(is_plugin, plugin='attachment')
235+ attachment_rows = self.main_model.get_matching_rows(attachment_func)
236+ for attachment_row in attachment_rows:
237+ self.main_model.set_selected(attachment_row, True)
238+
239 for name, _ in self.model:
240 references = self.main_model.name_cache[name]
241 rows = (self.main_model[reference.get_path()]
242
243=== modified file 'templates/checkbox/data/.checkbox-editor.cfg.tmpl'
244--- templates/checkbox/data/.checkbox-editor.cfg.tmpl 2011-04-11 13:49:20 +0000
245+++ templates/checkbox/data/.checkbox-editor.cfg.tmpl 2012-08-02 01:37:20 +0000
246@@ -13,4 +13,5 @@
247 replace_tabs_with_spaces = True
248 number_of_spaces = 4
249 checkbox_binary = bin/checkbox-{{name}}-gtk
250+whitelist_attachments = True
251 whitelist_resources = True

Subscribers

People subscribed via source and target branches

to all changes: