| Submitter | Shane Wang |
|---|---|
| Date | Feb. 29, 2012, 2:15 p.m. |
| Message ID | <0e99d291a8d3e9ad49ba82d5c30591322e958511.1330523904.git.shane.wang@intel.com> |
| Download | mbox | patch |
| Permalink | /patch/22479/ |
| State | New |
| Headers | show |
Comments
On 29/02/12 06:15, Shane Wang wrote: > This patch is to set os.environ to allow users to set the environment variables for http_proxy, https_proxy and ftp_proxy. I think this needs more work, I have a text entry with an attached button that spawns a file chooser. What file would I choose here? What about if my http, ftp and socks proxy are different? Cheers, Joshua > Signed-off-by: Shane Wang<shane.wang@intel.com> > --- > bitbake/lib/bb/ui/crumbs/builder.py | 23 +++++++++++++++++++++++ > bitbake/lib/bb/ui/crumbs/hig.py | 26 +++++++++++++++++++++++++- > 2 files changed, 48 insertions(+), 1 deletions(-) > > diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py > index 0d7f1c1..e9853f2 100755 > --- a/bitbake/lib/bb/ui/crumbs/builder.py > +++ b/bitbake/lib/bb/ui/crumbs/builder.py > @@ -116,6 +116,7 @@ class Configuration: > > class Parameters: > '''Represents other variables like available machines, etc.''' > + __dummy_proxy__ = "myproxy.example.com:8010" > > def __init__(self, params): > # Variables > @@ -129,6 +130,8 @@ class Parameters: > self.image_names = [] > self.image_addr = params["image_addr"] > self.image_types = params["image_types"].split() > + self.proxy = self.__dummy_proxy__ > + self.enable_proxy = False > > class Builder(gtk.Window): > > @@ -727,6 +730,19 @@ class Builder(gtk.Window): > > dialog.destroy() > > + def _setup_proxy(self): > + if self.parameters.proxy == Parameters.__dummy_proxy__ or self.parameters.proxy.lstrip() == "": > + if "http_proxy" in os.environ.keys(): > + del os.environ["http_proxy"] > + if "https_proxy" in os.environ.keys(): > + del os.environ["https_proxy"] > + if "ftp_proxy" in os.environ.keys(): > + del os.environ["ftp_proxy"] > + else: > + os.environ["http_proxy"] = self.parameters.proxy > + os.environ["https_proxy"] = self.parameters.proxy > + os.environ["ftp_proxy"] = self.parameters.proxy > + > def show_adv_settings_dialog(self): > dialog = AdvancedSettingDialog(title = "Settings", > configuration = copy.deepcopy(self.configuration), > @@ -735,6 +751,8 @@ class Builder(gtk.Window): > all_distros = self.parameters.all_distros, > all_sdk_machines = self.parameters.all_sdk_machines, > max_threads = self.parameters.max_threads, > + proxy = self.parameters.proxy, > + enable_proxy = self.parameters.enable_proxy, > split_model = self.get_split_model(), > parent = self, > flags = gtk.DIALOG_MODAL > @@ -745,6 +763,11 @@ class Builder(gtk.Window): > response = dialog.run() > if response == gtk.RESPONSE_YES: > self.configuration = dialog.configuration > + # setup the proxy > + self.parameters.enable_proxy = dialog.enable_proxy > + if self.parameters.enable_proxy == True: > + self.parameters.proxy = dialog.proxy > + self._setup_proxy() > # DO reparse recipes > if dialog.settings_changed: > if self.configuration.curr_mach == "": > diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py > index 20585b7..7e1c1ff 100644 > --- a/bitbake/lib/bb/ui/crumbs/hig.py > +++ b/bitbake/lib/bb/ui/crumbs/hig.py > @@ -428,7 +428,7 @@ class AdvancedSettingDialog (CrumbsDialog): > > def __init__(self, title, configuration, all_image_types, > all_package_formats, all_distros, all_sdk_machines, > - max_threads, split_model, parent, flags, buttons): > + max_threads, proxy, enable_proxy, split_model, parent, flags, buttons): > super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) > > # class members from other objects > @@ -439,6 +439,8 @@ class AdvancedSettingDialog (CrumbsDialog): > self.all_distros = all_distros > self.all_sdk_machines = all_sdk_machines > self.max_threads = max_threads > + self.enable_proxy = enable_proxy > + self.proxy = proxy > self.split_model = split_model > > # class members for internal use > @@ -614,6 +616,21 @@ class AdvancedSettingDialog (CrumbsDialog): > sub_vbox.pack_start(label, expand=False, fill=False) > sub_vbox.pack_start(sstatemirror_widget, expand=False, fill=False) > > + sub_vbox = gtk.VBox(False, 6) > + advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) > + self.proxy_checkbox = gtk.CheckButton("Enable Proxy") > + self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") > + self.proxy_checkbox.set_active(self.enable_proxy) > + self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) > + label = self.gen_label_widget("<span weight=\"bold\">Select Proxy:</span>") > + tooltip = "Select the proxy that will be used in do_fetch() source code" > + proxy_widget, self.proxy_text = self.gen_entry_widget(self.split_model, self.proxy, self, tooltip) > + self.proxy_text.set_editable(self.enable_proxy) > + self.proxy_text.set_sensitive(self.enable_proxy) > + sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) > + sub_vbox.pack_start(label, expand=False, fill=False) > + sub_vbox.pack_start(proxy_widget, expand=False, fill=False) > + > return advanced_vbox > > def create_others_page(self): > @@ -630,6 +647,11 @@ class AdvancedSettingDialog (CrumbsDialog): > > return advanced_vbox > > + def proxy_checkbox_toggled_cb(self, button): > + self.enable_proxy = self.proxy_checkbox.get_active() > + self.proxy_text.set_editable(self.enable_proxy) > + self.proxy_text.set_sensitive(self.enable_proxy) > + > def response_cb(self, dialog, response_id): > self.variables = {} > > @@ -679,6 +701,8 @@ class AdvancedSettingDialog (CrumbsDialog): > self.variables[key] = value > it = self.setting_store.iter_next(it) > > + self.proxy = self.proxy_text.get_text() > + > md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() > self.settings_changed = (self.md5 != md5) >
Joshua Lock wrote onĀ 2012-03-01: > On 29/02/12 06:15, Shane Wang wrote: >> This patch is to set os.environ to allow users to set the environment > variables for http_proxy, https_proxy and ftp_proxy. > > I think this needs more work, I have a text entry with an attached > button that spawns a file chooser. What file would I choose here? Josh, I don't understand why this is related to a file chooser. > > What about if my http, ftp and socks proxy are different? Yes, the patch doesn't work for this case. I admit the proxy patch needs more work. Again, this patch doesn't support git, either. The initial requirement is from Saul and from build appliance for users behind a firewall to use proxy. For what you mentioned to set up different proxies, it is easy to fix. But for git, I also need to investigate, do you have more hints? -- Shane > > Cheers, > Joshua >
On 02/03/12 05:29, Wang, Shane wrote: > Joshua Lock wrote on 2012-03-01: > >> On 29/02/12 06:15, Shane Wang wrote: >>> This patch is to set os.environ to allow users to set the environment >> variables for http_proxy, https_proxy and ftp_proxy. >> >> I think this needs more work, I have a text entry with an attached >> button that spawns a file chooser. What file would I choose here? > Josh, I don't understand why this is related to a file chooser. That's pretty much what I'm asking you. When I run the Hob from your shane/hob2-v0.68 branch I get the attached Settings->Build Environment dialogue. Next to the entry for the proxy information there's a file chooser - I don't understand what it's for? From looking at the code I'm assuming it's not supposed to be there and is a by-product of the way you've called gen_entry_widget() Cheers, Joshua
Patch
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py index 0d7f1c1..e9853f2 100755 --- a/bitbake/lib/bb/ui/crumbs/builder.py +++ b/bitbake/lib/bb/ui/crumbs/builder.py @@ -116,6 +116,7 @@ class Configuration: class Parameters: '''Represents other variables like available machines, etc.''' + __dummy_proxy__ = "myproxy.example.com:8010" def __init__(self, params): # Variables @@ -129,6 +130,8 @@ class Parameters: self.image_names = [] self.image_addr = params["image_addr"] self.image_types = params["image_types"].split() + self.proxy = self.__dummy_proxy__ + self.enable_proxy = False class Builder(gtk.Window): @@ -727,6 +730,19 @@ class Builder(gtk.Window): dialog.destroy() + def _setup_proxy(self): + if self.parameters.proxy == Parameters.__dummy_proxy__ or self.parameters.proxy.lstrip() == "": + if "http_proxy" in os.environ.keys(): + del os.environ["http_proxy"] + if "https_proxy" in os.environ.keys(): + del os.environ["https_proxy"] + if "ftp_proxy" in os.environ.keys(): + del os.environ["ftp_proxy"] + else: + os.environ["http_proxy"] = self.parameters.proxy + os.environ["https_proxy"] = self.parameters.proxy + os.environ["ftp_proxy"] = self.parameters.proxy + def show_adv_settings_dialog(self): dialog = AdvancedSettingDialog(title = "Settings", configuration = copy.deepcopy(self.configuration), @@ -735,6 +751,8 @@ class Builder(gtk.Window): all_distros = self.parameters.all_distros, all_sdk_machines = self.parameters.all_sdk_machines, max_threads = self.parameters.max_threads, + proxy = self.parameters.proxy, + enable_proxy = self.parameters.enable_proxy, split_model = self.get_split_model(), parent = self, flags = gtk.DIALOG_MODAL @@ -745,6 +763,11 @@ class Builder(gtk.Window): response = dialog.run() if response == gtk.RESPONSE_YES: self.configuration = dialog.configuration + # setup the proxy + self.parameters.enable_proxy = dialog.enable_proxy + if self.parameters.enable_proxy == True: + self.parameters.proxy = dialog.proxy + self._setup_proxy() # DO reparse recipes if dialog.settings_changed: if self.configuration.curr_mach == "": diff --git a/bitbake/lib/bb/ui/crumbs/hig.py b/bitbake/lib/bb/ui/crumbs/hig.py index 20585b7..7e1c1ff 100644 --- a/bitbake/lib/bb/ui/crumbs/hig.py +++ b/bitbake/lib/bb/ui/crumbs/hig.py @@ -428,7 +428,7 @@ class AdvancedSettingDialog (CrumbsDialog): def __init__(self, title, configuration, all_image_types, all_package_formats, all_distros, all_sdk_machines, - max_threads, split_model, parent, flags, buttons): + max_threads, proxy, enable_proxy, split_model, parent, flags, buttons): super(AdvancedSettingDialog, self).__init__(title, parent, flags, buttons) # class members from other objects @@ -439,6 +439,8 @@ class AdvancedSettingDialog (CrumbsDialog): self.all_distros = all_distros self.all_sdk_machines = all_sdk_machines self.max_threads = max_threads + self.enable_proxy = enable_proxy + self.proxy = proxy self.split_model = split_model # class members for internal use @@ -614,6 +616,21 @@ class AdvancedSettingDialog (CrumbsDialog): sub_vbox.pack_start(label, expand=False, fill=False) sub_vbox.pack_start(sstatemirror_widget, expand=False, fill=False) + sub_vbox = gtk.VBox(False, 6) + advanced_vbox.pack_start(sub_vbox, expand=False, fill=False) + self.proxy_checkbox = gtk.CheckButton("Enable Proxy") + self.proxy_checkbox.set_tooltip_text("Check this box to setup the proxy you specified") + self.proxy_checkbox.set_active(self.enable_proxy) + self.proxy_checkbox.connect("toggled", self.proxy_checkbox_toggled_cb) + label = self.gen_label_widget("<span weight=\"bold\">Select Proxy:</span>") + tooltip = "Select the proxy that will be used in do_fetch() source code" + proxy_widget, self.proxy_text = self.gen_entry_widget(self.split_model, self.proxy, self, tooltip) + self.proxy_text.set_editable(self.enable_proxy) + self.proxy_text.set_sensitive(self.enable_proxy) + sub_vbox.pack_start(self.proxy_checkbox, expand=False, fill=False) + sub_vbox.pack_start(label, expand=False, fill=False) + sub_vbox.pack_start(proxy_widget, expand=False, fill=False) + return advanced_vbox def create_others_page(self): @@ -630,6 +647,11 @@ class AdvancedSettingDialog (CrumbsDialog): return advanced_vbox + def proxy_checkbox_toggled_cb(self, button): + self.enable_proxy = self.proxy_checkbox.get_active() + self.proxy_text.set_editable(self.enable_proxy) + self.proxy_text.set_sensitive(self.enable_proxy) + def response_cb(self, dialog, response_id): self.variables = {} @@ -679,6 +701,8 @@ class AdvancedSettingDialog (CrumbsDialog): self.variables[key] = value it = self.setting_store.iter_next(it) + self.proxy = self.proxy_text.get_text() + md5 = hashlib.md5(str(sorted(self.variables.items()))).hexdigest() self.settings_changed = (self.md5 != md5)
This patch is to set os.environ to allow users to set the environment variables for http_proxy, https_proxy and ftp_proxy. Signed-off-by: Shane Wang <shane.wang@intel.com> --- bitbake/lib/bb/ui/crumbs/builder.py | 23 +++++++++++++++++++++++ bitbake/lib/bb/ui/crumbs/hig.py | 26 +++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletions(-)