diff options
author | Shane Wang <shane.wang@intel.com> | 2012-03-22 14:20:03 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-28 16:49:19 +0100 |
commit | 8b0bc593b32c49c71ca683b9bdcdca5018862eda (patch) | |
tree | db7927091a86c0eaa024e4e8c19811c0a3f6dce8 /bitbake/lib/bb/ui/crumbs/hig.py | |
parent | 7990d36f508a8eab4865b124045c02326680430d (diff) | |
download | poky-8b0bc593b32c49c71ca683b9bdcdca5018862eda.tar.gz |
Hob: allow users to setup the proxies
This patch is to read the proxy variables such as all_proxy, http_proxy, https_proxy, ftp_proxy, GIT_PROXY_HOST, GIT_PROXY_PORT, CVS_PROXY_HOST, and CVS_PROXY_PORT from the bitbake server, show them on the Settings dialog for users to change and set proxies for the build.
(From Poky rev: bbef66e4005def54d70d3720ec131fa7edc22e2a)
(Bitbake rev: 66c63167cd139706100bfa35eb4ca66c98407615)
Signed-off-by: Shane Wang <shane.wang@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hig.py')
-rw-r--r-- | bitbake/lib/bb/ui/crumbs/hig.py | 111 |
1 files changed, 100 insertions, 11 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 772f78eac5..4753c92d2a 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py | |||
@@ -147,20 +147,23 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
147 | 147 | ||
148 | dialog.destroy() | 148 | dialog.destroy() |
149 | 149 | ||
150 | def gen_entry_widget(self, content, parent, tooltip=""): | 150 | def gen_entry_widget(self, content, parent, tooltip="", need_button=True): |
151 | hbox = gtk.HBox(False, 12) | 151 | hbox = gtk.HBox(False, 12) |
152 | entry = gtk.Entry() | 152 | entry = gtk.Entry() |
153 | entry.set_text(content) | 153 | entry.set_text(content) |
154 | 154 | ||
155 | table = gtk.Table(1, 10, True) | 155 | if need_button: |
156 | hbox.pack_start(table, expand=True, fill=True) | 156 | table = gtk.Table(1, 10, True) |
157 | table.attach(entry, 0, 9, 0, 1) | 157 | hbox.pack_start(table, expand=True, fill=True) |
158 | image = gtk.Image() | 158 | table.attach(entry, 0, 9, 0, 1) |
159 | image.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON) | 159 | image = gtk.Image() |
160 | open_button = gtk.Button() | 160 | image.set_from_stock(gtk.STOCK_OPEN,gtk.ICON_SIZE_BUTTON) |
161 | open_button.set_image(image) | 161 | open_button = gtk.Button() |
162 | open_button.connect("clicked", self.entry_widget_select_path_cb, parent, entry) | 162 | open_button.set_image(image) |
163 | table.attach(open_button, 9, 10, 0, 1) | 163 | open_button.connect("clicked", self.entry_widget_select_path_cb, parent, entry) |
164 | table.attach(open_button, 9, 10, 0, 1) | ||
165 | else: | ||
166 | hbox.pack_start(entry, expand=True, fill=True) | ||
164 | 167 | ||
165 | info = HobInfoButton(tooltip, self) | 168 | info = HobInfoButton(tooltip, self) |
166 | hbox.pack_start(info, expand=False, fill=False) | 169 | hbox.pack_start(info, expand=False, fill=False) |
@@ -307,7 +310,7 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
307 | 310 | ||
308 | def __init__(self, title, configuration, all_image_types, | 311 | def __init__(self, title, configuration, all_image_types, |
309 | all_package_formats, all_distros, all_sdk_machines, | 312 | all_package_formats, all_distros, all_sdk_machines, |
310 | max_threads, parent, flags, buttons=None): | 313 | max_threads, enable_proxy, parent, flags, buttons=None): |
311 | super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) | 314 | super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) |
312 | 315 | ||
313 | # class members from other objects | 316 | # class members from other objects |
@@ -318,6 +321,7 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
318 | self.all_distros = all_distros | 321 | self.all_distros = all_distros |
319 | self.all_sdk_machines = all_sdk_machines | 322 | self.all_sdk_machines = all_sdk_machines |
320 | self.max_threads = max_threads | 323 | self.max_threads = max_threads |
324 | self.enable_proxy = enable_proxy | ||
321 | 325 | ||
322 | # class members for internal use | 326 | # class members for internal use |
323 | self.distro_combo = None | 327 | self.distro_combo = None |
@@ -352,6 +356,7 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
352 | self.nb.append_page(self.create_image_types_page(), gtk.Label("Image types")) | 356 | self.nb.append_page(self.create_image_types_page(), gtk.Label("Image types")) |
353 | self.nb.append_page(self.create_output_page(), gtk.Label("Output")) | 357 | self.nb.append_page(self.create_output_page(), gtk.Label("Output")) |
354 | self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) | 358 | self.nb.append_page(self.create_build_environment_page(), gtk.Label("Build environment")) |
359 | self.nb.append_page(self.create_proxy_page(), gtk.Label("Proxies")) | ||
355 | self.nb.append_page(self.create_others_page(), gtk.Label("Others")) | 360 | self.nb.append_page(self.create_others_page(), gtk.Label("Others")) |
356 | self.nb.set_current_page(0) | 361 | self.nb.set_current_page(0) |
357 | self.vbox.pack_start(self.nb, expand=True, fill=True) | 362 | self.vbox.pack_start(self.nb, expand=True, fill=True) |
@@ -492,6 +497,68 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
492 | 497 | ||
493 | return advanced_vbox | 498 | return advanced_vbox |
494 | 499 | ||
500 | def create_proxy_page(self): | ||
501 | advanced_vbox = gtk.VBox(False, 6) | ||
502 | advanced_vbox.set_border_width(6) | ||
503 | |||
504 | sub_vbox = gtk.VBox(False, 6) | ||
505 | advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) | ||
506 | self.proxy_checkbox = gtk.CheckButton("Enable Proxy") | ||
507 | self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") | ||
508 | self.proxy_checkbox.set_active(self.enable_proxy) | ||
509 | self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) | ||
510 | sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) | ||
511 | |||
512 | label = self.gen_label_widget("<span weight=\"bold\">Set all proxy:</span>") | ||
513 | tooltip = "Set the all proxy that will be used if the proxy for a URL isn't specified." | ||
514 | proxy_widget, self.all_proxy_text = self.gen_entry_widget(self.configuration.all_proxy, self, tooltip, False) | ||
515 | self.all_proxy_text.set_editable(self.enable_proxy) | ||
516 | self.all_proxy_text.set_sensitive(self.enable_proxy) | ||
517 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
518 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
519 | |||
520 | label = self.gen_label_widget("<span weight=\"bold\">Set http proxy:</span>") | ||
521 | tooltip = "Set the http proxy that will be used in do_fetch() source code" | ||
522 | proxy_widget, self.http_proxy_text = self.gen_entry_widget(self.configuration.http_proxy, self, tooltip, False) | ||
523 | self.http_proxy_text.set_editable(self.enable_proxy) | ||
524 | self.http_proxy_text.set_sensitive(self.enable_proxy) | ||
525 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
526 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
527 | |||
528 | label = self.gen_label_widget("<span weight=\"bold\">Set https proxy:</span>") | ||
529 | tooltip = "Set the https proxy that will be used in do_fetch() source code" | ||
530 | proxy_widget, self.https_proxy_text = self.gen_entry_widget(self.configuration.https_proxy, self, tooltip, False) | ||
531 | self.https_proxy_text.set_editable(self.enable_proxy) | ||
532 | self.https_proxy_text.set_sensitive(self.enable_proxy) | ||
533 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
534 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
535 | |||
536 | label = self.gen_label_widget("<span weight=\"bold\">Set ftp proxy:</span>") | ||
537 | tooltip = "Set the ftp proxy that will be used in do_fetch() source code" | ||
538 | proxy_widget, self.ftp_proxy_text = self.gen_entry_widget(self.configuration.ftp_proxy, self, tooltip, False) | ||
539 | self.ftp_proxy_text.set_editable(self.enable_proxy) | ||
540 | self.ftp_proxy_text.set_sensitive(self.enable_proxy) | ||
541 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
542 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
543 | |||
544 | label = self.gen_label_widget("<span weight=\"bold\">Set git proxy:</span>") | ||
545 | tooltip = "Set the git proxy that will be used in do_fetch() source code" | ||
546 | proxy_widget, self.git_proxy_text = self.gen_entry_widget(self.configuration.git_proxy_host + ':' + self.configuration.git_proxy_port, self, tooltip, False) | ||
547 | self.git_proxy_text.set_editable(self.enable_proxy) | ||
548 | self.git_proxy_text.set_sensitive(self.enable_proxy) | ||
549 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
550 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
551 | |||
552 | label = self.gen_label_widget("<span weight=\"bold\">Set cvs proxy:</span>") | ||
553 | tooltip = "Set the cvs proxy that will be used in do_fetch() source code" | ||
554 | proxy_widget, self.cvs_proxy_text = self.gen_entry_widget(self.configuration.cvs_proxy_host + ':' + self.configuration.cvs_proxy_port, self, tooltip, False) | ||
555 | self.cvs_proxy_text.set_editable(self.enable_proxy) | ||
556 | self.cvs_proxy_text.set_sensitive(self.enable_proxy) | ||
557 | sub_vbox.pack_start(label, expand=False, fill=False) | ||
558 | sub_vbox.pack_start(proxy_widget, expand=False, fill=False) | ||
559 | |||
560 | return advanced_vbox | ||
561 | |||
495 | def create_others_page(self): | 562 | def create_others_page(self): |
496 | advanced_vbox = gtk.VBox(False, 6) | 563 | advanced_vbox = gtk.VBox(False, 6) |
497 | advanced_vbox.set_border_width(6) | 564 | advanced_vbox.set_border_width(6) |
@@ -506,6 +573,21 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
506 | 573 | ||
507 | return advanced_vbox | 574 | return advanced_vbox |
508 | 575 | ||
576 | def proxy_checkbox_toggled_cb(self, button): | ||
577 | self.enable_proxy = self.proxy_checkbox.get_active() | ||
578 | self.all_proxy_text.set_editable(self.enable_proxy) | ||
579 | self.all_proxy_text.set_sensitive(self.enable_proxy) | ||
580 | self.http_proxy_text.set_editable(self.enable_proxy) | ||
581 | self.http_proxy_text.set_sensitive(self.enable_proxy) | ||
582 | self.https_proxy_text.set_editable(self.enable_proxy) | ||
583 | self.https_proxy_text.set_sensitive(self.enable_proxy) | ||
584 | self.ftp_proxy_text.set_editable(self.enable_proxy) | ||
585 | self.ftp_proxy_text.set_sensitive(self.enable_proxy) | ||
586 | self.git_proxy_text.set_editable(self.enable_proxy) | ||
587 | self.git_proxy_text.set_sensitive(self.enable_proxy) | ||
588 | self.cvs_proxy_text.set_editable(self.enable_proxy) | ||
589 | self.cvs_proxy_text.set_sensitive(self.enable_proxy) | ||
590 | |||
509 | def response_cb(self, dialog, response_id): | 591 | def response_cb(self, dialog, response_id): |
510 | self.variables = {} | 592 | self.variables = {} |
511 | 593 | ||
@@ -553,6 +635,13 @@ class AdvancedSettingDialog (CrumbsDialog): | |||
553 | self.variables[key] = value | 635 | self.variables[key] = value |
554 | it = self.setting_store.iter_next(it) | 636 | it = self.setting_store.iter_next(it) |
555 | 637 | ||
638 | self.configuration.all_proxy = self.all_proxy_text.get_text() | ||
639 | self.configuration.http_proxy = self.http_proxy_text.get_text() | ||
640 | self.configuration.https_proxy = self.https_proxy_text.get_text() | ||
641 | self.configuration.ftp_proxy = self.ftp_proxy_text.get_text() | ||
642 | self.configuration.git_proxy_host, self.configuration.git_proxy_port = self.git_proxy_text.get_text().split(':') | ||
643 | self.configuration.cvs_proxy_host, self.configuration.cvs_proxy_port = self.cvs_proxy_text.get_text().split(':') | ||
644 | |||
556 | md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() | 645 | md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() |
557 | self.settings_changed = (self.md5 != md5) | 646 | self.settings_changed = (self.md5 != md5) |
558 | 647 | ||