From 3f1a992889c858b400d84a5583fd144d93ea23f3 Mon Sep 17 00:00:00 2001 From: Hongxu Jia Date: Tue, 24 Jul 2018 16:49:09 +0800 Subject: [PATCH 34/65] text repository setting: support http proxy For text mode, it supports: - http repo + http proxy; - https repo + http proxy; - ftp repo + http proxy; Upstream-Status: Pending Signed-off-by: Hongxu Jia --- pyanaconda/ui/helpers.py | 8 +++++++- pyanaconda/ui/tui/spokes/installation_source.py | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pyanaconda/ui/helpers.py b/pyanaconda/ui/helpers.py index d980983..e9cdcab 100644 --- a/pyanaconda/ui/helpers.py +++ b/pyanaconda/ui/helpers.py @@ -109,6 +109,7 @@ class SourceSwitchHandler(object, metaclass=ABCMeta): It will correctly switch to the new method and cleanup any previous method set. """ + log = get_module_logger(__name__) @abstractproperty def data(self): @@ -177,7 +178,7 @@ class SourceSwitchHandler(object, metaclass=ABCMeta): # as we already made the device protected when # switching to it, we don't need to protect it here - def set_source_url(self, url=None): + def set_source_url(self, url=None, proxy=None): """ Switch to install source specified by URL """ # clean any old HDD ISO sources self._clean_hdd_iso() @@ -185,6 +186,11 @@ class SourceSwitchHandler(object, metaclass=ABCMeta): self.data.method.method = "url" if url is not None: self.data.method.url = url + self.log.info("url: %s" % url) + + if proxy is not None: + self.data.method.proxy = proxy + self.log.info("proxy: %s" % proxy) def set_source_nfs(self, opts=None): """ Switch to NFS install source """ diff --git a/pyanaconda/ui/tui/spokes/installation_source.py b/pyanaconda/ui/tui/spokes/installation_source.py index ab44ecc..da65437 100644 --- a/pyanaconda/ui/tui/spokes/installation_source.py +++ b/pyanaconda/ui/tui/spokes/installation_source.py @@ -263,6 +263,7 @@ class SpecifyRepoSpoke(NormalTUISpoke, SourceSwitchHandler): self._container = None self._url = self.data.url.url + self._proxy = self.data.method.proxy def refresh(self, args=None): """ Refresh window. """ @@ -273,11 +274,17 @@ class SpecifyRepoSpoke(NormalTUISpoke, SourceSwitchHandler): dialog = Dialog(_("Repo URL")) self._container.add(EntryWidget(dialog.title, self._url), self._set_repo_url, dialog) + dialog = Dialog(_("Repo Proxy")) + self._container.add(EntryWidget(dialog.title, self._proxy), self._set_repo_proxy, dialog) + self.window.add_with_separator(self._container) def _set_repo_url(self, dialog): self._url = dialog.run() + def _set_repo_proxy(self, dialog): + self._proxy = dialog.run() + def input(self, args, key): if self._container.process_user_input(key): self.apply() @@ -302,7 +309,15 @@ class SpecifyRepoSpoke(NormalTUISpoke, SourceSwitchHandler): # protocol either unknown or entry already starts with a protocol # specification url = self._url - self.set_source_url(url) + + # Proxy only support http protocal + proxy = None + if self._proxy is not None: + if not self._proxy.startswith("http://"): + proxy = "http://" + self._proxy + else: + proxy = self._proxy + self.set_source_url(url, proxy) class SpecifyNFSRepoSpoke(NormalTUISpoke, SourceSwitchHandler): -- 2.7.4