[PATCH 1/2] Add Payload.needsNetwork property.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clean up checking for whether a network connection is required.

Also, move _resetMethod up into Payload.
---
 pyanaconda/packaging/__init__.py   |   26 +++++++++++++++++++++++++-
 pyanaconda/packaging/yumpayload.py |   32 +++-----------------------------
 2 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index cd76fcd..ec82d69 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -43,7 +43,6 @@ from pyanaconda.constants import *
 from pyanaconda.flags import flags
 
 from pyanaconda import iutil
-from pyanaconda.network import hasActiveNetDev
 
 from pyanaconda.image import opticalInstallMedia
 from pyanaconda.image import mountImage
@@ -168,6 +167,31 @@ class Payload(object):
 
         return repo
 
+    def _repoNeedsNetwork(self, repo):
+        """ Returns True if the ksdata repo requires networking. """
+        urls = [repo.baseurl] + repo.mirrorlist
+        network_protocols = ["http:", "ftp:", "nfs:", "nfsiso:"]
+        for url in urls:
+            if any([url.startswith(p) for p in network_protocols]):
+                return True
+
+        return False
+
+    @property
+    def needsNetwork(self):
+        return any(self._repoNeedsNetwork(r) for r in self.data.repo.dataList())
+
+    def _resetMethod(self):
+        self.data.method.method = ""
+        self.data.method.url = None
+        self.data.method.server = None
+        self.data.method.dir = None
+        self.data.method.partition = None
+        self.data.method.biospart = None
+        self.data.method.noverifyssl = False
+        self.data.method.proxy = ""
+        self.data.method.opts = None
+
     def updateBaseRepo(self, storage):
         """ Update the base repository from ksdata.method. """
         pass
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index d1b7046..7277413 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -187,27 +187,6 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
 
         return base_repo_name
 
-    def _repoNeedsNetwork(self, repo):
-        """ Returns True if the ksdata repo requires networking. """
-        urls = [repo.baseurl] + repo.mirrorlist
-        network_protocols = ["http:", "ftp:", "nfs:", "nfsiso:"]
-        for url in urls:
-            if any([url.startswith(p) for p in network_protocols]):
-                return True
-
-        return False
-
-    def _resetMethod(self):
-        self.data.method.method = ""
-        self.data.method.url = None
-        self.data.method.server = None
-        self.data.method.dir = None
-        self.data.method.partition = None
-        self.data.method.biospart = None
-        self.data.method.noverifyssl = False
-        self.data.method.proxy = ""
-        self.data.method.opts = None
-
     def updateBaseRepo(self, storage, fallback=True):
         """ Update the base repo based on self.data.method.
 
@@ -550,13 +529,8 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
         from yum.Errors import RepoError
 
         if not self._groups:
-            has_network = hasActiveNetDev()
-            for repo in self.data.repo.dataList():
-                needs_network = self._repoNeedsNetwork(repo)
-                if needs_network and not has_network:
-                    raise NoNetworkError
-                elif needs_network and has_network:
-                    break
+            if self.needsNetwork and not hasActiveNetDev():
+                raise NoNetworkError
 
             try:
                 self._groups = self._yum.comps
@@ -608,7 +582,7 @@ reposdir=/etc/yum.repos.d,/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/t
         from yum.Errors import RepoError
 
         if not self._packages:
-            if not hasActiveNetDev():
+            if self.needsNetwork and not hasActiveNetDev():
                 raise NoNetworkError
 
             try:
-- 
1.7.9.3

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux