Merge lp:~dooferlad/linaro-image-tools/fetch_image_gui into lp:linaro-image-tools/11.11
- fetch_image_gui
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Loïc Minier |
Proposed branch: | lp:~dooferlad/linaro-image-tools/fetch_image_gui |
Merge into: | lp:linaro-image-tools/11.11 |
Prerequisite: | lp:~dooferlad/linaro-image-tools/fetch_image_server_indexer |
Diff against target: |
1749 lines (+1740/-0) 2 files modified
fetch_image.py (+79/-0) fetch_image_ui.py (+1661/-0) |
To merge this branch: | bzr merge lp:~dooferlad/linaro-image-tools/fetch_image_gui |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email: mp+66917@code.launchpad.net |
This proposal supersedes a proposal from 2011-06-17.
Commit message
Description of the change
Initial merge request of fetch_image_ui.py - a GUI with similar functionality to fetch_image.py.
The GUI guides the user through the process of creating an image for their ARM hardware. Files are pulled as required from release.linaro.org and snapshots.
--
Now with split up unit tests!
James Westby (james-w) wrote : Posted in a previous version of this proposal | # |
James Westby (james-w) : Posted in a previous version of this proposal | # |
James Tunnicliffe (dooferlad) wrote : Posted in a previous version of this proposal | # |
On 24 June 2011 21:58, James Westby <email address hidden> wrote:
> 133 + if(style != None):
> 134 + radio_button = wx.RadioButton(
> 135 + else:
> 136 + radio_button = wx.RadioButton(
>
> I think that's unnecessary isn't it? style=None is usually the default.
In this case, sadly not.
> (also we usually avoid spaces around = in method calls)
Noted and fixed.
> 226 + if "panda" in self.settings[
> 227 + default_hardware = "panda"
>
> Was this just to make your testing easier? I don't think that the choice should
> have a default until we're in a position to remember their last answer.
Mostly yes. I am sure we could have nothing selected and the next
button disabled by default. I didn't think it was too cheeky to do
since there are a lot of panda boards in the hands of Linaro engineers
:-) I am sure in the future we could remember some choices between
runs as well, which would be useful for just getting the latest build
for your board.
> 1562 + def test_url_
>
> Please break up this test in to several tests. These sort of test cases
> are a nightmare to debug. Ideally each test method should assert a single
> thing.
I have split it into three, with functions named such that if test x
requires test y to pass before it will pass, x will run first.
--
James Tunnicliffe
James Westby (james-w) : | # |
Loïc Minier (lool) wrote : | # |
This is marked as approved but not merged, but I see similar code in linaro-image-tools; I guess this really was superseded?
James Tunnicliffe (dooferlad) wrote : | # |
Indeed it was.
On 8 August 2011 22:51, Loïc Minier <email address hidden> wrote:
> This is marked as approved but not merged, but I see similar code in linaro-image-tools; I guess this really was superseded?
> --
> https:/
> You are the owner of lp:~dooferlad/linaro-image-tools/fetch_image_gui.
>
--
James Tunnicliffe
Unmerged revisions
- 362. By James Tunnicliffe
-
Slight style clean up.
- 361. By James Tunnicliffe
-
Split unit test into three cases.
Preview Diff
1 | === added file 'fetch_image.py' | |||
2 | --- fetch_image.py 1970-01-01 00:00:00 +0000 | |||
3 | +++ fetch_image.py 2011-07-05 15:28:36 +0000 | |||
4 | @@ -0,0 +1,79 @@ | |||
5 | 1 | #!/usr/bin/env python | ||
6 | 2 | # Copyright (C) 2010, 2011 Linaro | ||
7 | 3 | # | ||
8 | 4 | # Author: James Tunnicliffe <james.tunnicliffe@linaro.org> | ||
9 | 5 | # | ||
10 | 6 | # This file is part of Linaro Image Tools. | ||
11 | 7 | # | ||
12 | 8 | # Linaro Image Tools is free software; you can redistribute it and/or | ||
13 | 9 | # modify it under the terms of the GNU General Public License | ||
14 | 10 | # as published by the Free Software Foundation; either version 2 | ||
15 | 11 | # of the License, or (at your option) any later version. | ||
16 | 12 | # | ||
17 | 13 | # Linaro Image Tools is distributed in the hope that it will be useful, | ||
18 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | 16 | # GNU General Public License for more details. | ||
21 | 17 | # | ||
22 | 18 | # You should have received a copy of the GNU General Public License | ||
23 | 19 | # along with Linaro Image Tools; if not, write to the Free Software | ||
24 | 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
25 | 21 | # USA. | ||
26 | 22 | |||
27 | 23 | import sys | ||
28 | 24 | import os | ||
29 | 25 | import linaro_image_tools.FetchImage as FetchImage | ||
30 | 26 | import logging | ||
31 | 27 | |||
32 | 28 | |||
33 | 29 | def main(): | ||
34 | 30 | file_handler = FetchImage.FileHandler() | ||
35 | 31 | config = FetchImage.FetchImageConfig() | ||
36 | 32 | |||
37 | 33 | # Unfortunately we need to do a bit of a hack here and look for some | ||
38 | 34 | # options before performing a full options parse. | ||
39 | 35 | clean_cache = ("--clean-cache" in sys.argv[1:] | ||
40 | 36 | or "-x" in sys.argv[1:]) | ||
41 | 37 | |||
42 | 38 | force_download = ("--force-download" in sys.argv[1:] | ||
43 | 39 | or "-d" in sys.argv[1:]) | ||
44 | 40 | |||
45 | 41 | if clean_cache: | ||
46 | 42 | file_handler.clean_cache() | ||
47 | 43 | |||
48 | 44 | # If the settings file and server index need updating, grab them | ||
49 | 45 | file_handler.update_files_from_server(force_download) | ||
50 | 46 | |||
51 | 47 | # Load settings YAML, which defines the parameters we ask for and | ||
52 | 48 | # acceptable responses from the user | ||
53 | 49 | config.read_config(file_handler.settings_file) | ||
54 | 50 | |||
55 | 51 | # Using the settings that the YAML defines as what we need for a build, | ||
56 | 52 | # generate a command line parser and parse the command line | ||
57 | 53 | config.parse_args(sys.argv[1:]) | ||
58 | 54 | |||
59 | 55 | if config.args['platform'] == "snapshot": | ||
60 | 56 | config.args['release_or_snapshot'] = "snapshot" | ||
61 | 57 | else: | ||
62 | 58 | config.args['release_or_snapshot'] = "release" | ||
63 | 59 | |||
64 | 60 | # Using the config we have, look up URLs to download data from in the | ||
65 | 61 | # server index | ||
66 | 62 | db = FetchImage.DB(file_handler.index_file) | ||
67 | 63 | |||
68 | 64 | image_url, hwpack_url = db.get_image_and_hwpack_urls(config.args) | ||
69 | 65 | |||
70 | 66 | if(image_url and hwpack_url): | ||
71 | 67 | |||
72 | 68 | tools_dir = os.path.dirname(__file__) | ||
73 | 69 | if tools_dir == '': | ||
74 | 70 | tools_dir = None | ||
75 | 71 | |||
76 | 72 | file_handler.create_media(image_url, hwpack_url, | ||
77 | 73 | config.args, tools_dir) | ||
78 | 74 | else: | ||
79 | 75 | logging.error( | ||
80 | 76 | "Unable to find files that match the parameters specified") | ||
81 | 77 | |||
82 | 78 | if __name__ == '__main__': | ||
83 | 79 | main() | ||
84 | 0 | 80 | ||
85 | === added file 'fetch_image_ui.py' | |||
86 | --- fetch_image_ui.py 1970-01-01 00:00:00 +0000 | |||
87 | +++ fetch_image_ui.py 2011-07-05 15:28:36 +0000 | |||
88 | @@ -0,0 +1,1661 @@ | |||
89 | 1 | #!/usr/bin/env python | ||
90 | 2 | # Copyright (C) 2010, 2011 Linaro | ||
91 | 3 | # | ||
92 | 4 | # Author: James Tunnicliffe <james.tunnicliffe@linaro.org> | ||
93 | 5 | # | ||
94 | 6 | # This file is part of Linaro Image Tools. | ||
95 | 7 | # | ||
96 | 8 | # Linaro Image Tools is free software; you can redistribute it and/or | ||
97 | 9 | # modify it under the terms of the GNU General Public License | ||
98 | 10 | # as published by the Free Software Foundation; either version 2 | ||
99 | 11 | # of the License, or (at your option) any later version. | ||
100 | 12 | # | ||
101 | 13 | # Linaro Image Tools is distributed in the hope that it will be useful, | ||
102 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
103 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
104 | 16 | # GNU General Public License for more details. | ||
105 | 17 | # | ||
106 | 18 | # You should have received a copy of the GNU General Public License | ||
107 | 19 | # along with Linaro Image Tools; if not, write to the Free Software | ||
108 | 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, | ||
109 | 21 | # USA. | ||
110 | 22 | |||
111 | 23 | import wx | ||
112 | 24 | import wx.wizard | ||
113 | 25 | import wx.wizard as wiz | ||
114 | 26 | import sys | ||
115 | 27 | import re | ||
116 | 28 | import os | ||
117 | 29 | import linaro_image_tools.FetchImage as FetchImage | ||
118 | 30 | import string | ||
119 | 31 | import unittest | ||
120 | 32 | import operator | ||
121 | 33 | import Queue | ||
122 | 34 | |||
123 | 35 | |||
124 | 36 | def add_button(bind_to, | ||
125 | 37 | sizer, | ||
126 | 38 | label, | ||
127 | 39 | style, | ||
128 | 40 | select_event, | ||
129 | 41 | hover_event, | ||
130 | 42 | unhover_event): | ||
131 | 43 | |||
132 | 44 | """Create a radio button with event bindings.""" | ||
133 | 45 | if(style != None): | ||
134 | 46 | radio_button = wx.RadioButton(bind_to, label=label, style=style) | ||
135 | 47 | else: | ||
136 | 48 | radio_button = wx.RadioButton(bind_to, label=label) | ||
137 | 49 | |||
138 | 50 | sizer.Add(radio_button, 0, wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 5) | ||
139 | 51 | bind_to.Bind(wx.EVT_RADIOBUTTON, select_event, radio_button) | ||
140 | 52 | wx.EVT_ENTER_WINDOW(radio_button, hover_event) | ||
141 | 53 | wx.EVT_LEAVE_WINDOW(radio_button, unhover_event) | ||
142 | 54 | |||
143 | 55 | return radio_button | ||
144 | 56 | |||
145 | 57 | |||
146 | 58 | class ReleaseOrSnapshotPage(wiz.PyWizardPage): | ||
147 | 59 | """Ask the user if they want to use a release or a snapshot""" | ||
148 | 60 | |||
149 | 61 | def __init__(self, parent, config): | ||
150 | 62 | wiz.PyWizardPage.__init__(self, parent) | ||
151 | 63 | self.config = config | ||
152 | 64 | self.settings = self.config.settings | ||
153 | 65 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
154 | 66 | self.next = None | ||
155 | 67 | self.prev = None | ||
156 | 68 | |||
157 | 69 | self.sizer.Add(wx.StaticText(self, -1, | ||
158 | 70 | """This Wizard will write an operating system of your choosing to | ||
159 | 71 | either a disk image or to an MMC card. First we need to know if | ||
160 | 72 | your priority is stability or the latest and greatest features.""")) | ||
161 | 73 | |||
162 | 74 | self.box1 = wx.BoxSizer(wx.VERTICAL) | ||
163 | 75 | |||
164 | 76 | self.button_text = {'release': "I would like to run stable, " | ||
165 | 77 | "tested software.", | ||
166 | 78 | 'snapshot': "I would like to run untested, but " | ||
167 | 79 | "more up-to-date software."} | ||
168 | 80 | |||
169 | 81 | add_button(self, self.box1, self.button_text['release'], | ||
170 | 82 | wx.RB_GROUP, self.event_radio_button_select, None, None) | ||
171 | 83 | |||
172 | 84 | # Save the setting for the default selected value | ||
173 | 85 | self.settings['release_or_snapshot'] = "release" | ||
174 | 86 | |||
175 | 87 | add_button(self, self.box1, self.button_text['snapshot'], None, | ||
176 | 88 | self.event_radio_button_select, None, None) | ||
177 | 89 | |||
178 | 90 | self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
179 | 91 | |||
180 | 92 | self.SetSizerAndFit(self.sizer) | ||
181 | 93 | self.sizer.Fit(self) | ||
182 | 94 | self.Move((50, 50)) | ||
183 | 95 | |||
184 | 96 | def event_radio_button_select(self, event): | ||
185 | 97 | self.radio_selected = event.GetEventObject().GetLabel() | ||
186 | 98 | # The radio button can be release, snapshot or "latest snapshot" | ||
187 | 99 | if(self.radio_selected == self.button_text['release']): | ||
188 | 100 | self.settings['release_or_snapshot'] = "release" | ||
189 | 101 | else: | ||
190 | 102 | self.settings['release_or_snapshot'] = "snapshot" | ||
191 | 103 | |||
192 | 104 | def SetNext(self, next): | ||
193 | 105 | self.next = next | ||
194 | 106 | |||
195 | 107 | def GetNext(self): | ||
196 | 108 | return self.next | ||
197 | 109 | |||
198 | 110 | |||
199 | 111 | class AboutMyHardwarePage(wiz.WizardPageSimple): | ||
200 | 112 | """Ask the user about their hardware. This only asks about the board, not | ||
201 | 113 | any specific hardware packs because there can be multiple names for the | ||
202 | 114 | same hardware pack or sometimes a hardware pack is only available in the | ||
203 | 115 | releases or snapshots repository. We whittle down the choice as we go | ||
204 | 116 | and the user can chose a hardare pack (if they don't like the default) | ||
205 | 117 | under advanced options in the Linaro Media Create options | ||
206 | 118 | page""" | ||
207 | 119 | |||
208 | 120 | def __init__(self, parent, config, db, width): | ||
209 | 121 | wiz.WizardPageSimple.__init__(self, parent) | ||
210 | 122 | self.settings = config.settings | ||
211 | 123 | self.db = db | ||
212 | 124 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
213 | 125 | self.box1 = wx.BoxSizer(wx.VERTICAL) | ||
214 | 126 | self.box2 = wx.BoxSizer(wx.VERTICAL) | ||
215 | 127 | |||
216 | 128 | header = wx.StaticText(self, | ||
217 | 129 | label = "Please select the hardware that you " | ||
218 | 130 | "would like to build an image for from " | ||
219 | 131 | "the following list") | ||
220 | 132 | |||
221 | 133 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
222 | 134 | |||
223 | 135 | #--- Hardware Combo Box --- | ||
224 | 136 | # Make sure that the displayed release is the one set in settings if | ||
225 | 137 | # no selection is made | ||
226 | 138 | if "panda" in self.settings['choice']['hardware'].keys(): | ||
227 | 139 | default_hardware = "panda" | ||
228 | 140 | else: | ||
229 | 141 | default_hardware = self.settings['choice']['hardware'].keys()[-1] | ||
230 | 142 | |||
231 | 143 | self.settings['hardware'] = default_hardware | ||
232 | 144 | self.settings['compatable_hwpacks'] = ( | ||
233 | 145 | self.settings['choice']['hwpack'][self.settings['hardware']]) | ||
234 | 146 | |||
235 | 147 | self.cb_hardware = wx.ComboBox(self, | ||
236 | 148 | value = | ||
237 | 149 | self.settings['choice']['hardware'][default_hardware], | ||
238 | 150 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
239 | 151 | |||
240 | 152 | self.Bind(wx.EVT_COMBOBOX, | ||
241 | 153 | self.event_combo_box_hardware, | ||
242 | 154 | self.cb_hardware) | ||
243 | 155 | self.box1.Add(self.cb_hardware, 0, | ||
244 | 156 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 5) | ||
245 | 157 | |||
246 | 158 | self.sizer.Add(header) | ||
247 | 159 | self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
248 | 160 | self.sizer.Add(self.box2, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
249 | 161 | self.SetSizerAndFit(self.sizer) | ||
250 | 162 | self.sizer.Fit(self) | ||
251 | 163 | self.Move((50, 50)) | ||
252 | 164 | |||
253 | 165 | def on_page_changing(self): | ||
254 | 166 | self.update_hardware_box() | ||
255 | 167 | |||
256 | 168 | def update_hardware_box(self): | ||
257 | 169 | self.cb_hardware.Clear() | ||
258 | 170 | |||
259 | 171 | sorted_hardware_names = sorted(self.settings['choice']['hardware'] | ||
260 | 172 | .iteritems(), | ||
261 | 173 | key=operator.itemgetter(1)) | ||
262 | 174 | |||
263 | 175 | table = self.settings['release_or_snapshot'] + "_hwpacks" | ||
264 | 176 | |||
265 | 177 | for device_name, human_readable_name in sorted_hardware_names: | ||
266 | 178 | for hwpack in self.settings['choice']['hwpack'][device_name]: | ||
267 | 179 | if self.db.hardware_is_available_in_table(table, hwpack): | ||
268 | 180 | self.cb_hardware.Append(human_readable_name, device_name) | ||
269 | 181 | break | ||
270 | 182 | |||
271 | 183 | #--- Event(s) --- | ||
272 | 184 | def event_combo_box_hardware(self, event): | ||
273 | 185 | self.settings['hardware'] = (event | ||
274 | 186 | .GetEventObject() | ||
275 | 187 | .GetClientData(event.GetSelection()) | ||
276 | 188 | .encode('ascii')) | ||
277 | 189 | |||
278 | 190 | self.settings['compatable_hwpacks'] = ( | ||
279 | 191 | self.settings['choice']['hwpack'][self.settings['hardware']]) | ||
280 | 192 | #--- END event(s) --- | ||
281 | 193 | |||
282 | 194 | |||
283 | 195 | class SelectStableRelease(wiz.WizardPageSimple): | ||
284 | 196 | """Ask the user which Linaro release they would like to run.""" | ||
285 | 197 | def __init__(self, parent, config, db, width): | ||
286 | 198 | wiz.WizardPageSimple.__init__(self, parent) | ||
287 | 199 | self.settings = config.settings | ||
288 | 200 | self.db = db | ||
289 | 201 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
290 | 202 | self.wizard = parent | ||
291 | 203 | |||
292 | 204 | header = wx.StaticText(self, label = "Please select the stable Linaro " | ||
293 | 205 | "release you would like to use") | ||
294 | 206 | |||
295 | 207 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
296 | 208 | |||
297 | 209 | self.sizer.Add(header) | ||
298 | 210 | self.box1 = wx.BoxSizer(wx.VERTICAL) | ||
299 | 211 | |||
300 | 212 | platforms = [] | ||
301 | 213 | for key, value in self.settings['choice']['platform'].items(): | ||
302 | 214 | platforms.append(key) | ||
303 | 215 | |||
304 | 216 | default_release = self.settings['UI']['translate'][platforms[-1]] | ||
305 | 217 | self.cb_release = wx.ComboBox(self, | ||
306 | 218 | value = default_release, | ||
307 | 219 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
308 | 220 | self.Bind(wx.EVT_COMBOBOX, | ||
309 | 221 | self.event_combo_box_release, | ||
310 | 222 | self.cb_release) | ||
311 | 223 | |||
312 | 224 | if(default_release in self.settings['UI']['translate']): | ||
313 | 225 | default_release = self.settings['UI']['translate'][default_release] | ||
314 | 226 | self.settings['platform'] = ( | ||
315 | 227 | self.settings['UI']['reverse-translate'][default_release]) | ||
316 | 228 | |||
317 | 229 | for item in platforms: | ||
318 | 230 | if(item in self.settings['UI']['translate']): | ||
319 | 231 | new_item = self.settings['UI']['translate'][item] | ||
320 | 232 | item = new_item | ||
321 | 233 | |||
322 | 234 | self.cb_release.Append(item, item.upper()) | ||
323 | 235 | |||
324 | 236 | self.cb_build = wx.ComboBox(self, | ||
325 | 237 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
326 | 238 | self.Bind(wx.EVT_COMBOBOX, self.event_combo_box_build, self.cb_build) | ||
327 | 239 | |||
328 | 240 | self.box1.Add(self.cb_release, 0, | ||
329 | 241 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 5) | ||
330 | 242 | self.box1.Add(self.cb_build, 0, | ||
331 | 243 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 5) | ||
332 | 244 | self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
333 | 245 | self.SetSizerAndFit(self.sizer) | ||
334 | 246 | self.sizer.Fit(self) | ||
335 | 247 | self.Move((50, 50)) | ||
336 | 248 | |||
337 | 249 | def update_build_box(self): | ||
338 | 250 | """Depending on what hardware has been chosen, the OS list may be | ||
339 | 251 | restricted. Filter out anything that is unavailable.""" | ||
340 | 252 | self.cb_build.Clear() | ||
341 | 253 | |||
342 | 254 | builds = self.db.get_builds(self.settings['platform']) | ||
343 | 255 | self.cb_build.SetValue("No build available") | ||
344 | 256 | |||
345 | 257 | for build in builds: | ||
346 | 258 | if( self.db.hardware_is_available_for_platform_build( | ||
347 | 259 | self.settings['compatable_hwpacks'], | ||
348 | 260 | self.settings['platform'], | ||
349 | 261 | build) | ||
350 | 262 | and self.db.build_is_available_for_platform_image( | ||
351 | 263 | "release_binaries", | ||
352 | 264 | self.settings['platform'], | ||
353 | 265 | self.settings['image'], | ||
354 | 266 | build)): | ||
355 | 267 | |||
356 | 268 | self.cb_build.Append(build) | ||
357 | 269 | self.cb_build.SetValue(build) | ||
358 | 270 | self.settings['release_build'] = build | ||
359 | 271 | |||
360 | 272 | available_hwpacks = ( | ||
361 | 273 | self.db.get_available_hwpacks_for_hardware_build_plaform( | ||
362 | 274 | self.settings['compatable_hwpacks'], | ||
363 | 275 | self.settings['platform'], | ||
364 | 276 | self.settings['release_build'])) | ||
365 | 277 | |||
366 | 278 | if len(available_hwpacks): | ||
367 | 279 | self.settings['hwpack'] = available_hwpacks[0] | ||
368 | 280 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
369 | 281 | else: | ||
370 | 282 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
371 | 283 | |||
372 | 284 | def update_release_and_build_boxes(self): | ||
373 | 285 | """Depending on what hardware has been chosen, some builds may be | ||
374 | 286 | unavailable...""" | ||
375 | 287 | self.cb_release.Clear() | ||
376 | 288 | |||
377 | 289 | default_release = None | ||
378 | 290 | for platform, value in self.settings['choice']['platform'].items(): | ||
379 | 291 | if(self.db.hardware_is_available_for_platform( | ||
380 | 292 | self.settings['compatable_hwpacks'], | ||
381 | 293 | platform) | ||
382 | 294 | and len(self.db.execute_return_list( | ||
383 | 295 | 'select * from release_binaries ' | ||
384 | 296 | 'where platform == ? and image == ?', | ||
385 | 297 | (platform, self.settings['image'])))): | ||
386 | 298 | |||
387 | 299 | if(platform in self.settings['UI']['translate']): | ||
388 | 300 | platform = self.settings['UI']['translate'][platform] | ||
389 | 301 | |||
390 | 302 | self.cb_release.Append(platform, platform.upper()) | ||
391 | 303 | if not default_release or default_release < platform: | ||
392 | 304 | default_release = platform | ||
393 | 305 | |||
394 | 306 | self.settings['platform'] = ( | ||
395 | 307 | self.settings['UI']['reverse-translate'][default_release]) | ||
396 | 308 | self.cb_release.SetValue(default_release) | ||
397 | 309 | self.update_build_box() | ||
398 | 310 | |||
399 | 311 | #--- Event(s) --- | ||
400 | 312 | def event_combo_box_release(self, evt): | ||
401 | 313 | str = evt.GetString().encode('ascii').lower() | ||
402 | 314 | if(str in self.settings['UI']['reverse-translate']): | ||
403 | 315 | str = self.settings['UI']['reverse-translate'][str] | ||
404 | 316 | self.settings['platform'] = str | ||
405 | 317 | |||
406 | 318 | self.update_build_box() | ||
407 | 319 | |||
408 | 320 | def event_combo_box_build(self, evt): | ||
409 | 321 | self.settings['release_build'] = evt.GetString().encode('ascii') | ||
410 | 322 | #--- END event(s) --- | ||
411 | 323 | |||
412 | 324 | |||
413 | 325 | class SelectSnapshot(wiz.WizardPageSimple): | ||
414 | 326 | """Present the user with a calendar widget and a list of builds available | ||
415 | 327 | on the selected date so they can chose a snapshot. Filter out days when | ||
416 | 328 | their chosen hardware does not have an available build.""" | ||
417 | 329 | |||
418 | 330 | def __init__(self, parent, config, db, width): | ||
419 | 331 | wiz.WizardPageSimple.__init__(self, parent) | ||
420 | 332 | self.settings = config.settings | ||
421 | 333 | self.db = db | ||
422 | 334 | self.wizard = parent | ||
423 | 335 | self.width = width | ||
424 | 336 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
425 | 337 | |||
426 | 338 | header = wx.StaticText(self, | ||
427 | 339 | label = "Builds are created most days. First " | ||
428 | 340 | "please select the day on which the " | ||
429 | 341 | "build you would like to use was built," | ||
430 | 342 | " then, if there was more than one " | ||
431 | 343 | "build that day you will be able to " | ||
432 | 344 | "select the build number.") | ||
433 | 345 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
434 | 346 | |||
435 | 347 | box1 = wx.BoxSizer(wx.VERTICAL) | ||
436 | 348 | self.sizer.Add(header) | ||
437 | 349 | |||
438 | 350 | # Set today as the default build date in settings | ||
439 | 351 | # (matches the date picker) | ||
440 | 352 | self.today = wx.DateTime() | ||
441 | 353 | self.today.SetToCurrent() | ||
442 | 354 | self.settings['build_date'] = self.today.FormatISODate().encode('ascii') | ||
443 | 355 | |||
444 | 356 | dpc = wx.DatePickerCtrl(self, size = (120, -1), | ||
445 | 357 | style = wx.DP_DEFAULT) | ||
446 | 358 | self.Bind(wx.EVT_DATE_CHANGED, self.on_date_changed, dpc) | ||
447 | 359 | |||
448 | 360 | #--- Build number Combo Box --- | ||
449 | 361 | # Make sure that the displayed build is the one set in settings if no | ||
450 | 362 | # selection is made | ||
451 | 363 | self.settings['build_number'] = 0 | ||
452 | 364 | self.update_build() | ||
453 | 365 | self.cb_build = wx.ComboBox(self, | ||
454 | 366 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
455 | 367 | self.Bind(wx.EVT_COMBOBOX, self.event_combo_box_build, self.cb_build) | ||
456 | 368 | |||
457 | 369 | #--- Layout --- | ||
458 | 370 | # -- Combo boxes for hardware and image selection -- | ||
459 | 371 | |||
460 | 372 | grid2 = wx.FlexGridSizer(0, 2, 0, 0) | ||
461 | 373 | grid2.Add(dpc, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
462 | 374 | grid2.Add(self.cb_build, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
463 | 375 | |||
464 | 376 | box1.Add(grid2, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
465 | 377 | |||
466 | 378 | self.sizer.Add(box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
467 | 379 | |||
468 | 380 | self.help_text = wx.StaticText(self) | ||
469 | 381 | self.sizer.Add(self.help_text, 1, wx.EXPAND, 5) | ||
470 | 382 | |||
471 | 383 | self.SetSizer(self.sizer) | ||
472 | 384 | self.sizer.Fit(self) | ||
473 | 385 | self.Move((50, 50)) | ||
474 | 386 | |||
475 | 387 | def update_platform(self): | ||
476 | 388 | build_and_date = self.settings['snapshot_build'].split(":") | ||
477 | 389 | |||
478 | 390 | if len(build_and_date) == 2: | ||
479 | 391 | self.settings['platform'] = ( | ||
480 | 392 | self.db.execute_return_list( | ||
481 | 393 | "select platform from snapshot_binaries " | ||
482 | 394 | "where date == ? and build == ?", | ||
483 | 395 | (build_and_date[0], build_and_date[1]))) | ||
484 | 396 | |||
485 | 397 | if len(self.settings['platform']) > 0: | ||
486 | 398 | self.settings['platform'] = self.settings['platform'][0][0] | ||
487 | 399 | |||
488 | 400 | def update_build(self): | ||
489 | 401 | small_date = re.sub('-', '', self.settings['build_date']) | ||
490 | 402 | self.settings['snapshot_build'] = (small_date | ||
491 | 403 | + ":" | ||
492 | 404 | + str(self.settings['build_number'])) | ||
493 | 405 | |||
494 | 406 | def fill_build_combo_box_for_date(self, date): | ||
495 | 407 | """Every time a date is chosen, this function should be called. It will | ||
496 | 408 | check to see if a compatible build is available. If there isn't, it | ||
497 | 409 | will search for one and provide some help text to tell the user when | ||
498 | 410 | compatable builds were built.""" | ||
499 | 411 | # Re-populate the build combo box | ||
500 | 412 | |||
501 | 413 | self.cb_build.Clear() | ||
502 | 414 | |||
503 | 415 | builds = self.db.get_binary_builds_on_day_from_db( | ||
504 | 416 | self.settings['image'], | ||
505 | 417 | date, | ||
506 | 418 | self.settings['compatable_hwpacks']) | ||
507 | 419 | |||
508 | 420 | if len(builds): | ||
509 | 421 | max = 0 | ||
510 | 422 | for item in builds: | ||
511 | 423 | #Always get a tuple, only interested in the first entry | ||
512 | 424 | item = item[0] | ||
513 | 425 | self.cb_build.Append(item, item.upper()) | ||
514 | 426 | |||
515 | 427 | if item > max: | ||
516 | 428 | max = item | ||
517 | 429 | |||
518 | 430 | self.cb_build.SetValue(max) | ||
519 | 431 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
520 | 432 | self.help_text.SetLabel("") | ||
521 | 433 | |||
522 | 434 | else: | ||
523 | 435 | self.cb_build.SetValue("No builds available") | ||
524 | 436 | future_date, past_date = self.db.get_next_prev_day_with_builds( | ||
525 | 437 | self.settings['image'], | ||
526 | 438 | date, | ||
527 | 439 | self.settings['compatable_hwpacks']) | ||
528 | 440 | |||
529 | 441 | help_text = None | ||
530 | 442 | |||
531 | 443 | if future_date and past_date: | ||
532 | 444 | help_text = ("There are no builds that match your " | ||
533 | 445 | "specifications available on the selected date. " | ||
534 | 446 | "The previous build was on " + past_date + | ||
535 | 447 | " and the next build was on " + future_date + ".") | ||
536 | 448 | elif future_date: | ||
537 | 449 | help_text = ("There are no builds that match your " | ||
538 | 450 | "specifications available on the selected date. " | ||
539 | 451 | "The next build was on " + future_date + | ||
540 | 452 | " and I couldn't find a past build (looked one " | ||
541 | 453 | "year back from the selected date).") | ||
542 | 454 | elif past_date: | ||
543 | 455 | help_text = ("There are no builds that match your " | ||
544 | 456 | "specifications available on the selected date. " | ||
545 | 457 | "The previous build was on " + past_date) | ||
546 | 458 | if date != self.today.FormatISODate().encode('ascii'): | ||
547 | 459 | help_text += (" and I couldn't find a future build (I " | ||
548 | 460 | "looked up to one year forward from the " | ||
549 | 461 | "selected date).") | ||
550 | 462 | else: | ||
551 | 463 | help_text = ("I could not find any builds that match your " | ||
552 | 464 | "specifications close to the selected date (I " | ||
553 | 465 | "looked forward and back one year from the " | ||
554 | 466 | "selected date).") | ||
555 | 467 | |||
556 | 468 | self.help_text.SetLabel(help_text) | ||
557 | 469 | self.help_text.Wrap(self.width - 10) | ||
558 | 470 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
559 | 471 | |||
560 | 472 | #--- Event(s) --- | ||
561 | 473 | def on_date_changed(self, evt): | ||
562 | 474 | self.settings['build_date'] = evt.GetDate().FormatISODate().encode('ascii') | ||
563 | 475 | self.fill_build_combo_box_for_date(self.settings['build_date']) | ||
564 | 476 | self.update_build() | ||
565 | 477 | |||
566 | 478 | def event_combo_box_build(self, evt): | ||
567 | 479 | self.settings['build_number'] = evt.GetString().encode('ascii').lower() | ||
568 | 480 | self.update_build() | ||
569 | 481 | #--- END event(s) --- | ||
570 | 482 | |||
571 | 483 | |||
572 | 484 | class SelectOS(wiz.WizardPageSimple): | ||
573 | 485 | """Ask the user which OS they would like to run. Filter out any choices | ||
574 | 486 | that are unavailable due to previous choices.""" | ||
575 | 487 | def __init__(self, parent, config, db, width): | ||
576 | 488 | wiz.WizardPageSimple.__init__(self, parent) | ||
577 | 489 | self.settings = config.settings | ||
578 | 490 | self.wizard = parent | ||
579 | 491 | self.db = db | ||
580 | 492 | self.width = width | ||
581 | 493 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
582 | 494 | self.settings['image'] = None | ||
583 | 495 | |||
584 | 496 | header = wx.StaticText(self, label = "Please select the operating " | ||
585 | 497 | "system you would like to run on " | ||
586 | 498 | "your hardware.") | ||
587 | 499 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
588 | 500 | |||
589 | 501 | self.box1 = wx.BoxSizer(wx.VERTICAL) | ||
590 | 502 | self.sizer.Add(header) | ||
591 | 503 | |||
592 | 504 | self.cb_image = wx.ComboBox(self, | ||
593 | 505 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
594 | 506 | self.Bind(wx.EVT_COMBOBOX, self.event_combo_box_os, self.cb_image) | ||
595 | 507 | |||
596 | 508 | #--- Layout --- | ||
597 | 509 | # -- Combo boxes for hardware and image selection -- | ||
598 | 510 | self.box1.Add(self.cb_image, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
599 | 511 | |||
600 | 512 | self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
601 | 513 | |||
602 | 514 | self.help_text = wx.StaticText(self) | ||
603 | 515 | self.sizer.Add(self.help_text, 1, wx.EXPAND, 5) | ||
604 | 516 | |||
605 | 517 | self.SetSizer(self.sizer) | ||
606 | 518 | self.sizer.Fit(self) | ||
607 | 519 | self.Move((50, 50)) | ||
608 | 520 | |||
609 | 521 | def get_human_os_name(self, item): | ||
610 | 522 | """Given an OS name from the database, return a human name (either | ||
611 | 523 | translated from the YAML settings, or just prettified) and if it is a | ||
612 | 524 | LEB OS or not""" | ||
613 | 525 | |||
614 | 526 | item = re.sub("linaro-", "", item) # Remove any linaro- decoration | ||
615 | 527 | |||
616 | 528 | human_name = item | ||
617 | 529 | |||
618 | 530 | if item in self.settings['UI']['descriptions']: | ||
619 | 531 | human_name = self.settings['UI']['descriptions'][item] | ||
620 | 532 | else: | ||
621 | 533 | # Make human_name look nicer... | ||
622 | 534 | human_name = string.capwords(item) | ||
623 | 535 | |||
624 | 536 | leb_search = re.search("^LEB:\s*(.*)$", human_name) | ||
625 | 537 | |||
626 | 538 | if leb_search: | ||
627 | 539 | return leb_search.group(1), True | ||
628 | 540 | |||
629 | 541 | return human_name, False | ||
630 | 542 | |||
631 | 543 | def fill_os_list(self): | ||
632 | 544 | """Filter the list of OS's from the config file based on the users | ||
633 | 545 | preferences so all choices in the list are valid (i.e. their hardware | ||
634 | 546 | is supported for the build they have chosen).""" | ||
635 | 547 | |||
636 | 548 | # select unique image from snapshot_binaries/release_binaries to | ||
637 | 549 | # generate list | ||
638 | 550 | os_list = None | ||
639 | 551 | if self.settings['release_or_snapshot'] == "release": | ||
640 | 552 | os_list = self.db.get_os_list_from('release_binaries') | ||
641 | 553 | else: | ||
642 | 554 | os_list = self.db.get_os_list_from('snapshot_binaries') | ||
643 | 555 | |||
644 | 556 | self.cb_image.Clear() | ||
645 | 557 | |||
646 | 558 | printed_tag = None | ||
647 | 559 | last_name = None | ||
648 | 560 | current_image_setting_valid = False | ||
649 | 561 | |||
650 | 562 | for state in ["LEB", "other"]: | ||
651 | 563 | for item in os_list: | ||
652 | 564 | if item == "old": | ||
653 | 565 | # Old is a directory that sometimes hangs around, | ||
654 | 566 | # but isn't one we want to display | ||
655 | 567 | continue | ||
656 | 568 | |||
657 | 569 | # Save the original, untouched image name for use later. | ||
658 | 570 | # We give it a more human name for display | ||
659 | 571 | original = item | ||
660 | 572 | item = re.sub("linaro-", "", item) | ||
661 | 573 | |||
662 | 574 | os_hardware_combo_available = ( | ||
663 | 575 | self.db.image_hardware_combo_available( | ||
664 | 576 | self.settings['release_or_snapshot'], | ||
665 | 577 | original, | ||
666 | 578 | self.settings['compatable_hwpacks'])) | ||
667 | 579 | |||
668 | 580 | if os_hardware_combo_available: | ||
669 | 581 | human_name, is_LEB = self.get_human_os_name(item) | ||
670 | 582 | |||
671 | 583 | if item == self.settings['image']: | ||
672 | 584 | current_image_setting_valid = True | ||
673 | 585 | |||
674 | 586 | if state == "LEB" and is_LEB: | ||
675 | 587 | |||
676 | 588 | if printed_tag != state: | ||
677 | 589 | self.cb_image.Append( | ||
678 | 590 | "- Linaro Supported Releases -") | ||
679 | 591 | printed_tag = state | ||
680 | 592 | |||
681 | 593 | self.cb_image.Append(human_name, original) | ||
682 | 594 | |||
683 | 595 | if self.settings['image'] == None: | ||
684 | 596 | self.settings['image'] = original | ||
685 | 597 | |||
686 | 598 | elif state != "LEB" and not is_LEB: | ||
687 | 599 | if printed_tag != state: | ||
688 | 600 | self.cb_image.Append( | ||
689 | 601 | "- Community Supported Releases -") | ||
690 | 602 | printed_tag = state | ||
691 | 603 | |||
692 | 604 | self.cb_image.Append(human_name, original) | ||
693 | 605 | |||
694 | 606 | last_name = original | ||
695 | 607 | |||
696 | 608 | if( self.settings['image'] != None | ||
697 | 609 | and current_image_setting_valid == False): | ||
698 | 610 | # If we have an image setting, but it doesn't match the OS list, we | ||
699 | 611 | # have switched OS list. It may be that adding/removing "linaro-" | ||
700 | 612 | # from the name will get a match. | ||
701 | 613 | |||
702 | 614 | if re.search("linaro-", self.settings['image']): | ||
703 | 615 | test_name = re.sub("linaro-", "", self.settings['image']) | ||
704 | 616 | else: | ||
705 | 617 | test_name = "linaro-" + self.settings['image'] | ||
706 | 618 | |||
707 | 619 | if test_name in os_list: | ||
708 | 620 | # Success! We have translated the name and can retain the | ||
709 | 621 | # "old setting" | ||
710 | 622 | self.settings['image'] = test_name | ||
711 | 623 | current_image_setting_valid = True | ||
712 | 624 | |||
713 | 625 | if( self.settings['image'] == None | ||
714 | 626 | or current_image_setting_valid == False): | ||
715 | 627 | # This should only get hit if there are no LEBs available | ||
716 | 628 | self.settings['image'] = last_name | ||
717 | 629 | |||
718 | 630 | assert self.settings['image'] | ||
719 | 631 | |||
720 | 632 | # Make sure the visible selected value matches the saved setting | ||
721 | 633 | self.cb_image.SetValue( | ||
722 | 634 | self.get_human_os_name(self.settings['image'])[0]) | ||
723 | 635 | |||
724 | 636 | #--- Event(s) --- | ||
725 | 637 | def event_combo_box_os(self, evt): | ||
726 | 638 | self.settings['image'] = self.cb_image.GetClientData( | ||
727 | 639 | evt.GetSelection()) | ||
728 | 640 | |||
729 | 641 | if self.settings['image']: # Is None for items that aren't an OS | ||
730 | 642 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
731 | 643 | image = re.sub("linaro-", "", self.settings['image']) | ||
732 | 644 | |||
733 | 645 | if image + "::long" in self.settings['UI']['descriptions']: | ||
734 | 646 | self.help_text.SetLabel(self.settings['UI'] | ||
735 | 647 | ['descriptions'] | ||
736 | 648 | [image + "::long"]) | ||
737 | 649 | else: | ||
738 | 650 | self.help_text.SetLabel("") | ||
739 | 651 | |||
740 | 652 | else: # Have selected help text | ||
741 | 653 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
742 | 654 | self.help_text.SetLabel("Please select an operating system to run " | ||
743 | 655 | "on your chosen hardware.") | ||
744 | 656 | |||
745 | 657 | self.help_text.Wrap(self.width - 10) | ||
746 | 658 | #--- END event(s) --- | ||
747 | 659 | |||
748 | 660 | |||
749 | 661 | class LMC_settings(wiz.WizardPageSimple): | ||
750 | 662 | """Present the user with, intially, the choice of writing the file system | ||
751 | 663 | they are going to have created to a file, or directly to a device. Ask | ||
752 | 664 | which file/device to write to. | ||
753 | 665 | |||
754 | 666 | If writing to a device, the user is asked to tick a box saying that they | ||
755 | 667 | understand that the device they have chosen will be erased. | ||
756 | 668 | |||
757 | 669 | If the user ticks the advanced box, more options are shown.""" | ||
758 | 670 | |||
759 | 671 | def __init__(self, parent, config, db, width): | ||
760 | 672 | wiz.WizardPageSimple.__init__(self, parent) | ||
761 | 673 | self.settings = config.settings | ||
762 | 674 | self.wizard = parent | ||
763 | 675 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
764 | 676 | self.yes_use_mmc = False | ||
765 | 677 | self.db = db | ||
766 | 678 | |||
767 | 679 | self.settings['path_selected'] = "" | ||
768 | 680 | |||
769 | 681 | header = wx.StaticText(self, | ||
770 | 682 | label = "Media Creation Settings\n\n" | ||
771 | 683 | "Please select if you would like to write the " | ||
772 | 684 | "file system I am about to create to a memory " | ||
773 | 685 | "card, or to a file on the local file system.") | ||
774 | 686 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
775 | 687 | |||
776 | 688 | #--- Build some widgets --- | ||
777 | 689 | #-- Target file system -- | ||
778 | 690 | file_systems = ["ext3", "ext4", "btrfs", "ext2"] | ||
779 | 691 | default_target = file_systems[0] | ||
780 | 692 | self.settings['rootfs'] = default_target | ||
781 | 693 | cb_rootfs = wx.ComboBox(self, | ||
782 | 694 | value = default_target, | ||
783 | 695 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
784 | 696 | |||
785 | 697 | for item in file_systems: | ||
786 | 698 | cb_rootfs.Append(item, item.upper()) | ||
787 | 699 | |||
788 | 700 | self.Bind(wx.EVT_COMBOBOX, self.event_combo_box_rootfs, cb_rootfs) | ||
789 | 701 | |||
790 | 702 | #-- Image size spinner | ||
791 | 703 | self.image_size_spinner = wx.SpinCtrl(self, -1, "") | ||
792 | 704 | self.Bind(wx.EVT_SPINCTRL, | ||
793 | 705 | self.event_image_size, | ||
794 | 706 | self.image_size_spinner) | ||
795 | 707 | |||
796 | 708 | #-- Swap size spinner | ||
797 | 709 | self.swap_size_spinner = wx.SpinCtrl(self, -1, "") | ||
798 | 710 | self.Bind(wx.EVT_SPINCTRL, | ||
799 | 711 | self.event_swap_size, | ||
800 | 712 | self.swap_size_spinner) | ||
801 | 713 | |||
802 | 714 | #--- Layout --- | ||
803 | 715 | self.sizer.Add(header, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
804 | 716 | box1 = wx.BoxSizer(wx.VERTICAL) | ||
805 | 717 | file_dev_grid = wx.FlexGridSizer(0, 2, 0, 0) | ||
806 | 718 | box1.Add(file_dev_grid, 0, wx.EXPAND) | ||
807 | 719 | grid1 = wx.FlexGridSizer(0, 2, 0, 0) | ||
808 | 720 | |||
809 | 721 | # self.settings['write_to_file_or_device'] should match the first | ||
810 | 722 | # button below... | ||
811 | 723 | self.settings['write_to_file_or_device'] = "file" | ||
812 | 724 | add_button(self, | ||
813 | 725 | file_dev_grid, | ||
814 | 726 | "Write to file", | ||
815 | 727 | wx.RB_GROUP, | ||
816 | 728 | self.event_radio_button_select, | ||
817 | 729 | None, None) | ||
818 | 730 | |||
819 | 731 | add_button(self, | ||
820 | 732 | file_dev_grid, | ||
821 | 733 | "Write to device", | ||
822 | 734 | None, | ||
823 | 735 | self.event_radio_button_select, | ||
824 | 736 | None, None) | ||
825 | 737 | |||
826 | 738 | self.help_text_values = {"device": "Please select a device to write " | ||
827 | 739 | "the file system to:", | ||
828 | 740 | "file": "Please select a file to write the " | ||
829 | 741 | "file system to:"} | ||
830 | 742 | |||
831 | 743 | self.help_text = wx.StaticText( | ||
832 | 744 | self, | ||
833 | 745 | label = | ||
834 | 746 | self.help_text_values[ | ||
835 | 747 | self.settings['write_to_file_or_device']]) | ||
836 | 748 | self.help_text.Wrap(width - 10) | ||
837 | 749 | |||
838 | 750 | #-- File/dev picker -- | ||
839 | 751 | file_browse_button = wx.Button(self, -1, "Browse") | ||
840 | 752 | file_browse_grid = wx.FlexGridSizer(0, 2, 0, 0) | ||
841 | 753 | self.file_path_and_name = wx.TextCtrl(self, -1, "", size=(300, -1)) | ||
842 | 754 | |||
843 | 755 | file_browse_grid.Add(self.file_path_and_name, 0, wx.EXPAND) | ||
844 | 756 | file_browse_grid.Add(file_browse_button, 0, wx.EXPAND) | ||
845 | 757 | |||
846 | 758 | self.Bind(wx.EVT_BUTTON, | ||
847 | 759 | self.event_open_file_control, | ||
848 | 760 | file_browse_button) | ||
849 | 761 | |||
850 | 762 | self.Bind(wx.EVT_TEXT, | ||
851 | 763 | self.event_file_path_and_name, | ||
852 | 764 | self.file_path_and_name) | ||
853 | 765 | |||
854 | 766 | box1.Add(self.help_text, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
855 | 767 | |||
856 | 768 | box1.Add(file_browse_grid, 0, wx.EXPAND) | ||
857 | 769 | |||
858 | 770 | cb1 = wx.CheckBox(self, -1, "Show advanced options") | ||
859 | 771 | self.Bind(wx.EVT_CHECKBOX, self.event_show_advanced_options, cb1) | ||
860 | 772 | box1.Add(cb1) | ||
861 | 773 | |||
862 | 774 | #-- Combo boxes for hardware and image selection -- | ||
863 | 775 | optional_settings_box_title = wx.StaticBox( | ||
864 | 776 | self, | ||
865 | 777 | label = " Optional Settings ") | ||
866 | 778 | |||
867 | 779 | self.optional_settings_box = wx.StaticBoxSizer( | ||
868 | 780 | optional_settings_box_title, | ||
869 | 781 | wx.VERTICAL) | ||
870 | 782 | |||
871 | 783 | self.box2 = wx.BoxSizer(wx.VERTICAL) | ||
872 | 784 | |||
873 | 785 | self.box2.AddWindow(self.optional_settings_box, | ||
874 | 786 | 0, | ||
875 | 787 | border=2, | ||
876 | 788 | flag=wx.ALL | wx.EXPAND) | ||
877 | 789 | |||
878 | 790 | grid1.Add(cb_rootfs, 0, wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 5) | ||
879 | 791 | |||
880 | 792 | grid1.Add(wx.StaticText(self, | ||
881 | 793 | label = "The root file system of the image"), | ||
882 | 794 | 0, | ||
883 | 795 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
884 | 796 | 5) | ||
885 | 797 | |||
886 | 798 | # We want to sub-devide the cell, to add another grid sizer... | ||
887 | 799 | file_size_grid = wx.FlexGridSizer(0, 2, 0, 0) | ||
888 | 800 | |||
889 | 801 | grid1.Add(file_size_grid, | ||
890 | 802 | 0, | ||
891 | 803 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP) | ||
892 | 804 | |||
893 | 805 | # Add a spinner that allows us to type/click a numerical value (defined above) | ||
894 | 806 | file_size_grid.Add(self.image_size_spinner, | ||
895 | 807 | 0, | ||
896 | 808 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
897 | 809 | 5) | ||
898 | 810 | |||
899 | 811 | # Add a choice of MB or GB for size input | ||
900 | 812 | units = ["GB", "MB"] | ||
901 | 813 | self.size_unit = units[0] # Set the default unit | ||
902 | 814 | unit_choice = wx.Choice(self, -1, (100, 50), choices = units) | ||
903 | 815 | self.Bind(wx.EVT_CHOICE, self.event_chose_unit, unit_choice) | ||
904 | 816 | file_size_grid.Add(unit_choice, 0, wx.ALIGN_RIGHT | wx.TOP, 5) | ||
905 | 817 | |||
906 | 818 | # Back out of the extra grid, add some help text | ||
907 | 819 | grid1.Add(wx.StaticText( | ||
908 | 820 | self, | ||
909 | 821 | label = "Writing to file only: Image file size"), | ||
910 | 822 | 0, | ||
911 | 823 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
912 | 824 | 5) | ||
913 | 825 | |||
914 | 826 | # The swap size (MB only) | ||
915 | 827 | grid1.Add(self.swap_size_spinner, | ||
916 | 828 | 0, | ||
917 | 829 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
918 | 830 | 5) | ||
919 | 831 | |||
920 | 832 | grid1.Add(wx.StaticText(self, label = "Swap file size in MB"), | ||
921 | 833 | 0, | ||
922 | 834 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
923 | 835 | 5) | ||
924 | 836 | |||
925 | 837 | self.cb_hwpacks = wx.ComboBox( | ||
926 | 838 | self, | ||
927 | 839 | value = self.settings['compatable_hwpacks'][0], | ||
928 | 840 | style = wx.CB_DROPDOWN | wx.CB_READONLY) | ||
929 | 841 | |||
930 | 842 | self.Bind(wx.EVT_COMBOBOX, | ||
931 | 843 | self.event_combo_box_hwpack, | ||
932 | 844 | self.cb_hwpacks) | ||
933 | 845 | |||
934 | 846 | grid1.Add(self.cb_hwpacks, | ||
935 | 847 | 0, | ||
936 | 848 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
937 | 849 | 5) | ||
938 | 850 | |||
939 | 851 | grid1.Add(wx.StaticText(self, label = "Compatible hardware packs"), | ||
940 | 852 | 0, | ||
941 | 853 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
942 | 854 | 5) | ||
943 | 855 | |||
944 | 856 | self.optional_settings_box.Add(grid1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
945 | 857 | |||
946 | 858 | confirm_mmc_usage_title = wx.StaticBox(self, label = " Are you sure? ") | ||
947 | 859 | |||
948 | 860 | self.confirm_mmc_usage_box = wx.StaticBoxSizer(confirm_mmc_usage_title, | ||
949 | 861 | wx.VERTICAL) | ||
950 | 862 | cb2 = wx.CheckBox( | ||
951 | 863 | self, | ||
952 | 864 | -1, | ||
953 | 865 | "Yes, erase and use the device I have selected above.") | ||
954 | 866 | |||
955 | 867 | self.Bind(wx.EVT_CHECKBOX, self.event_use_mmc_tickbox, cb2) | ||
956 | 868 | self.confirm_mmc_usage_box.Add(cb2) | ||
957 | 869 | |||
958 | 870 | self.box3 = wx.BoxSizer(wx.VERTICAL) | ||
959 | 871 | self.box3.AddWindow(self.confirm_mmc_usage_box, | ||
960 | 872 | 0, | ||
961 | 873 | border=2, | ||
962 | 874 | flag=wx.ALL | wx.EXPAND) | ||
963 | 875 | |||
964 | 876 | self.sizer.Add(box1, 0, wx.ALIGN_LEFT | wx.ALL, 0) | ||
965 | 877 | self.sizer.Add(self.box2, 0, wx.ALIGN_LEFT | wx.ALL, 0) | ||
966 | 878 | self.sizer.Add(self.box3, 0, wx.ALIGN_LEFT | wx.ALL, 0) | ||
967 | 879 | self.SetSizer(self.sizer) | ||
968 | 880 | self.sizer.Fit(self) | ||
969 | 881 | self.Move((50, 50)) | ||
970 | 882 | |||
971 | 883 | def on_activate(self): | ||
972 | 884 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
973 | 885 | self.set_hwpacks_for_hardware() | ||
974 | 886 | |||
975 | 887 | def set_hwpacks_for_hardware(self): | ||
976 | 888 | self.cb_hwpacks.Clear() | ||
977 | 889 | |||
978 | 890 | if self.settings['release_or_snapshot'] == "snapshot": | ||
979 | 891 | self.settings['build'] = self.settings['snapshot_build'] | ||
980 | 892 | |||
981 | 893 | date_and_build = self.settings['build'].split(":") | ||
982 | 894 | |||
983 | 895 | compatable_hwpacks = ( | ||
984 | 896 | self.db.get_available_hwpacks_for_hardware_snapshot_build( | ||
985 | 897 | self.settings['compatable_hwpacks'], | ||
986 | 898 | self.settings['platform'], | ||
987 | 899 | date_and_build[0], | ||
988 | 900 | date_and_build[1])) | ||
989 | 901 | else: | ||
990 | 902 | self.settings['build'] = self.settings['release_build'] | ||
991 | 903 | compatable_hwpacks = ( | ||
992 | 904 | self.db.get_available_hwpacks_for_hardware_build_plaform( | ||
993 | 905 | self.settings['compatable_hwpacks'], | ||
994 | 906 | self.settings['platform'], | ||
995 | 907 | self.settings['build'])) | ||
996 | 908 | |||
997 | 909 | for hwpack in compatable_hwpacks: | ||
998 | 910 | self.cb_hwpacks.Append(hwpack) | ||
999 | 911 | |||
1000 | 912 | self.cb_hwpacks.SetStringSelection(compatable_hwpacks[0]) | ||
1001 | 913 | self.settings['hwpack'] = compatable_hwpacks[0] | ||
1002 | 914 | |||
1003 | 915 | def update_forward_active_and_mmc_confirm_box_visible(self): | ||
1004 | 916 | if( self.settings['path_selected'] | ||
1005 | 917 | and self.settings['path_selected'] != ""): | ||
1006 | 918 | |||
1007 | 919 | if ( self.settings['write_to_file_or_device'] == "file" | ||
1008 | 920 | or self.settings['write_to_file_or_device'] == "device" | ||
1009 | 921 | and self.yes_use_mmc): | ||
1010 | 922 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
1011 | 923 | else: | ||
1012 | 924 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
1013 | 925 | else: | ||
1014 | 926 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
1015 | 927 | |||
1016 | 928 | if self.settings['write_to_file_or_device'] == "device": | ||
1017 | 929 | self.box3.Show(self.confirm_mmc_usage_box, True) | ||
1018 | 930 | else: | ||
1019 | 931 | self.box3.Hide(self.confirm_mmc_usage_box, True) | ||
1020 | 932 | |||
1021 | 933 | # --- Event Handlers --- | ||
1022 | 934 | def event_open_file_control(self, event): | ||
1023 | 935 | if self.settings['write_to_file_or_device'] == "file": | ||
1024 | 936 | |||
1025 | 937 | dlg = wx.FileDialog(self, | ||
1026 | 938 | message="Save file as ...", | ||
1027 | 939 | defaultDir=os.getcwd(), | ||
1028 | 940 | defaultFile="", | ||
1029 | 941 | style=wx.SAVE) | ||
1030 | 942 | |||
1031 | 943 | elif self.settings['write_to_file_or_device'] == "device": | ||
1032 | 944 | dlg = wx.FileDialog(self, | ||
1033 | 945 | message="Choose a device", | ||
1034 | 946 | defaultDir=os.getcwd(), | ||
1035 | 947 | defaultFile="", | ||
1036 | 948 | style=wx.OPEN | wx.CHANGE_DIR) | ||
1037 | 949 | |||
1038 | 950 | if dlg.ShowModal() == wx.ID_OK: | ||
1039 | 951 | self.settings['path_selected'] = dlg.GetPaths()[0] | ||
1040 | 952 | self.file_path_and_name.SetValue(self.settings['path_selected']) | ||
1041 | 953 | |||
1042 | 954 | dlg.Destroy() | ||
1043 | 955 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
1044 | 956 | |||
1045 | 957 | def event_file_path_and_name(self, event): | ||
1046 | 958 | self.settings['path_selected'] = event.GetString() | ||
1047 | 959 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
1048 | 960 | |||
1049 | 961 | def event_combo_box_hwpack(self, event): | ||
1050 | 962 | self.settings['hwpack'] = event.GetString().encode('ascii') | ||
1051 | 963 | |||
1052 | 964 | def event_combo_box_rootfs(self, evt): | ||
1053 | 965 | self.settings['rootfs'] = evt.GetString().encode('ascii').lower() | ||
1054 | 966 | |||
1055 | 967 | def event_radio_button_select(self, event): | ||
1056 | 968 | """Search the label of the button that has been selected to work out | ||
1057 | 969 | what we are writing to.""" | ||
1058 | 970 | setting_search = re.search( | ||
1059 | 971 | "write to (\w+)", | ||
1060 | 972 | event | ||
1061 | 973 | .GetEventObject() | ||
1062 | 974 | .GetLabel() | ||
1063 | 975 | .encode('ascii') | ||
1064 | 976 | .lower()) | ||
1065 | 977 | |||
1066 | 978 | assert setting_search | ||
1067 | 979 | |||
1068 | 980 | self.settings['write_to_file_or_device'] = setting_search.group(1) | ||
1069 | 981 | |||
1070 | 982 | self.help_text.SetLabel( | ||
1071 | 983 | self.help_text_values[self.settings['write_to_file_or_device']]) | ||
1072 | 984 | |||
1073 | 985 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
1074 | 986 | |||
1075 | 987 | def event_show_advanced_options(self, event): | ||
1076 | 988 | if event.IsChecked(): | ||
1077 | 989 | self.box2.Show(self.optional_settings_box, True) | ||
1078 | 990 | else: | ||
1079 | 991 | self.box2.Hide(self.optional_settings_box, True) | ||
1080 | 992 | |||
1081 | 993 | def event_pick_file_path(self, evt): | ||
1082 | 994 | self.settings['path_selected'] = os.path.abspath(evt.GetPath()) | ||
1083 | 995 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
1084 | 996 | |||
1085 | 997 | def update_image_size_setting(self): | ||
1086 | 998 | if(self.image_size_spinner.GetValue() > 0): | ||
1087 | 999 | self.settings['image_size'] = (str(self.image_size_spinner | ||
1088 | 1000 | .GetValue()) | ||
1089 | 1001 | + self.size_unit[0]) | ||
1090 | 1002 | else: | ||
1091 | 1003 | self.settings['image_size'] = None | ||
1092 | 1004 | |||
1093 | 1005 | def event_image_size(self, event): | ||
1094 | 1006 | self.update_image_size_setting() | ||
1095 | 1007 | |||
1096 | 1008 | def event_chose_unit(self, event): | ||
1097 | 1009 | self.size_unit = event.GetString() | ||
1098 | 1010 | self.update_image_size_setting() | ||
1099 | 1011 | |||
1100 | 1012 | def event_swap_size(self, event): | ||
1101 | 1013 | self.settings['swap_file'] = str(self.image_size_spinner.GetValue()) | ||
1102 | 1014 | |||
1103 | 1015 | def event_use_mmc_tickbox(self, event): | ||
1104 | 1016 | self.yes_use_mmc = event.IsChecked() | ||
1105 | 1017 | self.update_forward_active_and_mmc_confirm_box_visible() | ||
1106 | 1018 | |||
1107 | 1019 | |||
1108 | 1020 | class RunLMC(wiz.WizardPageSimple): | ||
1109 | 1021 | """Present the user with some information about their choices and a button | ||
1110 | 1022 | to start linaro-media-create. The linaro-media-create process is started in | ||
1111 | 1023 | a new thread and important events are communicated back to the UI through a | ||
1112 | 1024 | queue.""" | ||
1113 | 1025 | |||
1114 | 1026 | def __init__(self, parent, config, db, width): | ||
1115 | 1027 | wiz.WizardPageSimple.__init__(self, parent) | ||
1116 | 1028 | self.settings = config.settings | ||
1117 | 1029 | self.sizer = wx.BoxSizer(wx.VERTICAL) | ||
1118 | 1030 | self.db = db | ||
1119 | 1031 | self.width = width | ||
1120 | 1032 | self.wizard = parent | ||
1121 | 1033 | |||
1122 | 1034 | header = wx.StaticText(self, label = """Installing...""") | ||
1123 | 1035 | header.Wrap(width - 10) # -10 because boarder below is 5 pixels wide | ||
1124 | 1036 | |||
1125 | 1037 | self.sizer.Add(header) | ||
1126 | 1038 | self.box1 = wx.BoxSizer(wx.VERTICAL) | ||
1127 | 1039 | |||
1128 | 1040 | # We expect to print 4 lines of information, reserve space using blank | ||
1129 | 1041 | # lines. | ||
1130 | 1042 | self.settings_summary_text = wx.StaticText(self, label = "\n\n\n\n") | ||
1131 | 1043 | self.settings_summary_text.Wrap(width - 10) | ||
1132 | 1044 | |||
1133 | 1045 | self.box1.Add(self.settings_summary_text, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
1134 | 1046 | |||
1135 | 1047 | self.start_button = wx.Button(self, 10, "Start", (20, 20)) | ||
1136 | 1048 | self.Bind(wx.EVT_BUTTON, self.start_lmc, self.start_button) | ||
1137 | 1049 | |||
1138 | 1050 | self.start_button.SetToolTipString("Start creating an image, using the" | ||
1139 | 1051 | "above settings.") | ||
1140 | 1052 | |||
1141 | 1053 | self.start_button.SetSize(self.start_button.GetBestSize()) | ||
1142 | 1054 | self.box1.Add(self.start_button, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
1143 | 1055 | |||
1144 | 1056 | self.status_grid = wx.FlexGridSizer(0, 2, 0, 0) | ||
1145 | 1057 | |||
1146 | 1058 | self.status_grid.Add(wx.StaticText(self, label="Downloading files"), | ||
1147 | 1059 | 0, | ||
1148 | 1060 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1149 | 1061 | 5) | ||
1150 | 1062 | |||
1151 | 1063 | self.downloading_files_status = wx.StaticText(self, label="") | ||
1152 | 1064 | self.status_grid.Add(self.downloading_files_status, | ||
1153 | 1065 | 0, | ||
1154 | 1066 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1155 | 1067 | 5) | ||
1156 | 1068 | |||
1157 | 1069 | self.status_grid.Add(wx.StaticText(self, label="Unpacking downloads"), | ||
1158 | 1070 | 0, | ||
1159 | 1071 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1160 | 1072 | 5) | ||
1161 | 1073 | |||
1162 | 1074 | self.unpacking_files_status = wx.StaticText(self, label="") | ||
1163 | 1075 | |||
1164 | 1076 | self.status_grid.Add(self.unpacking_files_status, | ||
1165 | 1077 | 0, | ||
1166 | 1078 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1167 | 1079 | 5) | ||
1168 | 1080 | |||
1169 | 1081 | self.status_grid.Add(wx.StaticText(self, label="Installing packages"), | ||
1170 | 1082 | 0, | ||
1171 | 1083 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1172 | 1084 | 5) | ||
1173 | 1085 | |||
1174 | 1086 | self.installing_packages_status = wx.StaticText(self, label="") | ||
1175 | 1087 | |||
1176 | 1088 | self.status_grid.Add(self.installing_packages_status, | ||
1177 | 1089 | 0, | ||
1178 | 1090 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1179 | 1091 | 5) | ||
1180 | 1092 | |||
1181 | 1093 | self.status_grid.Add(wx.StaticText(self, label="Create file system"), | ||
1182 | 1094 | 0, | ||
1183 | 1095 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1184 | 1096 | 5) | ||
1185 | 1097 | |||
1186 | 1098 | self.create_file_system_status = wx.StaticText(self, label="") | ||
1187 | 1099 | |||
1188 | 1100 | self.status_grid.Add(self.create_file_system_status, | ||
1189 | 1101 | 0, | ||
1190 | 1102 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1191 | 1103 | 5) | ||
1192 | 1104 | |||
1193 | 1105 | self.status_grid.Add(wx.StaticText(self, label="Populate file system"), | ||
1194 | 1106 | 0, | ||
1195 | 1107 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1196 | 1108 | 5) | ||
1197 | 1109 | |||
1198 | 1110 | self.populate_file_system_status = wx.StaticText(self, label="") | ||
1199 | 1111 | |||
1200 | 1112 | self.status_grid.Add(self.populate_file_system_status, | ||
1201 | 1113 | 0, | ||
1202 | 1114 | wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, | ||
1203 | 1115 | 5) | ||
1204 | 1116 | |||
1205 | 1117 | self.sizer.Add(self.box1, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
1206 | 1118 | self.sizer.Add(self.status_grid, 0, wx.ALIGN_LEFT | wx.ALL, 5) | ||
1207 | 1119 | self.SetSizerAndFit(self.sizer) | ||
1208 | 1120 | self.sizer.Fit(self) | ||
1209 | 1121 | self.Move((50, 50)) | ||
1210 | 1122 | |||
1211 | 1123 | def on_activate(self): | ||
1212 | 1124 | """Called just before the page is displayed to update the text based on | ||
1213 | 1125 | the users preferences.""" | ||
1214 | 1126 | |||
1215 | 1127 | # The build is stored in different forms depending on if we are using a | ||
1216 | 1128 | # release or snapshot but from here on in it is a common value | ||
1217 | 1129 | if self.settings['release_or_snapshot'] == "snapshot": | ||
1218 | 1130 | self.settings['build'] = self.settings['snapshot_build'] | ||
1219 | 1131 | else: | ||
1220 | 1132 | self.settings['build'] = self.settings['release_build'] | ||
1221 | 1133 | |||
1222 | 1134 | settings_summary = ("Press start to create an image with the " | ||
1223 | 1135 | "following settings:\n") | ||
1224 | 1136 | settings_summary += "Operating System: " + self.settings['image'] + "\n" | ||
1225 | 1137 | settings_summary += "Hardware: " + self.settings['hardware'] + "\n" | ||
1226 | 1138 | |||
1227 | 1139 | # Assumption is that a file may be in a long path, we don't know how | ||
1228 | 1140 | # big the font is and we don't want to allow the path to run off the | ||
1229 | 1141 | # end of the line, so if a file is chosen, just show the file name. | ||
1230 | 1142 | # Devices are (probably) /dev/some_short_name and the user really needs | ||
1231 | 1143 | # to check them, so we show the whole thing. | ||
1232 | 1144 | path = self.settings['path_selected'] | ||
1233 | 1145 | if self.settings['write_to_file_or_device'] == "file": | ||
1234 | 1146 | path = self.settings['path_selected'].split(os.sep)[-1] | ||
1235 | 1147 | |||
1236 | 1148 | settings_summary += ( "Writing image to " | ||
1237 | 1149 | + self.settings['write_to_file_or_device'] | ||
1238 | 1150 | + " " | ||
1239 | 1151 | + path) | ||
1240 | 1152 | |||
1241 | 1153 | self.settings_summary_text.SetLabel(settings_summary) | ||
1242 | 1154 | self.settings_summary_text.Wrap(self.width - 10) | ||
1243 | 1155 | |||
1244 | 1156 | def start_lmc(self, event): | ||
1245 | 1157 | """Start a thread that runs linaro-media-create and a timer, which | ||
1246 | 1158 | checks for UI updates every 100ms""" | ||
1247 | 1159 | |||
1248 | 1160 | if self.settings['write_to_file_or_device'] == "file": | ||
1249 | 1161 | self.settings['image_file'] = self.settings['path_selected'] | ||
1250 | 1162 | elif self.settings['write_to_file_or_device'] == "device": | ||
1251 | 1163 | self.settings['mmc'] = self.settings['path_selected'] | ||
1252 | 1164 | else: | ||
1253 | 1165 | assert False, ("self.config.settings['write_to_file_or_device'] " | ||
1254 | 1166 | "was an unexpected value" | ||
1255 | 1167 | + self.settings['write_to_file_or_device']) | ||
1256 | 1168 | |||
1257 | 1169 | image_url, hwpack_url = self.db.get_image_and_hwpack_urls(self.settings) | ||
1258 | 1170 | |||
1259 | 1171 | # Currently the UI is blocked when LMC is running, so grey out the | ||
1260 | 1172 | # buttons to indicate to the user that they won't work! | ||
1261 | 1173 | self.wizard.FindWindowById(wx.ID_BACKWARD).Disable() | ||
1262 | 1174 | self.wizard.FindWindowById(wx.ID_CANCEL).Disable() | ||
1263 | 1175 | |||
1264 | 1176 | if(image_url and hwpack_url): | ||
1265 | 1177 | |||
1266 | 1178 | print image_url | ||
1267 | 1179 | print hwpack_url | ||
1268 | 1180 | |||
1269 | 1181 | self.file_handler = FetchImage.FileHandler() | ||
1270 | 1182 | |||
1271 | 1183 | tools_dir = os.path.dirname(__file__) | ||
1272 | 1184 | if tools_dir == '': | ||
1273 | 1185 | tools_dir = None | ||
1274 | 1186 | |||
1275 | 1187 | self.file_handler.create_media(image_url, | ||
1276 | 1188 | hwpack_url, | ||
1277 | 1189 | self.settings, | ||
1278 | 1190 | tools_dir, | ||
1279 | 1191 | True, | ||
1280 | 1192 | self) | ||
1281 | 1193 | |||
1282 | 1194 | self.timer = wx.Timer(self) | ||
1283 | 1195 | self.Bind(wx.EVT_TIMER, self.timer_ping, self.timer) | ||
1284 | 1196 | self.timer.Start(milliseconds=100, oneShot=True) | ||
1285 | 1197 | |||
1286 | 1198 | self.start_button.Disable() | ||
1287 | 1199 | self.event_queue = Queue.Queue() | ||
1288 | 1200 | self.file_handler.start_lmc_gui_thread(self.event_queue) | ||
1289 | 1201 | else: | ||
1290 | 1202 | print >> sys.stderr, ("Unable to find files that match the" | ||
1291 | 1203 | "parameters specified") | ||
1292 | 1204 | |||
1293 | 1205 | def timer_ping(self, event): | ||
1294 | 1206 | """During start_lmc a timer is started to poll for events from | ||
1295 | 1207 | linaro-media-create every 100ms. This is the function which is called | ||
1296 | 1208 | to do that polling.""" | ||
1297 | 1209 | |||
1298 | 1210 | if self.event_queue.empty() == False: | ||
1299 | 1211 | event = self.event_queue.get() | ||
1300 | 1212 | |||
1301 | 1213 | if event[0] == "start": | ||
1302 | 1214 | self.event_start(event[1]) | ||
1303 | 1215 | self.timer.Start(milliseconds=100, oneShot=True) | ||
1304 | 1216 | |||
1305 | 1217 | elif event[0] == "end": | ||
1306 | 1218 | self.event_end(event[1]) | ||
1307 | 1219 | self.timer.Start(milliseconds=100, oneShot=True) | ||
1308 | 1220 | |||
1309 | 1221 | elif event == "terminate": | ||
1310 | 1222 | # Process complete. Enable next button. | ||
1311 | 1223 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
1312 | 1224 | self.populate_file_system_status.SetLabel("Done") | ||
1313 | 1225 | |||
1314 | 1226 | else: | ||
1315 | 1227 | print >> sys.stderr, "timer_ping: Unhandled event", event | ||
1316 | 1228 | |||
1317 | 1229 | else: | ||
1318 | 1230 | self.timer.Start(milliseconds=100, oneShot=True) | ||
1319 | 1231 | |||
1320 | 1232 | def unsigned_packages_query(self, package_list): | ||
1321 | 1233 | message = ('In order to continue, I need to install some unsigned' | ||
1322 | 1234 | 'packages into the image. Is this OK? The packages are:' | ||
1323 | 1235 | '\n\n' + package_list) | ||
1324 | 1236 | |||
1325 | 1237 | dlg = wx.MessageDialog(self, | ||
1326 | 1238 | message, | ||
1327 | 1239 | 'Install Unsigned Packages Into Image?', | ||
1328 | 1240 | wx.YES_NO | wx.NO_DEFAULT) | ||
1329 | 1241 | |||
1330 | 1242 | choice = dlg.ShowModal() | ||
1331 | 1243 | dlg.Destroy() | ||
1332 | 1244 | |||
1333 | 1245 | return choice == wx.ID_YES | ||
1334 | 1246 | |||
1335 | 1247 | #--- Event(s) --- | ||
1336 | 1248 | def event_start(self, event): | ||
1337 | 1249 | if event == "download OS": | ||
1338 | 1250 | self.downloading_files_status.SetLabel("Downloading OS") | ||
1339 | 1251 | elif event == "download hwpack": | ||
1340 | 1252 | self.downloading_files_status.SetLabel("Downloading Hardware Pack") | ||
1341 | 1253 | elif event == "unpack": | ||
1342 | 1254 | self.unpacking_files_status.SetLabel("Running") | ||
1343 | 1255 | elif event == "installing packages": | ||
1344 | 1256 | self.installing_packages_status.SetLabel("Running") | ||
1345 | 1257 | |||
1346 | 1258 | elif re.search('^unverified_packages:', event): | ||
1347 | 1259 | # Get rid of event ID and whitespace invariance | ||
1348 | 1260 | packages = " ".join(event.split()[1:]) | ||
1349 | 1261 | install_unsigned_packages = self.unsigned_packages_query(packages) | ||
1350 | 1262 | |||
1351 | 1263 | if install_unsigned_packages == False: | ||
1352 | 1264 | self.file_handler.kill_create_media() | ||
1353 | 1265 | sys.exit(1) | ||
1354 | 1266 | else: | ||
1355 | 1267 | self.file_handler.send_to_create_process("y") | ||
1356 | 1268 | |||
1357 | 1269 | elif event == "create file system": | ||
1358 | 1270 | self.create_file_system_status.SetLabel("Running") | ||
1359 | 1271 | elif event == "populate file system": | ||
1360 | 1272 | self.populate_file_system_status.SetLabel("Running") | ||
1361 | 1273 | else: | ||
1362 | 1274 | print "Unhandled start event:", event | ||
1363 | 1275 | |||
1364 | 1276 | def event_end(self, event): | ||
1365 | 1277 | if event == "download OS": | ||
1366 | 1278 | self.downloading_files_status.SetLabel("Done (1/2)") | ||
1367 | 1279 | elif event == "download hwpack": | ||
1368 | 1280 | self.downloading_files_status.SetLabel("Done") | ||
1369 | 1281 | elif event == "unpack": | ||
1370 | 1282 | self.unpacking_files_status.SetLabel("Done") | ||
1371 | 1283 | elif event == "installing packages": | ||
1372 | 1284 | self.installing_packages_status.SetLabel("Done") | ||
1373 | 1285 | elif event == "create file system": | ||
1374 | 1286 | self.create_file_system_status.SetLabel("Done") | ||
1375 | 1287 | elif event == "populate file system": | ||
1376 | 1288 | self.populate_file_system_status.SetLabel("Done") | ||
1377 | 1289 | else: | ||
1378 | 1290 | print "Unhhandled end event:", event | ||
1379 | 1291 | |||
1380 | 1292 | def event_combo_box_release(self, evt): | ||
1381 | 1293 | pass | ||
1382 | 1294 | |||
1383 | 1295 | def event_combo_box_build(self, evt): | ||
1384 | 1296 | pass | ||
1385 | 1297 | #--- END event(s) --- | ||
1386 | 1298 | |||
1387 | 1299 | |||
1388 | 1300 | class TestDriveWizard(wx.wizard.Wizard): | ||
1389 | 1301 | def __init__(self, title): | ||
1390 | 1302 | wx.wizard.Wizard.__init__(self, None, -1, title, wx.NullBitmap) | ||
1391 | 1303 | self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.on_page_changing) | ||
1392 | 1304 | self.done_startup = False | ||
1393 | 1305 | |||
1394 | 1306 | def on_page_changing(self, evt): | ||
1395 | 1307 | 'Executed before the page changes.' | ||
1396 | 1308 | |||
1397 | 1309 | if self.done_startup == False: | ||
1398 | 1310 | self.pages['lmc_settings'].box2.Hide( | ||
1399 | 1311 | self.pages['lmc_settings'].optional_settings_box, | ||
1400 | 1312 | True) | ||
1401 | 1313 | |||
1402 | 1314 | self.pages['lmc_settings'].box3.Hide( | ||
1403 | 1315 | self.pages['lmc_settings'].confirm_mmc_usage_box, | ||
1404 | 1316 | True) | ||
1405 | 1317 | |||
1406 | 1318 | self.done_startup = True | ||
1407 | 1319 | |||
1408 | 1320 | page = evt.GetPage() | ||
1409 | 1321 | |||
1410 | 1322 | if evt.GetDirection(): # If going forwards... | ||
1411 | 1323 | # Always enable back button if going forwards | ||
1412 | 1324 | self.wizard.FindWindowById(wx.ID_BACKWARD).Enable() | ||
1413 | 1325 | |||
1414 | 1326 | # If going from a select snapshot or select release page, record | ||
1415 | 1327 | # which we were on so the back button of the next page works | ||
1416 | 1328 | if(self.config.settings['release_or_snapshot'] == "release"): | ||
1417 | 1329 | self.pages['select_os'].SetNext(self.pages['select_release']) | ||
1418 | 1330 | self.pages['select_release'].SetPrev(self.pages['select_os']) | ||
1419 | 1331 | |||
1420 | 1332 | self.pages['select_release'].SetNext(self.pages['lmc_settings']) | ||
1421 | 1333 | self.pages['lmc_settings'].SetPrev(self.pages['select_release']) | ||
1422 | 1334 | else: | ||
1423 | 1335 | self.pages['select_os'].SetNext(self.pages['select_snapshot']) | ||
1424 | 1336 | self.pages['select_snapshot'].SetPrev(self.pages['select_os']) | ||
1425 | 1337 | |||
1426 | 1338 | if(page == self.pages['select_os']): | ||
1427 | 1339 | self.pages['select_snapshot'].fill_build_combo_box_for_date( | ||
1428 | 1340 | self.config.settings['build_date']) | ||
1429 | 1341 | |||
1430 | 1342 | self.pages['select_snapshot'].SetNext(self.pages['lmc_settings']) | ||
1431 | 1343 | self.pages['lmc_settings'].SetPrev(self.pages['select_snapshot']) | ||
1432 | 1344 | |||
1433 | 1345 | if page == self.pages['hardware_details']: | ||
1434 | 1346 | self.pages['select_os'].fill_os_list() | ||
1435 | 1347 | |||
1436 | 1348 | if page == self.pages['release_or_snapshot']: | ||
1437 | 1349 | self.pages['hardware_details'].on_page_changing() | ||
1438 | 1350 | |||
1439 | 1351 | # If about to move into the release selection, make sure the list | ||
1440 | 1352 | # is populated only with releases that are valid with our current | ||
1441 | 1353 | # selection | ||
1442 | 1354 | if( page == self.pages['select_os'] | ||
1443 | 1355 | and self.config.settings['release_or_snapshot'] == "release"): | ||
1444 | 1356 | self.pages['select_release'].update_release_and_build_boxes() | ||
1445 | 1357 | |||
1446 | 1358 | if page == self.pages['select_snapshot']: | ||
1447 | 1359 | # Execute when exiting page | ||
1448 | 1360 | self.pages['select_snapshot'].update_platform() | ||
1449 | 1361 | |||
1450 | 1362 | if( page == self.pages['select_snapshot'] | ||
1451 | 1363 | or page == self.pages['select_release']): | ||
1452 | 1364 | self.pages['lmc_settings'].on_activate() | ||
1453 | 1365 | |||
1454 | 1366 | if page == self.pages['lmc_settings']: | ||
1455 | 1367 | # Forward stays disabled until LMC has finished running | ||
1456 | 1368 | self.wizard.FindWindowById(wx.ID_FORWARD).Disable() | ||
1457 | 1369 | self.pages['run_lmc'].on_activate() | ||
1458 | 1370 | |||
1459 | 1371 | else: # Always enable the forward button if reversing into a page | ||
1460 | 1372 | self.wizard.FindWindowById(wx.ID_FORWARD).Enable() | ||
1461 | 1373 | |||
1462 | 1374 | def go(self, first_page): | ||
1463 | 1375 | file_handler = FetchImage.FileHandler() | ||
1464 | 1376 | self.config = FetchImage.FetchImageConfig() | ||
1465 | 1377 | self.config.settings["force_download"] = False | ||
1466 | 1378 | self.config.settings['compatable_hwpacks'] = ['foo'] | ||
1467 | 1379 | |||
1468 | 1380 | # If the settings file and server index need updating, grab them | ||
1469 | 1381 | file_handler.update_files_from_server(show_wx_progress = True) | ||
1470 | 1382 | |||
1471 | 1383 | # Load settings YAML, which defines the parameters we ask for and | ||
1472 | 1384 | # acceptable responses from the user | ||
1473 | 1385 | self.config.read_config(file_handler.settings_file) | ||
1474 | 1386 | |||
1475 | 1387 | # Using the config we have, look up URLs to download data from in | ||
1476 | 1388 | # the server index | ||
1477 | 1389 | db = FetchImage.DB(file_handler.index_file) | ||
1478 | 1390 | |||
1479 | 1391 | # Create the wizard and the pages | ||
1480 | 1392 | self.wizard = wiz.Wizard(self, -1, "Linaro Media Builder") | ||
1481 | 1393 | |||
1482 | 1394 | self.pages = {} | ||
1483 | 1395 | self.pages['release_or_snapshot'] = ReleaseOrSnapshotPage(self.wizard, | ||
1484 | 1396 | self.config) | ||
1485 | 1397 | self.wizard.FitToPage(self.pages['release_or_snapshot']) | ||
1486 | 1398 | (width, height) = self.wizard.GetSize() | ||
1487 | 1399 | |||
1488 | 1400 | self.pages['hardware_details'] = AboutMyHardwarePage(self.wizard, | ||
1489 | 1401 | self.config, | ||
1490 | 1402 | db, | ||
1491 | 1403 | width) | ||
1492 | 1404 | |||
1493 | 1405 | self.pages['select_release'] = SelectStableRelease(self.wizard, | ||
1494 | 1406 | self.config, | ||
1495 | 1407 | db, | ||
1496 | 1408 | width) | ||
1497 | 1409 | |||
1498 | 1410 | self.pages['select_snapshot'] = SelectSnapshot(self.wizard, | ||
1499 | 1411 | self.config, | ||
1500 | 1412 | db, | ||
1501 | 1413 | width) | ||
1502 | 1414 | |||
1503 | 1415 | self.pages['select_os'] = SelectOS(self.wizard, | ||
1504 | 1416 | self.config, | ||
1505 | 1417 | db, | ||
1506 | 1418 | width) | ||
1507 | 1419 | |||
1508 | 1420 | self.pages['lmc_settings'] = LMC_settings(self.wizard, | ||
1509 | 1421 | self.config, | ||
1510 | 1422 | db, | ||
1511 | 1423 | width) | ||
1512 | 1424 | |||
1513 | 1425 | self.pages['run_lmc'] = RunLMC(self.wizard, | ||
1514 | 1426 | self.config, | ||
1515 | 1427 | db, | ||
1516 | 1428 | width) | ||
1517 | 1429 | |||
1518 | 1430 | self.pages['release_or_snapshot'].SetNext( | ||
1519 | 1431 | self.pages['hardware_details']) | ||
1520 | 1432 | |||
1521 | 1433 | self.pages['hardware_details'].SetPrev( | ||
1522 | 1434 | self.pages['release_or_snapshot']) | ||
1523 | 1435 | |||
1524 | 1436 | self.pages['hardware_details'].SetNext(self.pages['select_os']) | ||
1525 | 1437 | self.pages['select_os'].SetPrev(self.pages['hardware_details']) | ||
1526 | 1438 | # Select OS goes to select build, which is customised for | ||
1527 | 1439 | # releases or snapshots | ||
1528 | 1440 | self.pages['lmc_settings'].SetNext(self.pages['run_lmc']) | ||
1529 | 1441 | self.pages['run_lmc'].SetPrev(self.pages['lmc_settings']) | ||
1530 | 1442 | |||
1531 | 1443 | for (name, page) in self.pages.items(): | ||
1532 | 1444 | self.wizard.GetPageAreaSizer().Add(page) | ||
1533 | 1445 | |||
1534 | 1446 | self.wizard.RunWizard(self.pages['release_or_snapshot']) | ||
1535 | 1447 | |||
1536 | 1448 | |||
1537 | 1449 | def run(start_page = None): | ||
1538 | 1450 | """Wrapper around the full wizard. Is encapsulated in its own function to | ||
1539 | 1451 | allow a restart to be performed, as described in __main___, easily""" | ||
1540 | 1452 | app = wx.PySimpleApp() # Start the application | ||
1541 | 1453 | #logging.basicConfig(level=logging.INFO) | ||
1542 | 1454 | w = TestDriveWizard('Simple Wizard') | ||
1543 | 1455 | return w.go(start_page) | ||
1544 | 1456 | |||
1545 | 1457 | |||
1546 | 1458 | class TestURLLookupFunctions(unittest.TestCase): | ||
1547 | 1459 | |||
1548 | 1460 | def setUp(self): | ||
1549 | 1461 | self.file_handler = FetchImage.FileHandler() | ||
1550 | 1462 | self.file_handler.update_files_from_server(show_wx_progress = True) | ||
1551 | 1463 | self.config = FetchImage.FetchImageConfig() | ||
1552 | 1464 | self.config.settings["force_download"] = False | ||
1553 | 1465 | |||
1554 | 1466 | # Load settings YAML, which defines the parameters we ask for and | ||
1555 | 1467 | # acceptable responses from the user | ||
1556 | 1468 | self.config.read_config(self.file_handler.settings_file) | ||
1557 | 1469 | |||
1558 | 1470 | # Using the config we have, look up URLs to download data from in the | ||
1559 | 1471 | # server index | ||
1560 | 1472 | self.db = FetchImage.DB(self.file_handler.index_file) | ||
1561 | 1473 | |||
1562 | 1474 | def test_000_url_lookup_snapshot_builds(self): | ||
1563 | 1475 | self.settings = self.config.settings | ||
1564 | 1476 | self.settings['release_or_snapshot'] = "snapshot" | ||
1565 | 1477 | |||
1566 | 1478 | #--- Test finding builds near a particular day --- | ||
1567 | 1479 | # This functionality is required for further tests, hence forcing the | ||
1568 | 1480 | # run order by putting numbers in the function name. | ||
1569 | 1481 | today = wx.DateTime() | ||
1570 | 1482 | today.SetToCurrent() | ||
1571 | 1483 | |||
1572 | 1484 | # -- Don't iterate through platforms for snapshot -- | ||
1573 | 1485 | |||
1574 | 1486 | # -- Select hardware -- | ||
1575 | 1487 | for self.settings['hardware'] in ( | ||
1576 | 1488 | self.settings['choice']['hardware'].keys()): | ||
1577 | 1489 | |||
1578 | 1490 | compatable_hwpacks = self.settings['choice']['hwpack'][ | ||
1579 | 1491 | self.settings['hardware']] | ||
1580 | 1492 | |||
1581 | 1493 | future_date, past_date = self.db.get_next_prev_day_with_builds( | ||
1582 | 1494 | "linaro-alip", | ||
1583 | 1495 | today.FormatISODate().encode('ascii'), | ||
1584 | 1496 | compatable_hwpacks) | ||
1585 | 1497 | |||
1586 | 1498 | if past_date == None: | ||
1587 | 1499 | # Some hardware packs are not available in the snapshot repo, | ||
1588 | 1500 | # so just skip if they aren't | ||
1589 | 1501 | continue | ||
1590 | 1502 | |||
1591 | 1503 | builds = self.db.get_binary_builds_on_day_from_db( | ||
1592 | 1504 | "linaro-alip", | ||
1593 | 1505 | past_date, | ||
1594 | 1506 | compatable_hwpacks) | ||
1595 | 1507 | |||
1596 | 1508 | self.assertTrue(len(builds)) | ||
1597 | 1509 | # If the above assert fails, either the DB is empty, or | ||
1598 | 1510 | # db.get_binary_builds_on_day_from_db failed | ||
1599 | 1511 | |||
1600 | 1512 | def test_100_url_lookup_snapshots(self): | ||
1601 | 1513 | self.settings = self.config.settings | ||
1602 | 1514 | self.settings['release_or_snapshot'] = "snapshot" | ||
1603 | 1515 | |||
1604 | 1516 | #--- Test snapshot build lookup --- | ||
1605 | 1517 | # -- Fix a build date -- | ||
1606 | 1518 | # We only need to look up a single snapshot date. Start with today and | ||
1607 | 1519 | # go with the day in the DB, build 0 | ||
1608 | 1520 | today = wx.DateTime() | ||
1609 | 1521 | today.SetToCurrent() | ||
1610 | 1522 | |||
1611 | 1523 | # -- Don't iterate through platforms for snapshot -- | ||
1612 | 1524 | |||
1613 | 1525 | # -- Select hardware -- | ||
1614 | 1526 | for self.settings['hardware'] in ( | ||
1615 | 1527 | self.settings['choice']['hardware'].keys()): | ||
1616 | 1528 | |||
1617 | 1529 | compatable_hwpacks = self.settings['choice']['hwpack'][ | ||
1618 | 1530 | self.settings['hardware']] | ||
1619 | 1531 | |||
1620 | 1532 | future_date, past_date = self.db.get_next_prev_day_with_builds( | ||
1621 | 1533 | "linaro-alip", | ||
1622 | 1534 | today.FormatISODate().encode('ascii'), | ||
1623 | 1535 | compatable_hwpacks) | ||
1624 | 1536 | |||
1625 | 1537 | if past_date == None: | ||
1626 | 1538 | # Some hardware packs are not available in the snapshot repo, | ||
1627 | 1539 | # so just skip if they aren't | ||
1628 | 1540 | continue | ||
1629 | 1541 | |||
1630 | 1542 | builds = self.db.get_binary_builds_on_day_from_db( | ||
1631 | 1543 | "linaro-alip", | ||
1632 | 1544 | past_date, | ||
1633 | 1545 | compatable_hwpacks) | ||
1634 | 1546 | |||
1635 | 1547 | self.assertTrue(len(builds)) | ||
1636 | 1548 | # The above code is tested in test_000_url_lookup_snapshot_build. | ||
1637 | 1549 | # If the above assert fails, either the DB is empty, or | ||
1638 | 1550 | # db.get_binary_builds_on_day_from_db failed. | ||
1639 | 1551 | |||
1640 | 1552 | small_date = re.sub('-', '', past_date) | ||
1641 | 1553 | self.settings['build'] = small_date + ":" + "0" | ||
1642 | 1554 | |||
1643 | 1555 | # -- Iterate through hardware packs -- | ||
1644 | 1556 | for self.settings['hwpack'] in compatable_hwpacks: | ||
1645 | 1557 | |||
1646 | 1558 | # If hardware pack is available... | ||
1647 | 1559 | if(self.settings['hwpack'] | ||
1648 | 1560 | in self.db.get_hwpacks('snapshot_hwpacks')): | ||
1649 | 1561 | |||
1650 | 1562 | # -- Iterate through images | ||
1651 | 1563 | os_list = self.db.get_os_list_from('snapshot_binaries') | ||
1652 | 1564 | |||
1653 | 1565 | for self.settings['image'] in os_list: | ||
1654 | 1566 | if re.search('old', self.settings['image']): | ||
1655 | 1567 | # Directories with old in the name are of no | ||
1656 | 1568 | # interest to us | ||
1657 | 1569 | continue | ||
1658 | 1570 | |||
1659 | 1571 | # -- Check build which matches these parameters | ||
1660 | 1572 | # (builds that don't match are excluded in UI) -- | ||
1661 | 1573 | if( len(self.db.execute_return_list( | ||
1662 | 1574 | 'select * from snapshot_hwpacks ' | ||
1663 | 1575 | 'where hardware == ? ' | ||
1664 | 1576 | 'and date == ? ' | ||
1665 | 1577 | 'and build == ?', | ||
1666 | 1578 | (self.settings['hwpack'], | ||
1667 | 1579 | small_date, | ||
1668 | 1580 | "0"))) | ||
1669 | 1581 | and len(self.db.execute_return_list( | ||
1670 | 1582 | 'select * from snapshot_binaries ' | ||
1671 | 1583 | 'where image == ? ' | ||
1672 | 1584 | 'and date == ? ' | ||
1673 | 1585 | 'and build == ?', | ||
1674 | 1586 | (self.settings['image'], | ||
1675 | 1587 | small_date, | ||
1676 | 1588 | "0")))): | ||
1677 | 1589 | |||
1678 | 1590 | # - Run the function under test! - | ||
1679 | 1591 | image_url, hwpack_url = ( | ||
1680 | 1592 | self.db.get_image_and_hwpack_urls(self.settings)) | ||
1681 | 1593 | |||
1682 | 1594 | self.assertTrue(image_url) | ||
1683 | 1595 | self.assertTrue(hwpack_url) | ||
1684 | 1596 | |||
1685 | 1597 | def test_101_url_lookup_releases(self): | ||
1686 | 1598 | #--- Test release build lookup --- | ||
1687 | 1599 | self.settings = self.config.settings | ||
1688 | 1600 | self.settings['release_or_snapshot'] = "release" | ||
1689 | 1601 | # -- Select hardware -- | ||
1690 | 1602 | for self.settings['hardware'] in ( | ||
1691 | 1603 | self.settings['choice']['hardware'].keys()): | ||
1692 | 1604 | compatable_hwpacks = ( | ||
1693 | 1605 | self.settings['choice']['hwpack'][self.settings['hardware']]) | ||
1694 | 1606 | |||
1695 | 1607 | # -- Iterate through hardware packs -- | ||
1696 | 1608 | for self.settings['hwpack'] in compatable_hwpacks: | ||
1697 | 1609 | |||
1698 | 1610 | # If hardware pack is available... | ||
1699 | 1611 | if(self.settings['hwpack'] | ||
1700 | 1612 | in self.db.get_hwpacks('release_hwpacks')): | ||
1701 | 1613 | |||
1702 | 1614 | # -- Iterate through images | ||
1703 | 1615 | os_list = self.db.get_os_list_from('release_binaries') | ||
1704 | 1616 | |||
1705 | 1617 | for self.settings['image'] in os_list: | ||
1706 | 1618 | if re.search('old', self.settings['image']): | ||
1707 | 1619 | # Directories with old in the name are of no | ||
1708 | 1620 | # interest to us | ||
1709 | 1621 | continue | ||
1710 | 1622 | |||
1711 | 1623 | for platform, ignore in ( | ||
1712 | 1624 | self.settings['choice']['platform'].items()): | ||
1713 | 1625 | self.settings['platform'] = platform | ||
1714 | 1626 | |||
1715 | 1627 | # -- Iterate through available builds -- | ||
1716 | 1628 | builds = self.db.get_builds( | ||
1717 | 1629 | self.settings['platform'], | ||
1718 | 1630 | self.settings['image']) | ||
1719 | 1631 | |||
1720 | 1632 | for build in builds: | ||
1721 | 1633 | self.settings['build'] = build | ||
1722 | 1634 | |||
1723 | 1635 | # -- Check build which matches these parameters | ||
1724 | 1636 | #(builds that don't match are excluded in UI)-- | ||
1725 | 1637 | if( len(self.db.execute_return_list( | ||
1726 | 1638 | 'select * from release_hwpacks ' | ||
1727 | 1639 | 'where platform == ? ' | ||
1728 | 1640 | 'and hardware == ? ' | ||
1729 | 1641 | 'and build == ?', | ||
1730 | 1642 | (self.settings['platform'], | ||
1731 | 1643 | self.settings['hwpack'], | ||
1732 | 1644 | self.settings['build']))) | ||
1733 | 1645 | and len(self.db.execute_return_list( | ||
1734 | 1646 | 'select * from release_binaries ' | ||
1735 | 1647 | 'where platform == ? ' | ||
1736 | 1648 | 'and image == ? ' | ||
1737 | 1649 | 'and build == ?', | ||
1738 | 1650 | (self.settings['platform'], | ||
1739 | 1651 | self.settings['image'], | ||
1740 | 1652 | self.settings['build'])))): | ||
1741 | 1653 | |||
1742 | 1654 | # - Run the function under test! - | ||
1743 | 1655 | image_url, hwpack_url = ( | ||
1744 | 1656 | self.db.get_image_and_hwpack_urls(self.settings)) | ||
1745 | 1657 | self.assertTrue(image_url) | ||
1746 | 1658 | self.assertTrue(hwpack_url) | ||
1747 | 1659 | |||
1748 | 1660 | if __name__ == '__main__': | ||
1749 | 1661 | run() |
133 + if(style != None): bind_to, label = label, style = style) bind_to, label = label)
134 + radio_button = wx.RadioButton(
135 + else:
136 + radio_button = wx.RadioButton(
I think that's unnecessary isn't it? style=None is usually the default.
(also we usually avoid spaces around = in method calls)
226 + if "panda" in self.settings[ 'choice' ]['hardware' ].keys( ):
227 + default_hardware = "panda"
Was this just to make your testing easier? I don't think that the choice should
have a default until we're in a position to remember their last answer.
1562 + def test_url_ lookup( self):
Please break up this test in to several tests. These sort of test cases
are a nightmare to debug. Ideally each test method should assert a single
thing.
Thanks,
James