diff options
author | Bogdan Marinescu <bogdan.a.marinescu@intel.com> | 2012-10-11 14:45:07 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-10-24 21:13:06 +0100 |
commit | 6cc2f06d43fed2b3cdec84cb21bbc45742b2608a (patch) | |
tree | b19c1cf266afeacaf570c279bb45d5ab467f38a3 /bitbake/lib/bb/ui/crumbs | |
parent | d93898b2c530681362e42d1b0477fa593a625046 (diff) | |
download | poky-6cc2f06d43fed2b3cdec84cb21bbc45742b2608a.tar.gz |
bitbake: event/hob: Add a button for network tests in the proxy settings
This patch allows the user to check the network connectivity in
the "Proxy" page ("Settings" dialog) by adding a button which provides
this functionality. It also disables retrigerring sanity checks if the
proxy values are changed, since now the proxy checks are explicit.
Note that this patch depends on a patch in oe-core
("sanity.bbclass: trigger network tests explicitly"). It will
not work properly if the patch in oe-core is not merged.
[YOCTO #3026]
(Bitbake rev: cb1354d29c0be27aee57b9783c724457ef6725fb)
Signed-off-by: Bogdan Marinescu <bogdan.a.marinescu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs')
-rwxr-xr-x | bitbake/lib/bb/ui/crumbs/builder.py | 47 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig.py | 258 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 23 |
3 files changed, 257 insertions, 71 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index 6ddc5b67fb..44e2aa51fb 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py | |||
@@ -51,10 +51,10 @@ class Configuration: | |||
51 | 51 | ||
52 | @classmethod | 52 | @classmethod |
53 | def parse_proxy_string(cls, proxy): | 53 | def parse_proxy_string(cls, proxy): |
54 | pattern = "^\s*((http|https|ftp|git|cvs)://)?((\S+):(\S+)@)?(\S+):(\d+)/?" | 54 | pattern = "^\s*((http|https|ftp|git|cvs)://)?((\S+):(\S+)@)?([^\s:]+)(:(\d+))?/?" |
55 | match = re.search(pattern, proxy) | 55 | match = re.search(pattern, proxy) |
56 | if match: | 56 | if match: |
57 | return match.group(2), match.group(4), match.group(5), match.group(6), match.group(7) | 57 | return match.group(2), match.group(4), match.group(5), match.group(6), match.group(8) |
58 | else: | 58 | else: |
59 | return None, None, None, "", "" | 59 | return None, None, None, "", "" |
60 | 60 | ||
@@ -82,10 +82,10 @@ class Configuration: | |||
82 | 82 | ||
83 | @classmethod | 83 | @classmethod |
84 | def make_proxy_string(cls, prot, user, passwd, host, port, default_prot=""): | 84 | def make_proxy_string(cls, prot, user, passwd, host, port, default_prot=""): |
85 | if host == None or host == "" or port == None or port == "": | 85 | if host == None or host == "":# or port == None or port == "": |
86 | return "" | 86 | return "" |
87 | 87 | ||
88 | return Configuration.make_host_string(prot, user, passwd, host, default_prot) + ":" + Configuration.make_port_string(port) | 88 | return Configuration.make_host_string(prot, user, passwd, host, default_prot) + (":" + Configuration.make_port_string(port) if port else "") |
89 | 89 | ||
90 | def __init__(self): | 90 | def __init__(self): |
91 | self.curr_mach = "" | 91 | self.curr_mach = "" |
@@ -746,6 +746,20 @@ class Builder(gtk.Window): | |||
746 | self.previous_step = self.current_step | 746 | self.previous_step = self.current_step |
747 | self.current_step = next_step | 747 | self.current_step = next_step |
748 | 748 | ||
749 | def set_user_config_proxies(self): | ||
750 | if self.configuration.enable_proxy == True: | ||
751 | self.handler.set_http_proxy(self.configuration.combine_proxy("http")) | ||
752 | self.handler.set_https_proxy(self.configuration.combine_proxy("https")) | ||
753 | self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) | ||
754 | self.handler.set_git_proxy(self.configuration.combine_host_only("git"), self.configuration.combine_port_only("git")) | ||
755 | self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) | ||
756 | elif self.configuration.enable_proxy == False: | ||
757 | self.handler.set_http_proxy("") | ||
758 | self.handler.set_https_proxy("") | ||
759 | self.handler.set_ftp_proxy("") | ||
760 | self.handler.set_git_proxy("", "") | ||
761 | self.handler.set_cvs_proxy("", "") | ||
762 | |||
749 | def set_user_config(self): | 763 | def set_user_config(self): |
750 | self.handler.init_cooker() | 764 | self.handler.init_cooker() |
751 | # set bb layers | 765 | # set bb layers |
@@ -767,19 +781,7 @@ class Builder(gtk.Window): | |||
767 | self.handler.set_extra_config(self.configuration.extra_setting) | 781 | self.handler.set_extra_config(self.configuration.extra_setting) |
768 | self.handler.set_extra_inherit("packageinfo") | 782 | self.handler.set_extra_inherit("packageinfo") |
769 | self.handler.set_extra_inherit("image_types") | 783 | self.handler.set_extra_inherit("image_types") |
770 | # set proxies | 784 | self.set_user_config_proxies() |
771 | if self.configuration.enable_proxy == True: | ||
772 | self.handler.set_http_proxy(self.configuration.combine_proxy("http")) | ||
773 | self.handler.set_https_proxy(self.configuration.combine_proxy("https")) | ||
774 | self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) | ||
775 | self.handler.set_git_proxy(self.configuration.combine_host_only("git"), self.configuration.combine_port_only("git")) | ||
776 | self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) | ||
777 | elif self.configuration.enable_proxy == False: | ||
778 | self.handler.set_http_proxy("") | ||
779 | self.handler.set_https_proxy("") | ||
780 | self.handler.set_ftp_proxy("") | ||
781 | self.handler.set_git_proxy("", "") | ||
782 | self.handler.set_cvs_proxy("", "") | ||
783 | 785 | ||
784 | def update_recipe_model(self, selected_image, selected_recipes): | 786 | def update_recipe_model(self, selected_image, selected_recipes): |
785 | self.recipe_model.set_selected_image(selected_image) | 787 | self.recipe_model.set_selected_image(selected_image) |
@@ -1310,7 +1312,8 @@ class Builder(gtk.Window): | |||
1310 | parent = self, | 1312 | parent = self, |
1311 | flags = gtk.DIALOG_MODAL | 1313 | flags = gtk.DIALOG_MODAL |
1312 | | gtk.DIALOG_DESTROY_WITH_PARENT | 1314 | | gtk.DIALOG_DESTROY_WITH_PARENT |
1313 | | gtk.DIALOG_NO_SEPARATOR) | 1315 | | gtk.DIALOG_NO_SEPARATOR, |
1316 | handler = self.handler) | ||
1314 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) | 1317 | button = dialog.add_button("Cancel", gtk.RESPONSE_NO) |
1315 | HobAltButton.style_button(button) | 1318 | HobAltButton.style_button(button) |
1316 | button = dialog.add_button("Save", gtk.RESPONSE_YES) | 1319 | button = dialog.add_button("Save", gtk.RESPONSE_YES) |
@@ -1323,6 +1326,14 @@ class Builder(gtk.Window): | |||
1323 | self.configuration = dialog.configuration | 1326 | self.configuration = dialog.configuration |
1324 | self.save_defaults() # remember settings | 1327 | self.save_defaults() # remember settings |
1325 | settings_changed = dialog.settings_changed | 1328 | settings_changed = dialog.settings_changed |
1329 | if dialog.proxy_settings_changed: | ||
1330 | self.set_user_config_proxies() | ||
1331 | elif dialog.proxy_test_ran: | ||
1332 | # The user might have modified the proxies in the "Proxy" | ||
1333 | # tab, which in turn made the proxy settings modify in bb. | ||
1334 | # If "Cancel" was pressed, restore the previous proxy | ||
1335 | # settings inside bb. | ||
1336 | self.set_user_config_proxies() | ||
1326 | dialog.destroy() | 1337 | dialog.destroy() |
1327 | return response == gtk.RESPONSE_YES, settings_changed | 1338 | return response == gtk.RESPONSE_YES, settings_changed |
1328 | 1339 | ||
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index ccd9f39a00..b3aea92fa8 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -319,9 +319,16 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
319 | PROXIES_PAGE_ID, | 319 | PROXIES_PAGE_ID, |
320 | OTHERS_PAGE_ID) = range(4) | 320 | OTHERS_PAGE_ID) = range(4) |
321 | 321 | ||
322 | (TEST_NETWORK_NONE, | ||
323 | TEST_NETWORK_INITIAL, | ||
324 | TEST_NETWORK_RUNNING, | ||
325 | TEST_NETWORK_PASSED, | ||
326 | TEST_NETWORK_FAILED, | ||
327 | TEST_NETWORK_CANCELED) = range(6) | ||
328 | |||
322 | def __init__(self, title, configuration, all_image_types, | 329 | def __init__(self, title, configuration, all_image_types, |
323 | all_package_formats, all_distros, all_sdk_machines, | 330 | all_package_formats, all_distros, all_sdk_machines, |
324 | max_threads, parent, flags, buttons=None): | 331 | max_threads, parent, flags, handler, buttons=None): |
325 | super(SimpleSettingsDialog, self).__init__(title, parent, flags, buttons) | 332 | super(SimpleSettingsDialog, self).__init__(title, parent, flags, buttons) |
326 | 333 | ||
327 | # class members from other objects | 334 | # class members from other objects |
@@ -348,7 +355,11 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
348 | self.image_types_checkbuttons = {} | 355 | self.image_types_checkbuttons = {} |
349 | 356 | ||
350 | self.md5 = self.config_md5() | 357 | self.md5 = self.config_md5() |
358 | self.proxy_md5 = self.config_proxy_md5() | ||
351 | self.settings_changed = False | 359 | self.settings_changed = False |
360 | self.proxy_settings_changed = False | ||
361 | self.handler = handler | ||
362 | self.proxy_test_ran = False | ||
352 | 363 | ||
353 | # create visual elements on the dialog | 364 | # create visual elements on the dialog |
354 | self.create_visual_elements() | 365 | self.create_visual_elements() |
@@ -357,12 +368,15 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
357 | def _get_sorted_value(self, var): | 368 | def _get_sorted_value(self, var): |
358 | return " ".join(sorted(str(var).split())) + "\n" | 369 | return " ".join(sorted(str(var).split())) + "\n" |
359 | 370 | ||
360 | def config_md5(self): | 371 | def config_proxy_md5(self): |
361 | data = "" | 372 | data = ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) |
362 | data += ("ENABLE_PROXY: " + self._get_sorted_value(self.configuration.enable_proxy)) | ||
363 | if self.configuration.enable_proxy: | 373 | if self.configuration.enable_proxy: |
364 | for protocol in self.configuration.proxies.keys(): | 374 | for protocol in self.configuration.proxies.keys(): |
365 | data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) | 375 | data += (protocol + ": " + self._get_sorted_value(self.configuration.combine_proxy(protocol))) |
376 | return hashlib.md5(data).hexdigest() | ||
377 | |||
378 | def config_md5(self): | ||
379 | data = "" | ||
366 | for key in self.configuration.extra_setting.keys(): | 380 | for key in self.configuration.extra_setting.keys(): |
367 | data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) | 381 | data += (key + ": " + self._get_sorted_value(self.configuration.extra_setting[key])) |
368 | return hashlib.md5(data).hexdigest() | 382 | return hashlib.md5(data).hexdigest() |
@@ -383,28 +397,25 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
383 | self.refresh_proxy_components() | 397 | self.refresh_proxy_components() |
384 | dialog.destroy() | 398 | dialog.destroy() |
385 | 399 | ||
386 | def gen_proxy_entry_widget(self, protocol, parent, need_button=True): | 400 | def gen_proxy_entry_widget(self, protocol, parent, need_button=True, line=0): |
387 | hbox = gtk.HBox(False, 12) | ||
388 | |||
389 | label = gtk.Label(protocol.upper() + " proxy") | 401 | label = gtk.Label(protocol.upper() + " proxy") |
390 | hbox.pack_start(label, expand=True, fill=False, padding=24) | 402 | self.proxy_table.attach(label, 0, 1, line, line+1, xpadding=24) |
391 | 403 | ||
392 | proxy_entry = gtk.Entry() | 404 | proxy_entry = gtk.Entry() |
393 | proxy_entry.set_size_request(300, -1) | 405 | proxy_entry.set_size_request(300, -1) |
394 | hbox.pack_start(proxy_entry, expand=False, fill=False) | 406 | self.proxy_table.attach(proxy_entry, 1, 2, line, line+1, ypadding=4) |
395 | 407 | ||
396 | hbox.pack_start(gtk.Label(":"), expand=False, fill=False) | 408 | self.proxy_table.attach(gtk.Label(":"), 2, 3, line, line+1, xpadding=12, ypadding=4) |
397 | 409 | ||
398 | port_entry = gtk.Entry() | 410 | port_entry = gtk.Entry() |
399 | port_entry.set_size_request(60, -1) | 411 | port_entry.set_size_request(60, -1) |
400 | hbox.pack_start(port_entry, expand=False, fill=False) | 412 | self.proxy_table.attach(port_entry, 3, 4, line, line+1, ypadding=4) |
401 | 413 | ||
402 | details_button = HobAltButton("Details") | 414 | details_button = HobAltButton("Details") |
403 | details_button.connect("clicked", self.details_cb, parent, protocol) | 415 | details_button.connect("clicked", self.details_cb, parent, protocol) |
404 | hbox.pack_start(details_button, expand=False, fill=False) | 416 | self.proxy_table.attach(details_button, 4, 5, line, line+1, xpadding=4, yoptions=gtk.EXPAND) |
405 | 417 | ||
406 | hbox.show_all() | 418 | return proxy_entry, port_entry, details_button |
407 | return hbox, proxy_entry, port_entry, details_button | ||
408 | 419 | ||
409 | def refresh_proxy_components(self): | 420 | def refresh_proxy_components(self): |
410 | self.same_checkbox.set_sensitive(self.configuration.enable_proxy) | 421 | self.same_checkbox.set_sensitive(self.configuration.enable_proxy) |
@@ -449,18 +460,53 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
449 | self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | 460 | self.cvs_proxy_port.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) |
450 | self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) | 461 | self.cvs_proxy_details.set_sensitive(self.configuration.enable_proxy and (not self.configuration.same_proxy)) |
451 | 462 | ||
463 | if self.configuration.same_proxy: | ||
464 | if self.http_proxy.get_text(): | ||
465 | [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] | ||
466 | if self.http_proxy_port.get_text(): | ||
467 | [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] | ||
468 | |||
452 | def proxy_checkbox_toggled_cb(self, button): | 469 | def proxy_checkbox_toggled_cb(self, button): |
453 | self.configuration.enable_proxy = self.proxy_checkbox.get_active() | 470 | self.configuration.enable_proxy = self.proxy_checkbox.get_active() |
454 | if not self.configuration.enable_proxy: | 471 | if not self.configuration.enable_proxy: |
455 | self.configuration.same_proxy = False | 472 | self.configuration.same_proxy = False |
456 | self.same_checkbox.set_active(self.configuration.same_proxy) | 473 | self.same_checkbox.set_active(self.configuration.same_proxy) |
474 | self.save_proxy_data() | ||
457 | self.refresh_proxy_components() | 475 | self.refresh_proxy_components() |
458 | 476 | ||
459 | def same_checkbox_toggled_cb(self, button): | 477 | def same_checkbox_toggled_cb(self, button): |
460 | self.configuration.same_proxy = self.same_checkbox.get_active() | 478 | self.configuration.same_proxy = self.same_checkbox.get_active() |
479 | self.save_proxy_data() | ||
461 | self.refresh_proxy_components() | 480 | self.refresh_proxy_components() |
462 | 481 | ||
463 | def response_cb(self, dialog, response_id): | 482 | def save_proxy_data(self): |
483 | self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
484 | if self.configuration.same_proxy: | ||
485 | self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
486 | self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
487 | self.configuration.split_proxy("git", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
488 | self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
489 | else: | ||
490 | self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) | ||
491 | self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) | ||
492 | self.configuration.split_proxy("git", self.git_proxy.get_text() + ":" + self.git_proxy_port.get_text()) | ||
493 | self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) | ||
494 | |||
495 | def response_cb(self, dialog, response_id): | ||
496 | if response_id == gtk.RESPONSE_YES: | ||
497 | # Check that all proxy entries have a corresponding port | ||
498 | for proxy, port in zip(self.all_proxy_addresses, self.all_proxy_ports): | ||
499 | if proxy.get_text() and not port.get_text(): | ||
500 | lbl = "<b>Enter all port numbers</b>\n\n" | ||
501 | msg = "Proxy servers require a port number. Please make sure you have entered a port number for each proxy server." | ||
502 | dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_WARNING, msg) | ||
503 | button = dialog.add_button("Close", gtk.RESPONSE_OK) | ||
504 | HobButton.style_button(button) | ||
505 | response = dialog.run() | ||
506 | dialog.destroy() | ||
507 | self.emit_stop_by_name("response") | ||
508 | return | ||
509 | |||
464 | self.configuration.dldir = self.dldir_text.get_text() | 510 | self.configuration.dldir = self.dldir_text.get_text() |
465 | self.configuration.sstatedir = self.sstatedir_text.get_text() | 511 | self.configuration.sstatedir = self.sstatedir_text.get_text() |
466 | self.configuration.sstatemirror = "" | 512 | self.configuration.sstatemirror = "" |
@@ -473,19 +519,7 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
473 | self.configuration.sstatemirror += smirror | 519 | self.configuration.sstatemirror += smirror |
474 | self.configuration.bbthread = self.bb_spinner.get_value_as_int() | 520 | self.configuration.bbthread = self.bb_spinner.get_value_as_int() |
475 | self.configuration.pmake = self.pmake_spinner.get_value_as_int() | 521 | self.configuration.pmake = self.pmake_spinner.get_value_as_int() |
476 | 522 | self.save_proxy_data() | |
477 | self.configuration.split_proxy("http", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
478 | if self.configuration.same_proxy: | ||
479 | self.configuration.split_proxy("https", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
480 | self.configuration.split_proxy("ftp", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
481 | self.configuration.split_proxy("git", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
482 | self.configuration.split_proxy("cvs", self.http_proxy.get_text() + ":" + self.http_proxy_port.get_text()) | ||
483 | else: | ||
484 | self.configuration.split_proxy("https", self.https_proxy.get_text() + ":" + self.https_proxy_port.get_text()) | ||
485 | self.configuration.split_proxy("ftp", self.ftp_proxy.get_text() + ":" + self.ftp_proxy_port.get_text()) | ||
486 | self.configuration.split_proxy("git", self.git_proxy.get_text() + ":" + self.git_proxy_port.get_text()) | ||
487 | self.configuration.split_proxy("cvs", self.cvs_proxy.get_text() + ":" + self.cvs_proxy_port.get_text()) | ||
488 | |||
489 | self.configuration.extra_setting = {} | 523 | self.configuration.extra_setting = {} |
490 | it = self.setting_store.get_iter_first() | 524 | it = self.setting_store.get_iter_first() |
491 | while it: | 525 | while it: |
@@ -496,6 +530,7 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
496 | 530 | ||
497 | md5 = self.config_md5() | 531 | md5 = self.config_md5() |
498 | self.settings_changed = (self.md5 != md5) | 532 | self.settings_changed = (self.md5 != md5) |
533 | self.proxy_settings_changed = (self.proxy_md5 != self.config_proxy_md5()) | ||
499 | 534 | ||
500 | def create_build_environment_page(self): | 535 | def create_build_environment_page(self): |
501 | advanced_vbox = gtk.VBox(False, 6) | 536 | advanced_vbox = gtk.VBox(False, 6) |
@@ -608,10 +643,91 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
608 | self.show_all() | 643 | self.show_all() |
609 | self.nb.set_current_page(page_num) | 644 | self.nb.set_current_page(page_num) |
610 | 645 | ||
646 | def test_proxy_ended(self, passed): | ||
647 | self.proxy_test_running = False | ||
648 | self.set_test_proxy_state(self.TEST_NETWORK_PASSED if passed else self.TEST_NETWORK_FAILED) | ||
649 | self.set_sensitive(True) | ||
650 | self.refresh_proxy_components() | ||
611 | 651 | ||
612 | def create_proxy_page(self): | 652 | def timer_func(self): |
653 | self.test_proxy_progress.pulse() | ||
654 | return self.proxy_test_running | ||
655 | |||
656 | def test_network_button_cb(self, b): | ||
657 | self.set_test_proxy_state(self.TEST_NETWORK_RUNNING) | ||
658 | self.set_sensitive(False) | ||
659 | self.save_proxy_data() | ||
660 | if self.configuration.enable_proxy == True: | ||
661 | self.handler.set_http_proxy(self.configuration.combine_proxy("http")) | ||
662 | self.handler.set_https_proxy(self.configuration.combine_proxy("https")) | ||
663 | self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) | ||
664 | self.handler.set_git_proxy(self.configuration.combine_host_only("git"), self.configuration.combine_port_only("git")) | ||
665 | self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) | ||
666 | elif self.configuration.enable_proxy == False: | ||
667 | self.handler.set_http_proxy("") | ||
668 | self.handler.set_https_proxy("") | ||
669 | self.handler.set_ftp_proxy("") | ||
670 | self.handler.set_git_proxy("", "") | ||
671 | self.handler.set_cvs_proxy("", "") | ||
672 | self.proxy_test_ran = True | ||
673 | self.proxy_test_running = True | ||
674 | gobject.timeout_add(100, self.timer_func) | ||
675 | self.handler.trigger_network_test() | ||
676 | |||
677 | def test_proxy_focus_event(self, w, direction): | ||
678 | if self.test_proxy_state in [self.TEST_NETWORK_PASSED, self.TEST_NETWORK_FAILED]: | ||
679 | self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) | ||
680 | return False | ||
681 | |||
682 | def http_proxy_changed(self, e): | ||
683 | if not self.configuration.same_proxy: | ||
684 | return | ||
685 | if e == self.http_proxy: | ||
686 | [w.set_text(self.http_proxy.get_text()) for w in self.same_proxy_addresses] | ||
687 | else: | ||
688 | [w.set_text(self.http_proxy_port.get_text()) for w in self.same_proxy_ports] | ||
689 | |||
690 | def proxy_address_focus_out_event(self, w, direction): | ||
691 | text = w.get_text() | ||
692 | if not text: | ||
693 | return False | ||
694 | if text.find("//") == -1: | ||
695 | w.set_text("http://" + text) | ||
696 | return False | ||
697 | |||
698 | def set_test_proxy_state(self, state): | ||
699 | if self.test_proxy_state == state: | ||
700 | return | ||
701 | [self.proxy_table.remove(w) for w in self.test_gui_elements] | ||
702 | if state == self.TEST_NETWORK_INITIAL: | ||
703 | self.proxy_table.attach(self.test_network_button, 1, 2, 5, 6) | ||
704 | self.test_network_button.show() | ||
705 | elif state == self.TEST_NETWORK_RUNNING: | ||
706 | self.test_proxy_progress.set_rcstyle("running") | ||
707 | self.test_proxy_progress.set_text("Testing network configuration") | ||
708 | self.proxy_table.attach(self.test_proxy_progress, 0, 5, 5, 6, xpadding=4) | ||
709 | self.test_proxy_progress.show() | ||
710 | else: # passed or failed | ||
711 | self.dummy_progress.update(1.0) | ||
712 | if state == self.TEST_NETWORK_PASSED: | ||
713 | self.dummy_progress.set_text("Your network is properly configured") | ||
714 | self.dummy_progress.set_rcstyle("running") | ||
715 | else: | ||
716 | self.dummy_progress.set_text("Network test failed") | ||
717 | self.dummy_progress.set_rcstyle("fail") | ||
718 | self.proxy_table.attach(self.dummy_progress, 0, 4, 5, 6) | ||
719 | self.proxy_table.attach(self.retest_network_button, 4, 5, 5, 6, xpadding=4) | ||
720 | self.dummy_progress.show() | ||
721 | self.retest_network_button.show() | ||
722 | self.test_proxy_state = state | ||
723 | |||
724 | def create_network_page(self): | ||
613 | advanced_vbox = gtk.VBox(False, 6) | 725 | advanced_vbox = gtk.VBox(False, 6) |
614 | advanced_vbox.set_border_width(6) | 726 | advanced_vbox.set_border_width(6) |
727 | self.same_proxy_addresses = [] | ||
728 | self.same_proxy_ports = [] | ||
729 | self.all_proxy_ports = [] | ||
730 | self.all_proxy_addresses = [] | ||
615 | 731 | ||
616 | sub_vbox = gtk.VBox(False, 6) | 732 | sub_vbox = gtk.VBox(False, 6) |
617 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | 733 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) |
@@ -623,42 +739,77 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
623 | hbox.pack_start(info, expand=False, fill=False) | 739 | hbox.pack_start(info, expand=False, fill=False) |
624 | sub_vbox.pack_start(hbox, expand=False, fill=False) | 740 | sub_vbox.pack_start(hbox, expand=False, fill=False) |
625 | 741 | ||
626 | self.direct_checkbox = gtk.RadioButton(None, "Direct internet connection") | 742 | proxy_test_focus = [] |
743 | self.direct_checkbox = gtk.RadioButton(None, "Direct network connection") | ||
744 | proxy_test_focus.append(self.direct_checkbox) | ||
627 | self.direct_checkbox.set_tooltip_text("Check this box to use a direct internet connection with no proxy") | 745 | self.direct_checkbox.set_tooltip_text("Check this box to use a direct internet connection with no proxy") |
628 | self.direct_checkbox.set_active(not self.configuration.enable_proxy) | 746 | self.direct_checkbox.set_active(not self.configuration.enable_proxy) |
629 | sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) | 747 | sub_vbox.pack_start(self.direct_checkbox, expand=False, fill=False) |
630 | 748 | ||
631 | self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") | 749 | self.proxy_checkbox = gtk.RadioButton(self.direct_checkbox, "Manual proxy configuration") |
750 | proxy_test_focus.append(self.proxy_checkbox) | ||
632 | self.proxy_checkbox.set_tooltip_text("Check this box to manually set up a specific proxy") | 751 | self.proxy_checkbox.set_tooltip_text("Check this box to manually set up a specific proxy") |
633 | self.proxy_checkbox.set_active(self.configuration.enable_proxy) | 752 | self.proxy_checkbox.set_active(self.configuration.enable_proxy) |
634 | sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) | 753 | sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) |
635 | 754 | ||
636 | self.same_checkbox = gtk.CheckButton("Use the same proxy for all protocols") | 755 | self.same_checkbox = gtk.CheckButton("Use the HTTP proxy for all protocols") |
756 | proxy_test_focus.append(self.same_checkbox) | ||
637 | self.same_checkbox.set_tooltip_text("Check this box to use the HTTP proxy for all five proxies") | 757 | self.same_checkbox.set_tooltip_text("Check this box to use the HTTP proxy for all five proxies") |
638 | self.same_checkbox.set_active(self.configuration.same_proxy) | 758 | self.same_checkbox.set_active(self.configuration.same_proxy) |
639 | hbox = gtk.HBox(False, 12) | 759 | hbox = gtk.HBox(False, 12) |
640 | hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) | 760 | hbox.pack_start(self.same_checkbox, expand=False, fill=False, padding=24) |
641 | sub_vbox.pack_start(hbox, expand=False, fill=False) | 761 | sub_vbox.pack_start(hbox, expand=False, fill=False) |
642 | 762 | ||
643 | proxy_widget, self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( | 763 | self.proxy_table = gtk.Table(6, 5, False) |
644 | "http", self, True) | 764 | self.http_proxy, self.http_proxy_port, self.http_proxy_details = self.gen_proxy_entry_widget( |
645 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 765 | "http", self, True, 0) |
646 | 766 | proxy_test_focus +=[self.http_proxy, self.http_proxy_port] | |
647 | proxy_widget, self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( | 767 | self.http_proxy.connect("changed", self.http_proxy_changed) |
648 | "https", self, True) | 768 | self.http_proxy_port.connect("changed", self.http_proxy_changed) |
649 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 769 | |
650 | 770 | self.https_proxy, self.https_proxy_port, self.https_proxy_details = self.gen_proxy_entry_widget( | |
651 | proxy_widget, self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( | 771 | "https", self, True, 1) |
652 | "ftp", self, True) | 772 | proxy_test_focus += [self.https_proxy, self.https_proxy_port] |
653 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 773 | self.same_proxy_addresses.append(self.https_proxy) |
654 | 774 | self.same_proxy_ports.append(self.https_proxy_port) | |
655 | proxy_widget, self.git_proxy, self.git_proxy_port, self.git_proxy_details = self.gen_proxy_entry_widget( | 775 | |
656 | "git", self, True) | 776 | self.ftp_proxy, self.ftp_proxy_port, self.ftp_proxy_details = self.gen_proxy_entry_widget( |
657 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 777 | "ftp", self, True, 2) |
658 | 778 | proxy_test_focus += [self.ftp_proxy, self.ftp_proxy_port] | |
659 | proxy_widget, self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( | 779 | self.same_proxy_addresses.append(self.ftp_proxy) |
660 | "cvs", self, True) | 780 | self.same_proxy_ports.append(self.ftp_proxy_port) |
661 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | 781 | |
782 | self.git_proxy, self.git_proxy_port, self.git_proxy_details = self.gen_proxy_entry_widget( | ||
783 | "git", self, True, 3) | ||
784 | proxy_test_focus += [self.git_proxy, self.git_proxy_port] | ||
785 | self.same_proxy_addresses.append(self.git_proxy) | ||
786 | self.same_proxy_ports.append(self.git_proxy_port) | ||
787 | |||
788 | self.cvs_proxy, self.cvs_proxy_port, self.cvs_proxy_details = self.gen_proxy_entry_widget( | ||
789 | "cvs", self, True, 4) | ||
790 | proxy_test_focus += [self.cvs_proxy, self.cvs_proxy_port] | ||
791 | self.same_proxy_addresses.append(self.cvs_proxy) | ||
792 | self.same_proxy_ports.append(self.cvs_proxy_port) | ||
793 | self.all_proxy_ports = self.same_proxy_ports + [self.http_proxy_port] | ||
794 | self.all_proxy_addresses = self.same_proxy_addresses + [self.http_proxy] | ||
795 | sub_vbox.pack_start(self.proxy_table, expand=False, fill=False) | ||
796 | self.proxy_table.show_all() | ||
797 | |||
798 | # Create the graphical elements for the network test feature, but don't display them yet | ||
799 | self.test_network_button = HobAltButton("Test network configuration") | ||
800 | self.test_network_button.connect("clicked", self.test_network_button_cb) | ||
801 | self.test_proxy_progress = HobProgressBar() | ||
802 | self.dummy_progress = HobProgressBar() | ||
803 | self.retest_network_button = HobAltButton("Retest") | ||
804 | self.retest_network_button.connect("clicked", self.test_network_button_cb) | ||
805 | self.test_gui_elements = [self.test_network_button, self.test_proxy_progress, self.dummy_progress, self.retest_network_button] | ||
806 | # Initialize the network tester | ||
807 | self.test_proxy_state = self.TEST_NETWORK_NONE | ||
808 | self.set_test_proxy_state(self.TEST_NETWORK_INITIAL) | ||
809 | self.proxy_test_passed_id = self.handler.connect("network-passed", lambda h:self.test_proxy_ended(True)) | ||
810 | self.proxy_test_failed_id = self.handler.connect("network-failed", lambda h:self.test_proxy_ended(False)) | ||
811 | [w.connect("focus-in-event", self.test_proxy_focus_event) for w in proxy_test_focus] | ||
812 | [w.connect("focus-out-event", self.proxy_address_focus_out_event) for w in self.all_proxy_addresses] | ||
662 | 813 | ||
663 | self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | 814 | self.direct_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) |
664 | self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | 815 | self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) |
@@ -840,7 +991,7 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
840 | self.nb.set_show_tabs(True) | 991 | self.nb.set_show_tabs(True) |
841 | self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) | 992 | self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) |
842 | self.nb.append_page(self.create_shared_state_page(), gtk.Label("Shared state")) | 993 | self.nb.append_page(self.create_shared_state_page(), gtk.Label("Shared state")) |
843 | self.nb.append_page(self.create_proxy_page(), gtk.Label("Proxies")) | 994 | self.nb.append_page(self.create_network_page(), gtk.Label("Network")) |
844 | self.nb.append_page(self.create_others_page(), gtk.Label("Others")) | 995 | self.nb.append_page(self.create_others_page(), gtk.Label("Others")) |
845 | self.nb.set_current_page(0) | 996 | self.nb.set_current_page(0) |
846 | self.vbox.pack_start(self.nb, expand=True, fill=True) | 997 | self.vbox.pack_start(self.nb, expand=True, fill=True) |
@@ -848,6 +999,11 @@ class SimpleSettingsDialog (CrumbsDialog, SettingsUIHelper): | |||
848 | 999 | ||
849 | self.show_all() | 1000 | self.show_all() |
850 | 1001 | ||
1002 | def destroy(self): | ||
1003 | self.handler.disconnect(self.proxy_test_passed_id) | ||
1004 | self.handler.disconnect(self.proxy_test_failed_id) | ||
1005 | super(SimpleSettingsDialog, self).destroy() | ||
1006 | |||
851 | 1007 | ||
852 | # | 1008 | # |
853 | # AdvancedSettings Dialog | 1009 | # AdvancedSettings Dialog |
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 5d038f45ca..7d3af6c725 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py | |||
@@ -65,10 +65,17 @@ class HobHandler(gobject.GObject): | |||
65 | "package-populated" : (gobject.SIGNAL_RUN_LAST, | 65 | "package-populated" : (gobject.SIGNAL_RUN_LAST, |
66 | gobject.TYPE_NONE, | 66 | gobject.TYPE_NONE, |
67 | ()), | 67 | ()), |
68 | "network-passed" : (gobject.SIGNAL_RUN_LAST, | ||
69 | gobject.TYPE_NONE, | ||
70 | ()), | ||
71 | "network-failed" : (gobject.SIGNAL_RUN_LAST, | ||
72 | gobject.TYPE_NONE, | ||
73 | ()), | ||
68 | } | 74 | } |
69 | 75 | ||
70 | (GENERATE_CONFIGURATION, GENERATE_RECIPES, GENERATE_PACKAGES, GENERATE_IMAGE, POPULATE_PACKAGEINFO, SANITY_CHECK) = range(6) | 76 | (GENERATE_CONFIGURATION, GENERATE_RECIPES, GENERATE_PACKAGES, GENERATE_IMAGE, POPULATE_PACKAGEINFO, SANITY_CHECK, NETWORK_TEST) = range(7) |
71 | (SUB_PATH_LAYERS, SUB_FILES_DISTRO, SUB_FILES_MACH, SUB_FILES_SDKMACH, SUB_MATCH_CLASS, SUB_PARSE_CONFIG, SUB_SANITY_CHECK, SUB_GNERATE_TGTS, SUB_GENERATE_PKGINFO, SUB_BUILD_RECIPES, SUB_BUILD_IMAGE) = range(11) | 77 | (SUB_PATH_LAYERS, SUB_FILES_DISTRO, SUB_FILES_MACH, SUB_FILES_SDKMACH, SUB_MATCH_CLASS, SUB_PARSE_CONFIG, SUB_SANITY_CHECK, |
78 | SUB_GNERATE_TGTS, SUB_GENERATE_PKGINFO, SUB_BUILD_RECIPES, SUB_BUILD_IMAGE, SUB_NETWORK_TEST) = range(12) | ||
72 | 79 | ||
73 | def __init__(self, server, recipe_model, package_model): | 80 | def __init__(self, server, recipe_model, package_model): |
74 | super(HobHandler, self).__init__() | 81 | super(HobHandler, self).__init__() |
@@ -146,6 +153,8 @@ class HobHandler(gobject.GObject): | |||
146 | self.runCommand(["triggerEvent", "bb.event.RequestPackageInfo()"]) | 153 | self.runCommand(["triggerEvent", "bb.event.RequestPackageInfo()"]) |
147 | elif next_command == self.SUB_SANITY_CHECK: | 154 | elif next_command == self.SUB_SANITY_CHECK: |
148 | self.runCommand(["triggerEvent", "bb.event.SanityCheck()"]) | 155 | self.runCommand(["triggerEvent", "bb.event.SanityCheck()"]) |
156 | elif next_command == self.SUB_NETWORK_TEST: | ||
157 | self.runCommand(["triggerEvent", "bb.event.NetworkTest()"]) | ||
149 | elif next_command == self.SUB_BUILD_RECIPES: | 158 | elif next_command == self.SUB_BUILD_RECIPES: |
150 | self.clear_busy() | 159 | self.clear_busy() |
151 | self.building = True | 160 | self.building = True |
@@ -254,6 +263,12 @@ class HobHandler(gobject.GObject): | |||
254 | message["total"] = event.total | 263 | message["total"] = event.total |
255 | message["title"] = "Parsing recipes: " | 264 | message["title"] = "Parsing recipes: " |
256 | self.emit("parsing-completed", message) | 265 | self.emit("parsing-completed", message) |
266 | elif isinstance(event, bb.event.NetworkTestFailed): | ||
267 | self.emit("network-failed") | ||
268 | self.run_next_command() | ||
269 | elif isinstance(event, bb.event.NetworkTestPassed): | ||
270 | self.emit("network-passed") | ||
271 | self.run_next_command() | ||
257 | 272 | ||
258 | if self.error_msg and not self.commands_async: | 273 | if self.error_msg and not self.commands_async: |
259 | self.display_error() | 274 | self.display_error() |
@@ -348,6 +363,10 @@ class HobHandler(gobject.GObject): | |||
348 | self.commands_async.append(self.SUB_SANITY_CHECK) | 363 | self.commands_async.append(self.SUB_SANITY_CHECK) |
349 | self.run_next_command(self.SANITY_CHECK) | 364 | self.run_next_command(self.SANITY_CHECK) |
350 | 365 | ||
366 | def trigger_network_test(self): | ||
367 | self.commands_async.append(self.SUB_NETWORK_TEST) | ||
368 | self.run_next_command(self.NETWORK_TEST) | ||
369 | |||
351 | def generate_configuration(self): | 370 | def generate_configuration(self): |
352 | self.commands_async.append(self.SUB_PARSE_CONFIG) | 371 | self.commands_async.append(self.SUB_PARSE_CONFIG) |
353 | self.commands_async.append(self.SUB_PATH_LAYERS) | 372 | self.commands_async.append(self.SUB_PATH_LAYERS) |