Reimplment proxy settings for Hob
cover Reimplment proxy settings for Hob
This patch is to reimplement the proxy tab in the advanced settings dialog according to the new design by the design team to make it more like Gnome style. Please review and check in. Thanks.
The following changes since commit 2219caa312822cf756b88b07dd70a014404e9cb0:
tune-mips64.inc: Add new tune file for mips64 big-endian (2012-05-21 09:59:04 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib shane/newproxy
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=shane/newproxy
Shane Wang (1):
Hob: reimplement the proxy page
bitbake/lib/bb/ui/crumbs/builder.py | 143 +++++++++++---- bitbake/lib/bb/ui/crumbs/hig.py | 273 ++++++++++++++++++++------- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 4 - 3 files changed, 309 insertions(+), 111 deletions(-)
Signature · 1 line
1.7.6
PATCH 1/1 Hob: reimplement the proxy page
This patch is to reimplement the proxy page in the "Advanced Settings" dialog per the new design in https://bugzilla.yoctoproject.org/attachment.cgi?id=442
and https://bugzilla.yoctoproject.org/attachment.cgi?id=443.
[Yocto #2247]
--- bitbake/lib/bb/ui/crumbs/builder.py | 143 +++++++++++---- bitbake/lib/bb/ui/crumbs/hig.py | 273 ++++++++++++++++++++------- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 4 - 3 files changed, 309 insertions(+), 111 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +106 -37
@@ -26,6 +26,7 @@ import copy import os import subprocess import shlex +import re from bb.ui.crumbs.template import TemplateMgr from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage
@@ -42,6 +43,44 @@ import bb.ui.crumbs.utils class Configuration: '''Represents the data structure of configuration.''' + @classmethod + def parse_proxy_string(cls, proxy): + pattern = "^\s*((http|https|ftp|git|cvs)://)?((\S+):(\S+)@)?(\S+):(\d+)/?" + match = re.search(pattern, proxy) + if match: + return match.group(2), match.group(4), match.group(5), match.group(6), match.group(7) + else: + return None, None, None, "", "" + + @classmethod + def make_host_string(cls, prot, user, passwd, host, default_prot=""): + if host == None or host == "": + return "" + + passwd = passwd or "" + + if user != None and user != "": + if prot == None or prot == "": + prot = default_prot + return prot + "://" + user + ":" + passwd + "@" + host + else: + if prot == None or prot == "": + return host + else: + return prot + "://" + host + + @classmethod + def make_port_string(cls, port): + port = port or "" + return port + + @classmethod + def make_proxy_string(cls, prot, user, passwd, host, port, default_prot=""): + if host == None or host == "" or port == None or port == "": + return "" + + return Configuration.make_host_string(prot, user, passwd, host, default_prot) + ":" + Configuration.make_port_string(port) + def __init__(self): self.curr_mach = "" # settings
@@ -67,15 +106,43 @@ class Configuration: self.default_task = "build" # proxy settings - self.all_proxy = self.http_proxy = self.ftp_proxy = self.https_proxy = "" - self.git_proxy_host = self.git_proxy_port = "" - self.cvs_proxy_host = self.cvs_proxy_port = "" + self.enable_proxy = None + self.same_proxy = False + self.proxies = { + "http" : [None, None, None, "", ""], # protocol : [prot, user, passwd, host, port] + "https" : [None, None, None, "", ""], + "ftp" : [None, None, None, "", ""], + "git" : [None, None, None, "", ""], + "cvs" : [None, None, None, "", ""], + } def clear_selection(self): self.selected_image = None self.selected_recipes = [] self.selected_packages = [] + def split_proxy(self, protocol, proxy): + entry = [] + prot, user, passwd, host, port = Configuration.parse_proxy_string(proxy) + entry.append(prot) + entry.append(user) + entry.append(passwd) + entry.append(host) + entry.append(port) + self.proxies[protocol] = entry + + def combine_proxy(self, protocol): + entry = self.proxies[protocol] + return Configuration.make_proxy_string(entry[0], entry[1], entry[2], entry[3], entry[4], protocol) + + def combine_host_only(self, protocol): + entry = self.proxies[protocol] + return Configuration.make_host_string(entry[0], entry[1], entry[2], entry[3], protocol) + + def combine_port_only(self, protocol): + entry = self.proxies[protocol] + return Configuration.make_port_string(entry[4]) + def update(self, params): # settings self.curr_distro = params["distro"]
@@ -99,14 +166,14 @@ class Configuration: self.default_task = params["default_task"] # proxy settings - self.all_proxy = params["all_proxy"] - self.http_proxy = params["http_proxy"] - self.ftp_proxy = params["ftp_proxy"] - self.https_proxy = params["https_proxy"] - self.git_proxy_host = params["git_proxy_host"] - self.git_proxy_port = params["git_proxy_port"] - self.cvs_proxy_host = params["cvs_proxy_host"] - self.cvs_proxy_port = params["cvs_proxy_port"] + self.enable_proxy = params["http_proxy"] != "" or params["https_proxy"] != "" or params["ftp_proxy"] != "" \ + or params["git_proxy_host"] != "" or params["git_proxy_port"] != "" \ + or params["cvs_proxy_host"] != "" or params["cvs_proxy_port"] != "" + self.split_proxy("http", params["http_proxy"]) + self.split_proxy("https", params["https_proxy"]) + self.split_proxy("ftp", params["ftp_proxy"]) + self.split_proxy("git", params["git_proxy_host"] + ":" + params["git_proxy_port"]) + self.split_proxy("cvs", params["cvs_proxy_host"] + ":" + params["cvs_proxy_port"]) def load(self, template): self.curr_mach = template.getVar("MACHINE")
@@ -146,14 +213,13 @@ class Configuration: self.selected_recipes = template.getVar("DEPENDS").split() self.selected_packages = template.getVar("IMAGE_INSTALL").split() # proxy - self.all_proxy = template.getVar("all_proxy") - self.http_proxy = template.getVar("http_proxy") - self.ftp_proxy = template.getVar("ftp_proxy") - self.https_proxy = template.getVar("https_proxy") - self.git_proxy_host = template.getVar("GIT_PROXY_HOST") - self.git_proxy_port = template.getVar("GIT_PROXY_PORT") - self.cvs_proxy_host = template.getVar("CVS_PROXY_HOST") - self.cvs_proxy_port = template.getVar("CVS_PROXY_PORT") + self.enable_proxy = eval(template.getVar("enable_proxy")) + self.same_proxy = eval(template.getVar("use_same_proxy")) + self.split_proxy("http", template.getVar("http_proxy")) + self.split_proxy("https", template.getVar("https_proxy")) + self.split_proxy("ftp", template.getVar("ftp_proxy")) + self.split_proxy("git", template.getVar("GIT_PROXY_HOST") + ":" + template.getVar("GIT_PROXY_PORT")) + self.split_proxy("cvs", template.getVar("CVS_PROXY_HOST") + ":" + template.getVar("CVS_PROXY_PORT")) def save(self, template, defaults=False): # bblayers.conf
@@ -183,14 +249,15 @@ class Configuration: template.setVar("DEPENDS", self.selected_recipes) template.setVar("IMAGE_INSTALL", self.user_selected_packages) # proxy - template.setVar("all_proxy", self.all_proxy) - template.setVar("http_proxy", self.http_proxy) - template.setVar("ftp_proxy", self.ftp_proxy) - template.setVar("https_proxy", self.https_proxy) - template.setVar("GIT_PROXY_HOST", self.git_proxy_host) - template.setVar("GIT_PROXY_PORT", self.git_proxy_port) - template.setVar("CVS_PROXY_HOST", self.cvs_proxy_host) - template.setVar("CVS_PROXY_PORT", self.cvs_proxy_port) + template.setVar("enable_proxy", self.enable_proxy) + template.setVar("use_same_proxy", self.same_proxy) + template.setVar("http_proxy", self.combine_proxy("http")) + template.setVar("https_proxy", self.combine_proxy("https")) + template.setVar("ftp_proxy", self.combine_proxy("ftp")) + template.setVar("GIT_PROXY_HOST", self.combine_host_only("git")) + template.setVar("GIT_PROXY_PORT", self.combine_port_only("git")) + template.setVar("CVS_PROXY_HOST", self.combine_host_only("cvs")) + template.setVar("CVS_PROXY_PORT", self.combine_port_only("cvs")) class Parameters: '''Represents other variables like available machines, etc.'''
@@ -212,7 +279,6 @@ class Parameters: self.all_sdk_machines = [] self.all_layers = [] self.image_names = [] - self.enable_proxy = False # for build log to show self.bb_version = ""
@@ -578,13 +644,18 @@ class Builder(gtk.Window): self.handler.set_extra_inherit("packageinfo") self.handler.set_extra_inherit("image_types") # set proxies - if self.parameters.enable_proxy: - self.handler.set_http_proxy(self.configuration.http_proxy) - self.handler.set_https_proxy(self.configuration.https_proxy) - self.handler.set_ftp_proxy(self.configuration.ftp_proxy) - self.handler.set_all_proxy(self.configuration.all_proxy) - self.handler.set_git_proxy(self.configuration.git_proxy_host, self.configuration.git_proxy_port) - self.handler.set_cvs_proxy(self.configuration.cvs_proxy_host, self.configuration.cvs_proxy_port) + if self.configuration.enable_proxy == True: + self.handler.set_http_proxy(self.configuration.combine_proxy("http")) + self.handler.set_https_proxy(self.configuration.combine_proxy("https")) + self.handler.set_ftp_proxy(self.configuration.combine_proxy("ftp")) + self.handler.set_git_proxy(self.configuration.combine_host_only("git"), self.configuration.combine_port_only("git")) + self.handler.set_cvs_proxy(self.configuration.combine_host_only("cvs"), self.configuration.combine_port_only("cvs")) + elif self.configuration.enable_proxy == False: + self.handler.set_http_proxy("") + self.handler.set_https_proxy("") + self.handler.set_ftp_proxy("") + self.handler.set_git_proxy("", "") + self.handler.set_cvs_proxy("", "") def update_recipe_model(self, selected_image, selected_recipes): self.recipe_model.set_selected_image(selected_image)
@@ -996,7 +1067,6 @@ class Builder(gtk.Window): all_distros = self.parameters.all_distros, all_sdk_machines = self.parameters.all_sdk_machines, max_threads = self.parameters.max_threads, - enable_proxy = self.parameters.enable_proxy, parent = self, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
@@ -1008,7 +1078,6 @@ class Builder(gtk.Window): response = dialog.run() settings_changed = False if response == gtk.RESPONSE_YES: - self.parameters.enable_proxy = dialog.enable_proxy self.configuration = dialog.configuration self.save_defaults() # remember settings settings_changed = dialog.settings_changed
bitbake/lib/bb/ui/crumbs/hig.py +203 -70
333 lines not on this page · raw message
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +0 -4
@@ -304,9 +304,6 @@ class HobHandler(gobject.GObject): def set_ftp_proxy(self, ftp_proxy): self.runCommand(["setVariable", "ftp_proxy", ftp_proxy]) - def set_all_proxy(self, all_proxy): - self.runCommand(["setVariable", "all_proxy", all_proxy]) - def set_git_proxy(self, host, port): self.runCommand(["setVariable", "GIT_PROXY_HOST", host]) self.runCommand(["setVariable", "GIT_PROXY_PORT", port])
@@ -496,7 +493,6 @@ class HobHandler(gobject.GObject): params["http_proxy"] = self.runCommand(["getVariable", "http_proxy"]) or "" params["ftp_proxy"] = self.runCommand(["getVariable", "ftp_proxy"]) or "" params["https_proxy"] = self.runCommand(["getVariable", "https_proxy"]) or "" - params["all_proxy"] = self.runCommand(["getVariable", "all_proxy"]) or "" params["cvs_proxy_host"] = self.runCommand(["getVariable", "CVS_PROXY_HOST"]) or "" params["cvs_proxy_port"] = self.runCommand(["getVariable", "CVS_PROXY_PORT"]) or ""
Signature · 1 line
1.7.6
Richard Purdie
AppliedQuoted 6 lines · Shane Wang
This patch is to reimplement the proxy tab in the advanced settings dialog according to the new design by the design team to make it more like Gnome style. Please review and check in. Thanks.
The following changes since commit
2219caa312822cf756b88b07dd70a014404e9cb0:
Quoted 8 lines
tune-mips64.inc: Add new tune file for mips64 big-endian (2012-05-21 09:59:04 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contribshane/newproxy
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=shane/newproxyShane Wang (1):
Hob: reimplement the proxy page
Merged to master, thanks.
Richard