[rhel7-branch/master][PATCH] Don't read proxy for methods that have no proxy (#997410)
David Shea
dshea at redhat.com
Thu Aug 15 15:11:02 UTC 2013
Not every method implements a proxy, so check that the proxy attribute
exists before reading it. No checks were added to the use of proxy in
LiveImageKSPayload, since if self.data.method there is not a liveimg,
something else went terribly wrong.
---
pyanaconda/packaging/__init__.py | 6 +++++-
pyanaconda/packaging/yumpayload.py | 20 ++++++++++++++++----
pyanaconda/ui/gui/spokes/source.py | 8 ++++++--
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 41f6a2a..ed00972 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -446,7 +446,11 @@ class Payload(object):
log.debug("getting release version from tree at %s (%s)" % (url,
version))
- treeinfo = self._getTreeInfo(url, self.data.method.proxy, not flags.noverifyssl)
+ if hasattr(self.data.method, "proxy"):
+ proxy = self.data.method.proxy
+ else:
+ proxy = None
+ treeinfo = self._getTreeInfo(url, proxy, not flags.noverifyssl)
if treeinfo:
c = ConfigParser.ConfigParser()
c.read(treeinfo)
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index c912f8a..f536666 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -261,7 +261,7 @@ reposdir=%s
if self.data.packages.multiLib:
buf += "multilib_policy=all\n"
- if self.data.method.proxy:
+ if hasattr(self.data.method, "proxy") and self.data.method.proxy:
try:
proxy = ProxyString(self.data.method.proxy)
buf += "proxy=%s\n" % (proxy.noauth_url,)
@@ -333,7 +333,7 @@ reposdir=%s
f.write("proxy_password=%s\n" % (proxy.password,))
except ProxyStringError as e:
log.error("Failed to parse proxy for _writeInstallConfig %s: %s" \
- % (self.data.method.proxy, e))
+ % (ks_repo.proxy, e))
if ks_repo.cost:
f.write("cost=%d\n" % ks_repo.cost)
@@ -772,9 +772,15 @@ reposdir=%s
raise PayloadSetupError("base repo is unusable")
self._yumCacheDirHack()
+
+ if hasattr(method, "proxy"):
+ proxyurl = method.proxy
+ else:
+ proxyurl = None
+
try:
self._addYumRepo(BASE_REPO_NAME, url, mirrorlist=mirrorlist,
- proxyurl=method.proxy, sslverify=sslverify)
+ proxyurl=proxyurl, sslverify=sslverify)
except MetadataError as e:
log.error("base repo (%s/%s) not valid -- removing it"
% (method.method, url))
@@ -794,7 +800,13 @@ reposdir=%s
if self._repoNeedsNetwork(repo) and not nm_is_connected():
raise NoNetworkError
- proxy = repo.proxy or self.data.method.proxy
+ if repo.proxy:
+ proxy = repo.proxy
+ elif hasattr(self.data.method, "proxy"):
+ proxy = self.data.method.proxy
+ else:
+ proxy = None
+
sslverify = not (flags.noverifyssl or repo.noverifyssl)
# this repo is already in ksdata, so we only add it to yum here
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index ba20564..009d386 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -119,7 +119,7 @@ class ProxyDialog(GUIObject):
self._proxyUsernameEntry = self.builder.get_object("proxyUsernameEntry")
self._proxyPasswordEntry = self.builder.get_object("proxyPasswordEntry")
- if not self.data.method.proxy:
+ if not (hasattr(self.data.method, "proxy") and self.data.method.proxy):
self._proxyCheck.set_active(False)
self.on_proxy_enable_toggled(self._proxyCheck)
self._authCheck.set_active(False)
@@ -421,7 +421,7 @@ class SourceSpoke(NormalSpoke):
log.error("PayloadError: %s" % (e,))
self._error = True
hubQ.send_message(self.__class__.__name__, _("Failed to set up installation source"))
- if not self.data.method.proxy:
+ if not (hasattr(self.data.method, "proxy") and self.data.method.proxy):
gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url"))
else:
gtk_call_once(self.set_warning, _("Failed to set up installation source; check the repo url and proxy settings"))
@@ -749,6 +749,10 @@ class SourceSpoke(NormalSpoke):
self._verifyIsoButton.set_sensitive(True)
def on_proxy_clicked(self, button):
+ # If this method has no proxy, ignore the click
+ if not hasattr(self.data.method, "proxy"):
+ return
+
old_proxy = self.data.method.proxy
dialog = ProxyDialog(self.data)
with enlightbox(self.window, dialog.window):
--
1.8.3.1
More information about the anaconda-patches
mailing list