Merge lp:~ara/mago/cleaner_happier into lp:~mago-contributors/mago/mago-1.0
- cleaner_happier
- Merge into mago-1.0
Proposed by
Ara Pulido
Status: | Merged |
---|---|
Merged at revision: | 134 |
Proposed branch: | lp:~ara/mago/cleaner_happier |
Merge into: | lp:~mago-contributors/mago/mago-1.0 |
Diff against target: |
1391 lines (+316/-707) 9 files modified
mago/application/gcalc.py (+15/-27) mago/application/gedit.py (+25/-66) mago/application/gnome_screenshot.py (+46/-154) mago/application/main.py (+19/-39) mago/application/policykit.py (+4/-11) mago/application/seahorse.py (+76/-193) mago/application/ubuntu_menu.py (+1/-4) mago/application/update_manager.py (+125/-199) mago/test_suite/gedit.py (+5/-14) |
To merge this branch: | bzr merge lp:~ara/mago/cleaner_happier |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Tatum | Approve | ||
Review via email: mp+38923@code.launchpad.net |
Commit message
Description of the change
Avoid the unnecessary try/catch blocks that are all over the application wrappers. The main reason of these blocks were to give a correct error message, when LDTP didn't give us one.
We are going to avoid these blocks, and, whenever LDTP gives a wrong (or not clear) error message, we are going to file a bug against LDTP instead. This will make Mago code cleaner, and we will be improving LDTP.
To post a comment you must log in.
Revision history for this message
Ara Pulido (ara) wrote : | # |
Indeed, the LDTP exceptions can be improved a lot. This is why I want to change the strategy, and, every time I receive an LDTP exception that does not help me, I will file a bug against LDTP instead.
Thanks for the review, I will merge the changes now.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'mago/application/gcalc.py' |
2 | --- mago/application/gcalc.py 2010-10-15 11:46:53 +0000 |
3 | +++ mago/application/gcalc.py 2010-10-20 10:26:00 +0000 |
4 | @@ -97,14 +97,13 @@ |
5 | True |
6 | """ |
7 | calculator = ooldtp.context(self.name) |
8 | - try: |
9 | - children = calculator.getchild(button,'push button') |
10 | - for child in children: |
11 | - childName=child.getName() |
12 | - if calculator.hasstate(childName, ldtp.state.SHOWING): |
13 | - return True |
14 | - except ldtp.LdtpExecutionError: |
15 | - raise ldtp.LdtpExecutionError, "Error locating button %s" % button |
16 | + |
17 | + children = calculator.getchild(button,'push button') |
18 | + for child in children: |
19 | + childName=child.getName() |
20 | + if calculator.hasstate(childName, ldtp.state.SHOWING): |
21 | + return True |
22 | + |
23 | return False |
24 | |
25 | def push(self, buttons): |
26 | @@ -120,12 +119,9 @@ |
27 | """ |
28 | calculator = ooldtp.context(self.name) |
29 | for button in buttons: |
30 | - try: |
31 | - children = calculator.getchild(self.BUTTONS[button],'push button') |
32 | - for child in children: |
33 | - child.click() |
34 | - except ldtp.LdtpExecutionError: |
35 | - raise ldtp.LdtpExecutionError, "Error clicking button %s" % button |
36 | + children = calculator.getchild(self.BUTTONS[button],'push button') |
37 | + for child in children: |
38 | + child.click() |
39 | |
40 | def get_view(self): |
41 | """ |
42 | @@ -161,15 +157,10 @@ |
43 | new_window_name = self.VIEWS[new_view]["WINDOW"] |
44 | new_view_menu_name = self.VIEWS[new_view]["MENU"] |
45 | calculator = ooldtp.context(self.name) |
46 | - try: |
47 | - mnu_new_view = calculator.getchild(new_view_menu_name) |
48 | - except ldtp.LdtpExecutionError: |
49 | - raise ldtp.LdtpExecutionError, "The menu item for the requested view was not found." |
50 | + mnu_new_view = calculator.getchild(new_view_menu_name) |
51 | |
52 | - try: |
53 | - mnu_new_view.selectmenuitem() |
54 | - except ldtp.LdtpExecutionError: |
55 | - raise ldtp.LdtpExecutionError, "There was a problem changing views." |
56 | + mnu_new_view.selectmenuitem() |
57 | + |
58 | self.set_name(new_window_name) |
59 | calculator.remap() |
60 | time.sleep(self.SLEEP_DELAY) # need to give mago some time to catch up to calc ui |
61 | @@ -188,11 +179,8 @@ |
62 | @rtype: string |
63 | """ |
64 | calculator = ooldtp.context(self.name) |
65 | - try: |
66 | - editBar = calculator.getchild(role=self.EDITBAR_ROLE) |
67 | - value = editBar[0].gettextvalue() |
68 | - except ldtp.LdtpExecutionError: |
69 | - raise ldtp.LdtpExecutionError, "There was a problem reading the value." |
70 | + editBar = calculator.getchild(role=self.EDITBAR_ROLE) |
71 | + value = editBar[0].gettextvalue() |
72 | return value |
73 | |
74 | def set_thousands_separator(self, option = True): |
75 | |
76 | === modified file 'mago/application/gedit.py' |
77 | --- mago/application/gedit.py 2010-07-22 10:43:18 +0000 |
78 | +++ mago/application/gedit.py 2010-10-20 10:26:00 +0000 |
79 | @@ -66,30 +66,16 @@ |
80 | Application.save(self, self.MNU_SAVE) |
81 | ooldtp.context(self.name) |
82 | |
83 | - try: |
84 | - ldtp.waittillguiexist(self.SAVE_DLG) |
85 | - save_dialog = ooldtp.context(self.SAVE_DLG) |
86 | - except ldtp.LdtpExecutionError: |
87 | - raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found." |
88 | - try: |
89 | - save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) |
90 | - except ldtp.LdtpExecutionError: |
91 | - raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found." |
92 | - try: |
93 | - ldtp.wait(2) |
94 | - save_dlg_txt_filename.settextvalue(filename) |
95 | - except ldtp.LdtpExecutionError: |
96 | - raise ldtp.LdtpExecutionError, "We couldn't write text." |
97 | + ldtp.waittillguiexist(self.SAVE_DLG) |
98 | + save_dialog = ooldtp.context(self.SAVE_DLG) |
99 | + |
100 | + save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) |
101 | + ldtp.wait(2) |
102 | + save_dlg_txt_filename.settextvalue(filename) |
103 | |
104 | - try: |
105 | - save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) |
106 | - except ldtp.LdtpExecutionError: |
107 | - raise ldtp.LdtpExecutionError, "The button Save in Gedit save dialog was not found." |
108 | + save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) |
109 | |
110 | - try: |
111 | - save_dlg_btn_save.click() |
112 | - except ldtp.LdtpExecutionError: |
113 | - raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button." |
114 | + save_dlg_btn_save.click() |
115 | |
116 | ldtp.waittillguinotexist(self.SAVE_DLG) |
117 | ldtp.wait(1) |
118 | @@ -107,15 +93,9 @@ |
119 | """ |
120 | |
121 | # Exit using the Quit menu |
122 | - try: |
123 | - gedit = ooldtp.context(self.name) |
124 | - try: |
125 | - quit_menu = gedit.getchild(self.MNU_QUIT) |
126 | - except ldtp.LdtpExecutionError: |
127 | - raise ldtp.LdtpExecutionError, "The quit menu was not found." |
128 | - quit_menu.selectmenuitem() |
129 | - except ldtp.LdtpExecutionError: |
130 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
131 | + gedit = ooldtp.context(self.name) |
132 | + quit_menu = gedit.getchild(self.MNU_QUIT) |
133 | + quit_menu.selectmenuitem() |
134 | |
135 | question_dialog = None |
136 | count = 0 |
137 | @@ -137,45 +117,24 @@ |
138 | question_dlg_btn_save.click() |
139 | except ldtp.LdtpExecutionError: |
140 | # If the Save button was not found, we will try to find the Save As |
141 | - try: |
142 | - question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE_AS) |
143 | - question_dlg_btn_save.click() |
144 | - except ldtp.LdtpExecutionError: |
145 | - raise ldtp.LdtpExecutionError, "The save or save as buttons in Gedit question dialog were not found." |
146 | - |
147 | - try: |
148 | - ldtp.waittillguiexist(self.SAVE_DLG) |
149 | - save_dialog = ooldtp.context(self.SAVE_DLG) |
150 | - except ldtp.LdtpExecutionError: |
151 | - raise ldtp.LdtpExecutionError, "The Gedit save dialog was not found." |
152 | - try: |
153 | - save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) |
154 | - except ldtp.LdtpExecutionError: |
155 | - raise ldtp.LdtpExecutionError, "The filename txt field in Gedit save dialog was not found." |
156 | - try: |
157 | - ldtp.wait(2) |
158 | - save_dlg_txt_filename.settextvalue(filename) |
159 | - except ldtp.LdtpExecutionError: |
160 | - raise ldtp.LdtpExecutionError, "There was an error when writing the text." |
161 | - |
162 | - try: |
163 | - save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) |
164 | - except ldtp.LdtpExecutionError: |
165 | - raise ldtp.LdtpExecutionError, "The save button in Gedit save dialog was not found." |
166 | - |
167 | - try: |
168 | - save_dlg_btn_save.click() |
169 | - except ldtp.LdtpExecutionError: |
170 | - raise ldtp.LdtpExecutionError, "There was an error when pushing the Save button." |
171 | + question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE_AS) |
172 | + question_dlg_btn_save.click() |
173 | + |
174 | + ldtp.waittillguiexist(self.SAVE_DLG) |
175 | + save_dialog = ooldtp.context(self.SAVE_DLG) |
176 | + |
177 | + save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME) |
178 | + ldtp.wait(2) |
179 | + save_dlg_txt_filename.settextvalue(filename) |
180 | + |
181 | + save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE) |
182 | + save_dlg_btn_save.click() |
183 | |
184 | ldtp.waittillguinotexist(self.SAVE_DLG) |
185 | |
186 | else: |
187 | - try: |
188 | - question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE) |
189 | - question_dlg_btn_close.click() |
190 | - except ldtp.LdtpExecutionError: |
191 | - raise ldtp.LdtpExecutionError, "It was not possible to click the close button." |
192 | + question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE) |
193 | + question_dlg_btn_close.click() |
194 | |
195 | gedit.waittillguinotexist(guiTimeOut=20) |
196 | |
197 | |
198 | === modified file 'mago/application/gnome_screenshot.py' |
199 | --- mago/application/gnome_screenshot.py 2010-07-22 10:43:18 +0000 |
200 | +++ mago/application/gnome_screenshot.py 2010-10-20 10:26:00 +0000 |
201 | @@ -60,45 +60,18 @@ |
202 | @param delay: The number of seconds to delay before taking the |
203 | screenshot. |
204 | """ |
205 | - try: |
206 | - gnome_screenshot = ooldtp.context(self.name) |
207 | - except ldtp.LdtpExecutionError: |
208 | - raise ldtp.LdtpExecutionError, "Error finding " + name |
209 | - |
210 | - try: |
211 | - radio_button = gnome_screenshot.getchild(self.GRAB_THE_WHOLE_DESKTOP_RADIO) |
212 | - except ldtp.LdtpExecutionError: |
213 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_THE_WHOLE_DESKTOP_RADIO |
214 | - |
215 | - try: |
216 | - radio_button.click() |
217 | - except ldtp.LdtpExecutionError: |
218 | - raise ldtp.LdtpExecutionError, "Error clicking on radio button." |
219 | - |
220 | - try: |
221 | - delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
222 | - except ldtp.LdtpExecutionError: |
223 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_AFTER_DELAY_FIELD |
224 | - |
225 | - try: |
226 | - delay_field.setvalue(delay) |
227 | - except ldtp.LdtpExecutionError: |
228 | - raise ldtp.LdtpExecutionError, "Error setting value to " + self.GRAB_AFTER_DELAY_FIELD |
229 | - |
230 | - try: |
231 | - save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
232 | - except ldtp.LdtpExecutionError: |
233 | - raise ldtp.LdtpExecutionError, "Error finding " + self.TAKE_SCREENSHOT_BUTTON |
234 | - |
235 | - try: |
236 | - ldtp.click(self.WINDOW, self.TAKE_SCREENSHOT_BUTTON) |
237 | - except ldtp.LdtpExecutionError: |
238 | - raise ldtp.LdtpExecutionError, "Error clicking on save button" |
239 | - |
240 | - try: |
241 | - ldtp.waittillguinotexist(self.WINDOW) |
242 | - except ldtp.LdtpExecutionError: |
243 | - raise ldtp.LdtpExecutionError, "Window " + self.WINDOW + " did not go away." |
244 | + gnome_screenshot = ooldtp.context(self.name) |
245 | + |
246 | + radio_button = gnome_screenshot.getchild(self.GRAB_THE_WHOLE_DESKTOP_RADIO) |
247 | + radio_button.click() |
248 | + |
249 | + delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
250 | + delay_field.setvalue(delay) |
251 | + |
252 | + save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
253 | + ldtp.click(self.WINDOW, self.TAKE_SCREENSHOT_BUTTON) |
254 | + |
255 | + ldtp.waittillguinotexist(self.WINDOW) |
256 | |
257 | |
258 | def take_current_window_screenshot(self, delay): |
259 | @@ -112,45 +85,18 @@ |
260 | @param delay: The number of seconds to delay before taking the |
261 | screenshot. |
262 | """ |
263 | - try: |
264 | - gnome_screenshot = ooldtp.context(self.name) |
265 | - except ldtp.LdtpExecutionError: |
266 | - raise ldtp.LdtpExecutionError, "Error finding " + name |
267 | - |
268 | - try: |
269 | - radio_button = gnome_screenshot.getchild(self.GRAB_THE_CURRENT_WINDOW_RADIO) |
270 | - except ldtp.LdtpExecutionError: |
271 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_THE_CURRENT_WINDOW_RADIO |
272 | - |
273 | - try: |
274 | - radio_button.click() |
275 | - except ldtp.LdtpExecutionError: |
276 | - raise ldtp.LdtpExecutionError, "Error clicking on radio button" |
277 | + gnome_screenshot = ooldtp.context(self.name) |
278 | + |
279 | + radio_button = gnome_screenshot.getchild(self.GRAB_THE_CURRENT_WINDOW_RADIO) |
280 | + radio_button.click() |
281 | |
282 | - try: |
283 | - delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
284 | - except ldtp.LdtpExecutionError: |
285 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_AFTER_DELAY_FIELD |
286 | - |
287 | - try: |
288 | - delay_field.setvalue(delay) |
289 | - except ldtp.LdtpExecutionError: |
290 | - raise ldtp.LdtpExecutionError, "Error setting delay to " + delay |
291 | - |
292 | - try: |
293 | - save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
294 | - except ldtp.LdtpExecutionError: |
295 | - raise ldtp.LdtpExecutionError, "Error finding " + self.TAKE_SCREENSHOT_BUTTON |
296 | - |
297 | - try: |
298 | - save_button.click() |
299 | - except ldtp.LdtpExecutionError: |
300 | - raise ldtp.LdtpExecutionError, "Error clicking on save button" |
301 | - |
302 | - try: |
303 | - ldtp.waittillguinotexist(self.WINDOW) |
304 | - except ldtp.LdtpExecutionError: |
305 | - raise ldtp.LdtpExecutionError, "Window " + self.WINDOW + " did not go away" |
306 | + delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
307 | + delay_field.setvalue(delay) |
308 | + |
309 | + save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
310 | + save_button.click() |
311 | + |
312 | + ldtp.waittillguinotexist(self.WINDOW) |
313 | |
314 | def grab_selected_area(self, delay): |
315 | """ |
316 | @@ -163,45 +109,18 @@ |
317 | @param delay: The number of seconds to delay before taking the |
318 | screenshot. |
319 | """ |
320 | - try: |
321 | - gnome_screenshot = ooldtp.context(self.name) |
322 | - except ldtp.LdtpExecutionError: |
323 | - raise ldtp.LdtpExecutionError, "Error finding " + name |
324 | - |
325 | - try: |
326 | - radio_button = gnome_screenshot.getchild(self.GRAB_A_SELECTED_AREA) |
327 | - except ldtp.LdtpExecutionError: |
328 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_A_SELECTED_AREA |
329 | - |
330 | - try: |
331 | - radio_button.click() |
332 | - except ldtp.LdtpExecutionError: |
333 | - raise ldtp.LdtpExecutionError, "Error clicking on radio button" |
334 | - |
335 | - try: |
336 | - delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
337 | - except ldtp.LdtpExecutionError: |
338 | - raise ldtp.LdtpExecutionError, "Error finding " + self.GRAB_AFTER_DELAY_FIELD |
339 | - |
340 | - try: |
341 | - delay_field.setvalue(delay) |
342 | - except ldtp.LdtpExecutionError: |
343 | - raise ldtp.LdtpExecutionError, "Error setting delay to " + delay |
344 | - |
345 | - try: |
346 | - save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
347 | - except ldtp.LdtpExecutionError: |
348 | - raise ldtp.LdtpExecutionError, "Error finding " + self.TAKE_SCREENSHOT_BUTTON |
349 | - |
350 | - try: |
351 | - save_button.click() |
352 | - except ldtp.LdtpExecutionError: |
353 | - raise ldtp.LdtpExecutionError, "Error clicking on save button" |
354 | - |
355 | - try: |
356 | - ldtp.waittillguinotexist(self.WINDOW) |
357 | - except ldtp.LdtpExecutionError: |
358 | - raise ldtp.LdtpExecutionError, "Window " + self.WINDOW + " did not go away" |
359 | + gnome_screenshot = ooldtp.context(self.name) |
360 | + |
361 | + radio_button = gnome_screenshot.getchild(self.GRAB_A_SELECTED_AREA) |
362 | + radio_button.click() |
363 | + |
364 | + delay_field = gnome_screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD) |
365 | + delay_field.setvalue(delay) |
366 | + |
367 | + save_button = gnome_screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON) |
368 | + save_button.click() |
369 | + |
370 | + ldtp.waittillguinotexist(self.WINDOW) |
371 | |
372 | # Select the area of the screen for the screenshot. As long as your screen is |
373 | # larger than 200x200px this should work fine. |
374 | @@ -221,25 +140,11 @@ |
375 | into the current users home folder. You cannot |
376 | specify a directory. |
377 | """ |
378 | - try: |
379 | - ldtp.waittillguiexist(self.SAVE_FILE_WINDOW) |
380 | - except ldtp.LdtpExecutionError: |
381 | - raise ldtp.LdtpExecutionError, "Window " + self.SAVE_FILE_WINDOW + " did not appear" |
382 | - |
383 | - try: |
384 | - save_file_window = ooldtp.context(self.SAVE_FILE_WINDOW) |
385 | - except ldtp.LdtpExecutionError: |
386 | - raise ldtp.LdtpExecutionError, "Error finding window " + self.SAVE_FILE_WINDOW |
387 | - |
388 | - try: |
389 | - filename_field = save_file_window.getchild(self.SAVE_FILE_NAME_TEXT) |
390 | - except ldtp.LdtpExecutionError: |
391 | - raise ldtp.LdtpExecutionError, "Error finding " + self.SAVE_FILE_NAME_TEXT |
392 | - |
393 | - try: |
394 | - filename_field.settextvalue(filename) |
395 | - except ldtp.LdtpExecutionError: |
396 | - raise ldtp.LdtpExecutionError, "Error setting filename to " + delay |
397 | + ldtp.waittillguiexist(self.SAVE_FILE_WINDOW) |
398 | + |
399 | + save_file_window = ooldtp.context(self.SAVE_FILE_WINDOW) |
400 | + filename_field = save_file_window.getchild(self.SAVE_FILE_NAME_TEXT) |
401 | + filename_field.settextvalue(filename) |
402 | |
403 | # There is a bug in gnome-screenshot that prevents the combobox |
404 | # name from being used. There is only one combo box so its easy to |
405 | @@ -247,22 +152,9 @@ |
406 | # |
407 | # Also for some reason ooldtp didn't seem to be able select the combo |
408 | # box properly. |
409 | - try: |
410 | - ldtp.comboselectindex(self.SAVE_FILE_WINDOW, "cbo#0", 0) |
411 | - except ldtp.LdtpExecutionError: |
412 | - raise ldtp.LdtpExecutionError, "Error setting folder to home folder" |
413 | - |
414 | - try: |
415 | - save_file_button = save_file_window.getchild(self.SAVE_FILE_BUTTON) |
416 | - except ldtp.LdtpExecutionError: |
417 | - raise ldtp.LdtpExecutionError, "Error finding " + self.SAVE_FILE_BUTTON |
418 | - |
419 | - try: |
420 | - save_file_button.click() |
421 | - except ldtp.LdtpExecutionError: |
422 | - raise ldtp.LdtpExecutionError, "Error clicking on save button" |
423 | - |
424 | - try: |
425 | - ldtp.waittillguinotexist(self.SAVE_FILE_WINDOW) |
426 | - except ldtp.LdtpExecutionError: |
427 | - raise ldtp.LdtpExecutionError, "Window " + self.SAVE_FILE_WINDOW + " did not go away" |
428 | + ldtp.comboselectindex(self.SAVE_FILE_WINDOW, "cbo#0", 0) |
429 | + |
430 | + save_file_button = save_file_window.getchild(self.SAVE_FILE_BUTTON) |
431 | + |
432 | + save_file_button.click() |
433 | + ldtp.waittillguinotexist(self.SAVE_FILE_WINDOW) |
434 | |
435 | === modified file 'mago/application/main.py' |
436 | --- mago/application/main.py 2010-09-10 09:16:21 +0000 |
437 | +++ mago/application/main.py 2010-10-20 10:26:00 +0000 |
438 | @@ -99,24 +99,19 @@ |
439 | """ |
440 | Given an application, it tries to close it. |
441 | """ |
442 | - try: |
443 | - app = ooldtp.context(self.name) |
444 | - try: |
445 | - close_widget = app.getchild(self.close_name) |
446 | - except ldtp.LdtpExecutionError: |
447 | - raise ldtp.LdtpExecutionError, "The " + self.close_name + " widget was not found." |
448 | + app = ooldtp.context(self.name) |
449 | + close_widget = app.getchild(self.close_name) |
450 | |
451 | - if self.close_type == 'menu': |
452 | - close_widget.selectmenuitem() |
453 | - elif self.close_type == 'button': |
454 | - close_widget.click() |
455 | - else: |
456 | - raise ldtp.LdtpExecutionError, "Wrong close item type." |
457 | - response = ldtp.waittillguinotexist(self.name, '', 20) |
458 | - if response == 0: |
459 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
460 | - except ldtp.LdtpExecutionError, msg: |
461 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application: " + str(msg) |
462 | + if self.close_type == 'menu': |
463 | + close_widget.selectmenuitem() |
464 | + elif self.close_type == 'button': |
465 | + close_widget.click() |
466 | + else: |
467 | + raise ldtp.LdtpExecutionError, "Wrong close item type." |
468 | + |
469 | + response = ldtp.waittillguinotexist(self.name, '', 20) |
470 | + if response == 0: |
471 | + raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
472 | |
473 | def save(self, save_menu=_('mnuSave')): |
474 | """ |
475 | @@ -126,16 +121,10 @@ |
476 | @type save_menu: string |
477 | @param save_menu: The name of the Save menu of the application. If not mentioned the default will be used ("Save"). |
478 | """ |
479 | - try: |
480 | - app = ooldtp.context(self.name) |
481 | - try: |
482 | - actualMenu = app.getchild(save_menu) |
483 | - except ldtp.LdtpExecutionError: |
484 | - raise ldtp.LdtpExecutionError, "The " + save_menu + " menu was not found." |
485 | + app = ooldtp.context(self.name) |
486 | + actualMenu = app.getchild(save_menu) |
487 | |
488 | - actualMenu.selectmenuitem() |
489 | - except ldtp.LdtpExecutionError: |
490 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when saving the current document." |
491 | + actualMenu.selectmenuitem() |
492 | |
493 | def write_text(self, text, txt_field=''): |
494 | """ |
495 | @@ -144,20 +133,11 @@ |
496 | app = ooldtp.context(self.name) |
497 | |
498 | if txt_field == '': |
499 | - try: |
500 | - ldtp.enterstring(text) |
501 | - except ldtp.LdtpExecutionError: |
502 | - raise ldtp.LdtpExecutionError, "We couldn't write text." |
503 | + ldtp.enterstring(text) |
504 | else: |
505 | - try: |
506 | - app_txt_fields = app.getchild(txt_field, "text") |
507 | - except ldtp.LdtpExecutionError: |
508 | - raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
509 | - try: |
510 | - for field in app_txt_fields: |
511 | - field.settextvalue(text) |
512 | - except ldtp.LdtpExecutionError: |
513 | - raise ldtp.LdtpExecutionError, "We couldn't write text." |
514 | + app_txt_fields = app.getchild(txt_field, "text") |
515 | + for field in app_txt_fields: |
516 | + field.settextvalue(text) |
517 | |
518 | def _enable_a11y(self, enable): |
519 | os.environ['NO_GAIL'] = str(int(not enable)) |
520 | |
521 | === modified file 'mago/application/policykit.py' |
522 | --- mago/application/policykit.py 2010-07-22 10:43:18 +0000 |
523 | +++ mago/application/policykit.py 2010-10-20 10:26:00 +0000 |
524 | @@ -57,13 +57,9 @@ |
525 | |
526 | ooldtp.context(self.name) |
527 | |
528 | - try: |
529 | - ldtp.enterstring (self.password) |
530 | - ldtp.enterstring ("<enter>") |
531 | + ldtp.enterstring (self.password) |
532 | + ldtp.enterstring ("<enter>") |
533 | |
534 | - except ldtp.LdtpExecutionError: |
535 | - raise ldtp.LdtpExecutionError, "The PolicyKit txt field for the password was not found." |
536 | - |
537 | # TODO: Change this to use ooldtp |
538 | # try: |
539 | # btnOK = polKit.getchild(self.BTN_OK) |
540 | @@ -78,10 +74,7 @@ |
541 | def cancel(self): |
542 | polKit = ooldtp.context(self.name) |
543 | |
544 | - try: |
545 | - cancelButton = polKit.getchild(self.BTN_CANCEL) |
546 | - except ldtp.LdtpExecutionError: |
547 | - raise ldtp.LdtpExecutionError, "The PolicyKit cancel button was not found." |
548 | - |
549 | + cancelButton = polKit.getchild(self.BTN_CANCEL) |
550 | cancelButton.click() |
551 | + |
552 | ldtp.waittillguinotexist (self.name) |
553 | |
554 | === modified file 'mago/application/seahorse.py' |
555 | --- mago/application/seahorse.py 2010-07-22 10:43:18 +0000 |
556 | +++ mago/application/seahorse.py 2010-10-20 10:26:00 +0000 |
557 | @@ -68,45 +68,26 @@ |
558 | |
559 | seahorse = ooldtp.context(self.name) |
560 | |
561 | - try: |
562 | - mnu_new_key = seahorse.getchild(self.MNU_NEWKEY) |
563 | - except ldtp.LdtpExecutionError: |
564 | - raise ldtp.LdtpExecutionError, "The new key menu was not found." |
565 | - |
566 | - try: |
567 | - mnu_new_key.selectmenuitem() |
568 | - except ldtp.LdtpExecutionError: |
569 | - raise ldtp.LdtpExecutionError, "There was a problem when selecting new key menu item." |
570 | - |
571 | - try: |
572 | - ldtp.waittillguiexist(self.NEWKEY_DLG) |
573 | - dlg_new_key = ooldtp.context(self.NEWKEY_DLG) |
574 | - except ldtp.LdtpExecutionError: |
575 | - raise ldtp.LdtpExecutionError, "The new key dialog was not found." |
576 | - |
577 | - try: |
578 | - table = dlg_new_key.getchild(role = 'table') |
579 | - types_table = table[0] |
580 | - |
581 | - for i in range(0, types_table.getrowcount(), 1): |
582 | - text = types_table.getcellvalue(i, 1) |
583 | - candidate = text.split('\n')[0] |
584 | - if candidate == key_type: |
585 | - types_table.selectrowindex(i) |
586 | - break |
587 | - ldtp.wait(1) |
588 | - except ldtp.LdtpExecutionError: |
589 | - raise ldtp.LdtpExecutionError, "Error getting the key types table." |
590 | - |
591 | - try: |
592 | - btn_continue = dlg_new_key.getchild(self.BTN_CONTINUE) |
593 | - except ldtp.LdtpExecutionError: |
594 | - raise ldtp.LdtpExecutionError, "The continue button at the new key dialog was not found." |
595 | - |
596 | - try: |
597 | - btn_continue.click() |
598 | - except ldtp.LdtpExecutionError: |
599 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the continue button." |
600 | + mnu_new_key = seahorse.getchild(self.MNU_NEWKEY) |
601 | + mnu_new_key.selectmenuitem() |
602 | + |
603 | + ldtp.waittillguiexist(self.NEWKEY_DLG) |
604 | + dlg_new_key = ooldtp.context(self.NEWKEY_DLG) |
605 | + |
606 | + table = dlg_new_key.getchild(role = 'table') |
607 | + types_table = table[0] |
608 | + |
609 | + for i in range(0, types_table.getrowcount(), 1): |
610 | + text = types_table.getcellvalue(i, 1) |
611 | + candidate = text.split('\n')[0] |
612 | + if candidate == key_type: |
613 | + types_table.selectrowindex(i) |
614 | + break |
615 | + ldtp.wait(1) |
616 | + |
617 | + btn_continue = dlg_new_key.getchild(self.BTN_CONTINUE) |
618 | + |
619 | + btn_continue.click() |
620 | |
621 | def new_pgp_key(self, full_name, email, comment, passphrase): |
622 | """ |
623 | @@ -130,78 +111,36 @@ |
624 | |
625 | self.new_key(self.TYPE_PGP) |
626 | |
627 | - try: |
628 | - ldtp.waittillguiexist(self.NEWPGP_DLG) |
629 | - dlg_new_pgp = ooldtp.context(self.NEWPGP_DLG) |
630 | - except ldtp.LdtpExecutionError: |
631 | - raise ldtp.LdtpExecutionError, "The new key dialog was not found." |
632 | - |
633 | - try: |
634 | - txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_FULLNAME) |
635 | - except ldtp.LdtpExecutionError: |
636 | - raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
637 | - try: |
638 | - txt_field.settextvalue(full_name) |
639 | - except ldtp.LdtpExecutionError: |
640 | - raise ldtp.LdtpExecutionError, "There was an error when writing the text." |
641 | - |
642 | - try: |
643 | - txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_EMAIL) |
644 | - except ldtp.LdtpExecutionError: |
645 | - raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
646 | - try: |
647 | - txt_field.settextvalue(email) |
648 | - except ldtp.LdtpExecutionError: |
649 | - raise ldtp.LdtpExecutionError, "There was a problem when writing the text." |
650 | + ldtp.waittillguiexist(self.NEWPGP_DLG) |
651 | + dlg_new_pgp = ooldtp.context(self.NEWPGP_DLG) |
652 | + |
653 | + txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_FULLNAME) |
654 | + txt_field.settextvalue(full_name) |
655 | + |
656 | + txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_EMAIL) |
657 | + txt_field.settextvalue(email) |
658 | |
659 | - try: |
660 | - txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_COMMENT) |
661 | - except ldtp.LdtpExecutionError: |
662 | - raise ldtp.LdtpExecutionError, "The " + txt_field + " text field was not found." |
663 | - try: |
664 | - txt_field.settextvalue(comment) |
665 | - except ldtp.LdtpExecutionError: |
666 | - raise ldtp.LdtpExecutionError, "There was a problem when writing the text." |
667 | - |
668 | - try: |
669 | - btn_create = dlg_new_pgp.getchild(self.BTN_NEWPGP_CREATE) |
670 | - except ldtp.LdtpExecutionError: |
671 | - raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found." |
672 | - |
673 | - try: |
674 | - btn_create.click() |
675 | - except ldtp.LdtpExecutionError: |
676 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button." |
677 | + txt_field = dlg_new_pgp.getchild(self.DLG_NEWPGP_COMMENT) |
678 | + txt_field.settextvalue(comment) |
679 | + |
680 | + btn_create = dlg_new_pgp.getchild(self.BTN_NEWPGP_CREATE) |
681 | + btn_create.click() |
682 | |
683 | - try: |
684 | - ldtp.waittillguiexist(self.DLG_NEWKEY_PASS) |
685 | - dlg_new_pgp_pass = ooldtp.context(self.DLG_NEWKEY_PASS) |
686 | - except ldtp.LdtpExecutionError: |
687 | - raise ldtp.LdtpExecutionError, "The new pgp key passphrase dialog was not found." |
688 | - |
689 | - try: |
690 | - ldtp.enterstring(passphrase) |
691 | - ldtp.enterstring("<tab>") |
692 | - ldtp.enterstring(passphrase) |
693 | - except ldtp.LdtpExecutionError: |
694 | - raise ldtp.LdtpExecutionError, "Error entering passphrase." |
695 | - |
696 | - try: |
697 | - btn_pass_ok = dlg_new_pgp_pass.getchild(self.BTN_PASS_OK) |
698 | - except ldtp.LdtpExecutionError: |
699 | - raise ldtp.LdtpExecutionError, "The OK button at the new PGP key passphrase dialog was not found." |
700 | - |
701 | - try: |
702 | - btn_pass_ok.click() |
703 | - except ldtp.LdtpExecutionError: |
704 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button." |
705 | - |
706 | - try: |
707 | - ldtp.waittillguiexist(self.DLG_GENERATING_KEY) |
708 | - while ldtp.guiexist(self.DLG_GENERATING_KEY) == 1: |
709 | - ldtp.wait(1) |
710 | - except ldtp.LdtpExecutionError: |
711 | - raise ldtp.LdtpExecutionError, "The new pgp generating key dialog was not found." |
712 | + ldtp.waittillguiexist(self.DLG_NEWKEY_PASS) |
713 | + dlg_new_pgp_pass = ooldtp.context(self.DLG_NEWKEY_PASS) |
714 | + |
715 | + # Entering the passphrase |
716 | + ldtp.enterstring(passphrase) |
717 | + ldtp.enterstring("<tab>") |
718 | + ldtp.enterstring(passphrase) |
719 | + |
720 | + btn_pass_ok = dlg_new_pgp_pass.getchild(self.BTN_PASS_OK) |
721 | + |
722 | + btn_pass_ok.click() |
723 | + |
724 | + ldtp.waittillguiexist(self.DLG_GENERATING_KEY) |
725 | + while ldtp.guiexist(self.DLG_GENERATING_KEY) == 1: |
726 | + ldtp.wait(1) |
727 | |
728 | # Add key name to generated key list, so we know to delete it later. |
729 | self.generated_keys.append(' '.join([full_name, email, "'"+comment+"'"])) |
730 | @@ -230,105 +169,49 @@ |
731 | |
732 | self.new_key(self.TYPE_SSH) |
733 | |
734 | - try: |
735 | - ldtp.waittillguiexist(self.NEWSSH_DLG) |
736 | - dlg_new_ssh = ooldtp.context(self.NEWSSH_DLG) |
737 | - except ldtp.LdtpExecutionError: |
738 | - raise ldtp.LdtpExecutionError, "The new key dialog was not found." |
739 | + ldtp.waittillguiexist(self.NEWSSH_DLG) |
740 | + dlg_new_ssh = ooldtp.context(self.NEWSSH_DLG) |
741 | |
742 | - try: |
743 | - txt_field = dlg_new_ssh.getchild(self.DLG_NEWSSH_DESC) |
744 | - except ldtp.LdtpExecutionError: |
745 | - raise ldtp.LdtpExecutionError, "The " + self.DLG_NEWSSH_DESC + " text field was not found." |
746 | - try: |
747 | - txt_field.settextvalue(description) |
748 | - except ldtp.LdtpExecutionError: |
749 | - raise ldtp.LdtpExecutionError, "There was an error when writing the text." |
750 | + txt_field = dlg_new_ssh.getchild(self.DLG_NEWSSH_DESC) |
751 | + txt_field.settextvalue(description) |
752 | |
753 | if set_up == True: |
754 | - try: |
755 | - btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE_AND_SETUP) |
756 | - except ldtp.LdtpExecutionError: |
757 | - raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found." |
758 | - |
759 | + btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE_AND_SETUP) |
760 | else: |
761 | - try: |
762 | - btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE) |
763 | - except ldtp.LdtpExecutionError: |
764 | - raise ldtp.LdtpExecutionError, "The create button at the new PGP key dialog was not found." |
765 | + btn_create = dlg_new_ssh.getchild(self.BTN_NEWSSH_CREATE) |
766 | |
767 | - try: |
768 | - btn_create.click() |
769 | - except ldtp.LdtpExecutionError: |
770 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the create button." |
771 | + btn_create.click() |
772 | |
773 | |
774 | - try: |
775 | - ldtp.waittillguiexist(self.DLG_NEWKEY_PASS) |
776 | - dlg_new_key_pass = ooldtp.context(self.DLG_NEWKEY_PASS) |
777 | - except ldtp.LdtpExecutionError: |
778 | - raise ldtp.LdtpExecutionError, "The new key passphrase dialog was not found." |
779 | + ldtp.waittillguiexist(self.DLG_NEWKEY_PASS) |
780 | + dlg_new_key_pass = ooldtp.context(self.DLG_NEWKEY_PASS) |
781 | |
782 | - try: |
783 | - ldtp.enterstring(passphrase) |
784 | - ldtp.enterstring("<tab>") |
785 | - ldtp.enterstring(passphrase) |
786 | - except ldtp.LdtpExecutionError: |
787 | - raise ldtp.LdtpExecutionError, "Error entering passphrase." |
788 | + # Entering the passphrase |
789 | + ldtp.enterstring(passphrase) |
790 | + ldtp.enterstring("<tab>") |
791 | + ldtp.enterstring(passphrase) |
792 | |
793 | - try: |
794 | - btn_pass_ok = dlg_new_key_pass.getchild(self.BTN_PASS_OK) |
795 | - except ldtp.LdtpExecutionError: |
796 | - raise ldtp.LdtpExecutionError, "The OK button at the new key passphrase dialog was not found." |
797 | - |
798 | - try: |
799 | - btn_pass_ok.click() |
800 | - except ldtp.LdtpExecutionError: |
801 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the OK button." |
802 | + btn_pass_ok = dlg_new_key_pass.getchild(self.BTN_PASS_OK) |
803 | + btn_pass_ok.click() |
804 | |
805 | if set_up == True and login is not None: |
806 | |
807 | - try: |
808 | - ldtp.waittillguiexist(self.DLG_SET_UP) |
809 | - dlg_set_up_computer = ooldtp.context(self.DLG_SET_UP) |
810 | - except ldtp.LdtpExecutionError: |
811 | - raise ldtp.LdtpExecutionError, "The set up computer dialog was not found." |
812 | + ldtp.waittillguiexist(self.DLG_SET_UP) |
813 | + dlg_set_up_computer = ooldtp.context(self.DLG_SET_UP) |
814 | |
815 | - try: |
816 | - txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_LOGIN) |
817 | - except ldtp.LdtpExecutionError: |
818 | - raise ldtp.LdtpExecutionError, "The " + self.TXT_SET_UP_LOGIN + " text field was not found." |
819 | - try: |
820 | - txt_field.settextvalue(login) |
821 | - except ldtp.LdtpExecutionError: |
822 | - raise ldtp.LdtpExecutionError, "There was an error when writing the text." |
823 | + txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_LOGIN) |
824 | + txt_field.settextvalue(login) |
825 | |
826 | if set_up == True: |
827 | - try: |
828 | - txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_COMPUTER) |
829 | - except ldtp.LdtpExecutionError: |
830 | - raise ldtp.LdtpExecutionError, "The " + self.TXT_SET_UP_COMPUTER + " text field was not found." |
831 | - try: |
832 | - txt_field.settextvalue(computer) |
833 | - except ldtp.LdtpExecutionError: |
834 | - raise ldtp.LdtpExecutionError, "There was an error when writing the text." |
835 | - |
836 | - try: |
837 | - btn_set_up = dlg_set_up_computer.getchild(self.BTN_SET_UP) |
838 | - except ldtp.LdtpExecutionError: |
839 | - raise ldtp.LdtpExecutionError, "The set up button was not found." |
840 | - |
841 | - try: |
842 | - btn_set_up.click() |
843 | - except ldtp.LdtpExecutionError: |
844 | - raise ldtp.LdtpExecutionError, "There was a problem when clicking the set up button." |
845 | - |
846 | - try: |
847 | - while ldtp.guiexist(self.DLG_CREATING_SSH) == 1: |
848 | - ldtp.wait(1) |
849 | - |
850 | - except ldtp.LdtpExecutionError: |
851 | - raise ldtp.LdtpExecutionError, "The creating key dialog was not found." |
852 | + txt_field = dlg_set_up_computer.getchild(self.TXT_SET_UP_COMPUTER) |
853 | + txt_field.settextvalue(computer) |
854 | + |
855 | + btn_set_up = dlg_set_up_computer.getchild(self.BTN_SET_UP) |
856 | + btn_set_up.click() |
857 | + |
858 | + while ldtp.guiexist(self.DLG_CREATING_SSH) == 1: |
859 | + ldtp.wait(1) |
860 | + |
861 | # Add key name to generated key list, so we know to delete it later. |
862 | self.generated_keys.append(description) |
863 | |
864 | |
865 | === modified file 'mago/application/ubuntu_menu.py' |
866 | --- mago/application/ubuntu_menu.py 2010-06-28 21:46:54 +0000 |
867 | +++ mago/application/ubuntu_menu.py 2010-10-20 10:26:00 +0000 |
868 | @@ -27,10 +27,7 @@ |
869 | |
870 | topPanel = ooldtp.context(self.__class__.TOP_PANEL) |
871 | |
872 | - try: |
873 | - actualMenu = topPanel.getchild(menu_item_txt) |
874 | - except ldtp.LdtpExecutionError: |
875 | - raise ldtp.LdtpExecutionError, "The " + menu_item_txt + " menu was not found. " |
876 | + actualMenu = topPanel.getchild(menu_item_txt) |
877 | |
878 | actualMenu.selectmenuitem() |
879 | |
880 | |
881 | === modified file 'mago/application/update_manager.py' |
882 | --- mago/application/update_manager.py 2010-07-22 10:43:18 +0000 |
883 | +++ mago/application/update_manager.py 2010-10-20 10:26:00 +0000 |
884 | @@ -29,18 +29,18 @@ |
885 | |
886 | i.e. C{updateManager = UpdateManager("my_password")} |
887 | """ |
888 | - MNU_ITEM = _("mnuUpdateManager" |
889 | - WINDOW = _("frmUpdateManager" |
890 | + MNU_ITEM = _("mnuUpdateManager") |
891 | + WINDOW = _("frmUpdateManager") |
892 | LAUNCHER = "update-manager" |
893 | - BTN_CLOSE = _("btnClose" |
894 | - BTN_CHECK = _("btnCheck" |
895 | - BTN_INSTALL = _("btnInstallUpdates" |
896 | - TBL_UPDATES = _("updates" |
897 | - BAN_LIST = _(" updates" |
898 | - TAB_CHANGES = _("Changes" |
899 | - TXT_DESCRIPTION = _("Description" |
900 | - LBL_WAIT = _("lblKeepyoursystemup-to-date" |
901 | - LBL_UPTODATE = _("lblYoursystemisup-to-date" |
902 | + BTN_CLOSE = _("btnClose") |
903 | + BTN_CHECK = _("btnCheck") |
904 | + BTN_INSTALL = _("btnInstallUpdates") |
905 | + TBL_UPDATES = _("updates") |
906 | + BAN_LIST = _(" updates") |
907 | + TAB_CHANGES = _("Changes") |
908 | + TXT_DESCRIPTION = _("Description") |
909 | + LBL_WAIT = _("lblKeepyoursystemup-to-date") |
910 | + LBL_UPTODATE = _("lblYoursystemisup-to-date") |
911 | LBL_N_UPDATES = r_('lblYoucaninstall(\d+)updates?') |
912 | LBL_DOWNLOADSIZE = r_(r'lblDownloadsize((\d+)((\.)(\d+))?)(.*)') |
913 | |
914 | @@ -96,20 +96,16 @@ |
915 | |
916 | populating = True |
917 | |
918 | - try: |
919 | - while populating: |
920 | - populating = False |
921 | - self.remap() |
922 | + while populating: |
923 | + populating = False |
924 | + self.remap() |
925 | |
926 | - label = updateManager.getchild(role = 'label') |
927 | - for i in label: |
928 | - label_name = i.getName() |
929 | - if label_name == self.LBL_WAIT: |
930 | - populating = True |
931 | + label = updateManager.getchild(role = 'label') |
932 | + for i in label: |
933 | + label_name = i.getName() |
934 | + if label_name == self.LBL_WAIT: |
935 | + populating = True |
936 | |
937 | - except ldtp.LdtpExecutionError: |
938 | - raise ldtp.LdtpExecutionError, "The Update Manager description label was not found." |
939 | - |
940 | def close(self): |
941 | """ |
942 | It closes the update-manager window using the close button. |
943 | @@ -117,12 +113,9 @@ |
944 | |
945 | updateManager = ooldtp.context(self.name) |
946 | |
947 | - try: |
948 | - closeButton = updateManager.getchild(self.BTN_CLOSE) |
949 | - except ldtp.LdtpExecutionError: |
950 | - raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found." |
951 | - |
952 | + closeButton = updateManager.getchild(self.BTN_CLOSE) |
953 | closeButton.click() |
954 | + |
955 | ldtp.waittillguinotexist (self.name) |
956 | |
957 | def number_updates(self): |
958 | @@ -135,21 +128,16 @@ |
959 | """ |
960 | updateManager = ooldtp.context(self.name) |
961 | |
962 | - try: |
963 | - label = updateManager.getchild(role = 'label') |
964 | - for i in label: |
965 | - label_name = i.getName() |
966 | - if label_name == self.LBL_UPTODATE: |
967 | - return 0 |
968 | - else: |
969 | - groups = re.match(self.LBL_N_UPDATES, label_name) |
970 | - if groups: |
971 | - number = groups.group(1) |
972 | - return int(number) |
973 | - |
974 | - except ldtp.LdtpExecutionError: |
975 | - raise ldtp.LdtpExecutionError, "Error getting number of updates" |
976 | - |
977 | + label = updateManager.getchild(role = 'label') |
978 | + for i in label: |
979 | + label_name = i.getName() |
980 | + if label_name == self.LBL_UPTODATE: |
981 | + return 0 |
982 | + else: |
983 | + groups = re.match(self.LBL_N_UPDATES, label_name) |
984 | + if groups: |
985 | + number = groups.group(1) |
986 | + return int(number) |
987 | return 0 |
988 | |
989 | def download_size(self): |
990 | @@ -160,31 +148,27 @@ |
991 | """ |
992 | updateManager = ooldtp.context(self.name) |
993 | |
994 | - try: |
995 | - label = updateManager.getchild(role = 'label') |
996 | - for i in label: |
997 | - label_name = i.getName() |
998 | - groups = re.match(self.LBL_DOWNLOADSIZE, label_name) |
999 | + label = updateManager.getchild(role = 'label') |
1000 | + for i in label: |
1001 | + label_name = i.getName() |
1002 | + groups = re.match(self.LBL_DOWNLOADSIZE, label_name) |
1003 | |
1004 | - if groups: |
1005 | - # Calculate size based on the tag after the number |
1006 | - tag_size = groups.group(6) |
1007 | - if tag_size == 'B': |
1008 | - size = 1 |
1009 | - elif tag_size == 'KB': |
1010 | - size = 1024 |
1011 | - elif tag_size == 'MB': |
1012 | - size = 1048576 |
1013 | - elif tag_size == 'GB': |
1014 | - size = 1073741824 |
1015 | - else: |
1016 | - size = 0 |
1017 | - |
1018 | - total_size = float(groups.group(1)) * size |
1019 | - return total_size |
1020 | - |
1021 | - except ldtp.LdtpExecutionError: |
1022 | - raise ldtp.LdtpExecutionError, "Error getting the download size." |
1023 | + if groups: |
1024 | + # Calculate size based on the tag after the number |
1025 | + tag_size = groups.group(6) |
1026 | + if tag_size == 'B': |
1027 | + size = 1 |
1028 | + elif tag_size == 'KB': |
1029 | + size = 1024 |
1030 | + elif tag_size == 'MB': |
1031 | + size = 1048576 |
1032 | + elif tag_size == 'GB': |
1033 | + size = 1073741824 |
1034 | + else: |
1035 | + size = 0 |
1036 | + |
1037 | + total_size = float(groups.group(1)) * size |
1038 | + return total_size |
1039 | |
1040 | return 0.0 |
1041 | |
1042 | @@ -194,15 +178,12 @@ |
1043 | """ |
1044 | updateManager = ooldtp.context(self.name) |
1045 | |
1046 | - try: |
1047 | - table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1048 | - updates_table = table[0] |
1049 | + table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1050 | + updates_table = table[0] |
1051 | |
1052 | - for i in range(0, updates_table.getrowcount(), 1): |
1053 | - updates_table.checkrow(i) |
1054 | - ldtp.wait(1) |
1055 | - except ldtp.LdtpExecutionError: |
1056 | - raise ldtp.LdtpExecutionError, "Error getting the updates table." |
1057 | + for i in range(0, updates_table.getrowcount(), 1): |
1058 | + updates_table.checkrow(i) |
1059 | + ldtp.wait(1) |
1060 | |
1061 | return 0 |
1062 | |
1063 | @@ -212,22 +193,18 @@ |
1064 | """ |
1065 | updateManager = ooldtp.context(self.name) |
1066 | |
1067 | - try: |
1068 | - table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1069 | - updates_table = table[0] |
1070 | + table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1071 | + updates_table = table[0] |
1072 | |
1073 | - # TODO: When table admits right click, use the context menu |
1074 | + # TODO: When table admits right click, use the context menu |
1075 | + self.remap() |
1076 | + size_updates = self.download_size() |
1077 | + while size_updates > 0: |
1078 | + for i in range(0, updates_table.getrowcount(), 1): |
1079 | + updates_table.uncheckrow(i) |
1080 | + ldtp.wait(1) |
1081 | self.remap() |
1082 | size_updates = self.download_size() |
1083 | - while size_updates > 0: |
1084 | - for i in range(0, updates_table.getrowcount(), 1): |
1085 | - updates_table.uncheckrow(i) |
1086 | - ldtp.wait(1) |
1087 | - self.remap() |
1088 | - size_updates = self.download_size() |
1089 | - |
1090 | - except ldtp.LdtpExecutionError: |
1091 | - raise ldtp.LdtpExecutionError, "Error getting the updates table." |
1092 | |
1093 | return 0 |
1094 | |
1095 | @@ -242,18 +219,15 @@ |
1096 | |
1097 | available_updates = [] |
1098 | |
1099 | - try: |
1100 | - table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1101 | - updates_table = table[0] |
1102 | + table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1103 | + updates_table = table[0] |
1104 | |
1105 | - for i in range(0, updates_table.getrowcount(), 1): |
1106 | - text = updates_table.getcellvalue(i, 1) |
1107 | - candidate = text.split('\n')[0] |
1108 | - if candidate.find(self.BAN_LIST) == -1: |
1109 | - available_updates.append(candidate) |
1110 | - ldtp.wait(1) |
1111 | - except ldtp.LdtpExecutionError: |
1112 | - raise ldtp.LdtpExecutionError, "Error getting the updates table." |
1113 | + for i in range(0, updates_table.getrowcount(), 1): |
1114 | + text = updates_table.getcellvalue(i, 1) |
1115 | + candidate = text.split('\n')[0] |
1116 | + if candidate.find(self.BAN_LIST) == -1: |
1117 | + available_updates.append(candidate) |
1118 | + ldtp.wait(1) |
1119 | |
1120 | return available_updates |
1121 | |
1122 | @@ -267,19 +241,16 @@ |
1123 | |
1124 | updateManager = ooldtp.context(self.name) |
1125 | |
1126 | - try: |
1127 | - table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1128 | - updates_table = table[0] |
1129 | + table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1130 | + updates_table = table[0] |
1131 | |
1132 | - for i in range(0, updates_table.getrowcount(), 1): |
1133 | - text = updates_table.getcellvalue(i, 1) |
1134 | - candidate = text.split('\n')[0] |
1135 | - if candidate == name: |
1136 | - updates_table.selectrowindex(i) |
1137 | - break |
1138 | - ldtp.wait(1) |
1139 | - except ldtp.LdtpExecutionError: |
1140 | - raise ldtp.LdtpExecutionError, "Error getting the updates table." |
1141 | + for i in range(0, updates_table.getrowcount(), 1): |
1142 | + text = updates_table.getcellvalue(i, 1) |
1143 | + candidate = text.split('\n')[0] |
1144 | + if candidate == name: |
1145 | + updates_table.selectrowindex(i) |
1146 | + break |
1147 | + ldtp.wait(1) |
1148 | |
1149 | def tick_update(self, name): |
1150 | """ |
1151 | @@ -291,19 +262,16 @@ |
1152 | |
1153 | updateManager = ooldtp.context(self.name) |
1154 | |
1155 | - try: |
1156 | - table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1157 | - updates_table = table[0] |
1158 | + table = updateManager.getchild(self.TBL_UPDATES, role = 'table') |
1159 | + updates_table = table[0] |
1160 | |
1161 | - for i in range(0, updates_table.getrowcount(), 1): |
1162 | - text = updates_table.getcellvalue(i, 1) |
1163 | - candidate = text.split('\n')[0] |
1164 | - if candidate == name: |
1165 | - updates_table.checkrow(i) |
1166 | - break |
1167 | - ldtp.wait(1) |
1168 | - except ldtp.LdtpExecutionError: |
1169 | - raise ldtp.LdtpExecutionError, "Error getting the updates table." |
1170 | + for i in range(0, updates_table.getrowcount(), 1): |
1171 | + text = updates_table.getcellvalue(i, 1) |
1172 | + candidate = text.split('\n')[0] |
1173 | + if candidate == name: |
1174 | + updates_table.checkrow(i) |
1175 | + break |
1176 | + ldtp.wait(1) |
1177 | |
1178 | def check_updates(self): |
1179 | """ |
1180 | @@ -313,10 +281,7 @@ |
1181 | raise an error if the UpdateManager instance was created without password. |
1182 | """ |
1183 | |
1184 | - try: |
1185 | - updateManager = ooldtp.context(self.name) |
1186 | - except ldtp.LdtpExecutionError: |
1187 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1188 | + updateManager = ooldtp.context(self.name) |
1189 | |
1190 | if self.password == "": |
1191 | raise ldtp.LdtpExecutionError, "Checking for updates requires administrative permissions." |
1192 | @@ -325,11 +290,7 @@ |
1193 | # We will need administrative permission |
1194 | polKit = PolicyKit(self.password) |
1195 | |
1196 | - try: |
1197 | - checkButton = updateManager.getchild(self.BTN_CHECK) |
1198 | - except ldtp.LdtpExecutionError: |
1199 | - raise ldtp.LdtpExecutionError, "The Update Manager Check button was not found." |
1200 | - |
1201 | + checkButton = updateManager.getchild(self.BTN_CHECK) |
1202 | checkButton.click() |
1203 | |
1204 | # Administrative permissions |
1205 | @@ -348,18 +309,11 @@ |
1206 | If no updates are available, it won't do anything. |
1207 | """ |
1208 | |
1209 | - try: |
1210 | - updateManager = ooldtp.context(self.name) |
1211 | - except ldtp.LdtpExecutionError: |
1212 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1213 | + updateManager = ooldtp.context(self.name) |
1214 | |
1215 | # If there is any update available, install it |
1216 | if self.number_updates() > 0: |
1217 | - |
1218 | - try: |
1219 | - btnInstall = updateManager.getchild(self.BTN_INSTALL) |
1220 | - except ldtp.LdtpExecutionError: |
1221 | - raise ldtp.LdtpExecutionError, "The Update Manager install button was not found." |
1222 | + btnInstall = updateManager.getchild(self.BTN_INSTALL) |
1223 | |
1224 | if btnInstall.stateenabled(): |
1225 | btnInstall.click() |
1226 | @@ -374,11 +328,7 @@ |
1227 | polKit.set_password() |
1228 | |
1229 | # Wait for the the close button to be ready |
1230 | - try: |
1231 | - btnClose = updateManager.getchild(self.BTN_CLOSE) |
1232 | - except ldtp.LdtpExecutionError: |
1233 | - raise ldtp.LdtpExecutionError, "The Update Manager Close button was not found." |
1234 | - |
1235 | + btnClose = updateManager.getchild(self.BTN_CLOSE) |
1236 | while not btnClose.stateenabled(): |
1237 | ldtp.wait(5) |
1238 | |
1239 | @@ -389,16 +339,10 @@ |
1240 | @return: True if the install button is enabled. False, otherwise. |
1241 | """ |
1242 | |
1243 | - try: |
1244 | - updateManager = ooldtp.context(self.name) |
1245 | - except ldtp.LdtpExecutionError: |
1246 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1247 | + updateManager = ooldtp.context(self.name) |
1248 | |
1249 | - try: |
1250 | - btnTest = updateManager.getchild(self.BTN_INSTALL) |
1251 | - state = btnTest.stateenabled() |
1252 | - except ldtp.LdtpExecutionError: |
1253 | - raise ldtp.LdtpExecutionError, "The install button was not found." |
1254 | + btnTest = updateManager.getchild(self.BTN_INSTALL) |
1255 | + state = btnTest.stateenabled() |
1256 | |
1257 | return state |
1258 | |
1259 | @@ -426,22 +370,16 @@ |
1260 | |
1261 | @return: The decription of the packages, as shown in the application |
1262 | """ |
1263 | - try: |
1264 | - updateManager = ooldtp.context(self.name) |
1265 | - except ldtp.LdtpExecutionError: |
1266 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1267 | + updateManager = ooldtp.context(self.name) |
1268 | |
1269 | - try: |
1270 | - if name != '': |
1271 | - self.select_update(name) |
1272 | + if name != '': |
1273 | + self.select_update(name) |
1274 | |
1275 | - # Get the description text field |
1276 | - text_field = updateManager.getchild(self.TXT_DESCRIPTION, role='text') |
1277 | - # Get the text |
1278 | - text = ldtp.gettextvalue(self.name, text_field[0].getName()) |
1279 | - return text |
1280 | - except ldtp.LdtpExecutionError: |
1281 | - raise ldtp.LdtpExecutionError, "The description text was not found." |
1282 | + # Get the description text field |
1283 | + text_field = updateManager.getchild(self.TXT_DESCRIPTION, role='text') |
1284 | + # Get the text |
1285 | + text = ldtp.gettextvalue(self.name, text_field[0].getName()) |
1286 | + return text |
1287 | |
1288 | return '' |
1289 | |
1290 | @@ -457,27 +395,21 @@ |
1291 | |
1292 | @return: The decription of the changes |
1293 | """ |
1294 | - try: |
1295 | - ooldtp.context(self.name) |
1296 | - except ldtp.LdtpExecutionError: |
1297 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1298 | + ooldtp.context(self.name) |
1299 | |
1300 | - try: |
1301 | - if name != '': |
1302 | - self.select_update(name) |
1303 | + if name != '': |
1304 | + self.select_update(name) |
1305 | |
1306 | - # Get the filler tab |
1307 | - filler = ldtp.getobjectproperty(self.name , self.TAB_CHANGES, 'children') |
1308 | - # Get the scroll pane |
1309 | - scroll_pane = ldtp.getobjectproperty(self.name , filler, 'children') |
1310 | - # Get the text field |
1311 | - text_field = ldtp.getobjectproperty(self.name , scroll_pane, 'children') |
1312 | - text_field = text_field.split(' ')[0] |
1313 | - # Get the text |
1314 | - text = ldtp.gettextvalue(self.name, text_field) |
1315 | - return text |
1316 | - except ldtp.LdtpExecutionError: |
1317 | - raise ldtp.LdtpExecutionError, "The Changes tab was not found." |
1318 | + # Get the filler tab |
1319 | + filler = ldtp.getobjectproperty(self.name , self.TAB_CHANGES, 'children') |
1320 | + # Get the scroll pane |
1321 | + scroll_pane = ldtp.getobjectproperty(self.name , filler, 'children') |
1322 | + # Get the text field |
1323 | + text_field = ldtp.getobjectproperty(self.name , scroll_pane, 'children') |
1324 | + text_field = text_field.split(' ')[0] |
1325 | + # Get the text |
1326 | + text = ldtp.gettextvalue(self.name, text_field) |
1327 | + return text |
1328 | |
1329 | return '' |
1330 | |
1331 | @@ -488,18 +420,12 @@ |
1332 | @type show: boolean |
1333 | @param show: True, to show the description; False, to hide the description. |
1334 | """ |
1335 | - try: |
1336 | - updateManager = ooldtp.context(self.name) |
1337 | - except ldtp.LdtpExecutionError: |
1338 | - raise ldtp.LdtpExecutionError, "The Update Manager window was not found." |
1339 | + updateManager = ooldtp.context(self.name) |
1340 | |
1341 | - try: |
1342 | - toggle_button = updateManager.getchild(role='toggle button') |
1343 | - state = toggle_button[0].verifytoggled() |
1344 | + toggle_button = updateManager.getchild(role='toggle button') |
1345 | + state = toggle_button[0].verifytoggled() |
1346 | |
1347 | - if state != show: |
1348 | - toggle_button[0].click() |
1349 | - except ldtp.LdtpExecutionError: |
1350 | - raise ldtp.LdtpExecutionError, "The description button was not found." |
1351 | + if state != show: |
1352 | + toggle_button[0].click() |
1353 | |
1354 | return state |
1355 | |
1356 | === modified file 'mago/test_suite/gedit.py' |
1357 | --- mago/test_suite/gedit.py 2010-06-28 18:58:01 +0000 |
1358 | +++ mago/test_suite/gedit.py 2010-10-20 10:26:00 +0000 |
1359 | @@ -18,15 +18,9 @@ |
1360 | |
1361 | def cleanup(self): |
1362 | # Exit using the Quit menu |
1363 | - try: |
1364 | - try: |
1365 | - gedit = ooldtp.context(self.application.name) |
1366 | - quit_menu = gedit.getchild(self.application.MNU_CLOSE) |
1367 | - except ldtp.LdtpExecutionError: |
1368 | - raise ldtp.LdtpExecutionError, "The quit menu was not found." |
1369 | - quit_menu.selectmenuitem() |
1370 | - except ldtp.LdtpExecutionError: |
1371 | - raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application." |
1372 | + gedit = ooldtp.context(self.application.name) |
1373 | + quit_menu = gedit.getchild(self.application.MNU_CLOSE) |
1374 | + quit_menu.selectmenuitem() |
1375 | |
1376 | result = ldtp.waittillguiexist(self.application.QUESTION_DLG, |
1377 | guiTimeOut = 2) |
1378 | @@ -36,11 +30,8 @@ |
1379 | question_dlg_btn_close = question_dialog.getchild(self.application.QUESTION_DLG_BTN_CLOSE) |
1380 | question_dlg_btn_close.click() |
1381 | |
1382 | - try: |
1383 | - gedit = ooldtp.context(self.application.name) |
1384 | - new_menu = gedit.getchild(self.application.MNU_NEW) |
1385 | - except ldtp.LdtpExecutionError: |
1386 | - raise ldtp.LdtpExecutionError, "The new menu was not found." |
1387 | + gedit = ooldtp.context(self.application.name) |
1388 | + new_menu = gedit.getchild(self.application.MNU_NEW) |
1389 | new_menu.selectmenuitem() |
1390 | |
1391 | result = ldtp.waittillguiexist( |
This is a neat change. I tried to make this one early on but for some reason got some resistance Do you think the LDTP exceptions are OK as is or could they stand to be improved to clearly identify the causes? On the other hand, having a backtrace gets you the exact line of the code that failed which is about as good as the rewritten exceptions did anyway...