The environment addon refresh really only needs to be executed when new
metadata has been fetched so move it into packaging and call it after
metadata download. It was also running very slow from the other thread,
moving it speeds it up considerably.
This also removes the need to call it from software.py when the source
has changed, since it will already be updated when the spoke is entered.
---
pyanaconda/packaging/__init__.py | 33 ++++++++++++++++++++++++++++-
pyanaconda/packaging/dnfpayload.py | 1 +
pyanaconda/packaging/yumpayload.py | 3 +++
pyanaconda/ui/gui/spokes/software.py | 41 +++++++++---------------------------
4 files changed, 46 insertions(+), 32 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index bcf0ac5..b7a056a 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -644,6 +644,13 @@ class PackagePayload(Payload):
super(PackagePayload, self).__init__(data)
self.install_device = None
+ # Used to determine which add-ons to display for each environment.
+ # The dictionary keys are environment IDs. The dictionary values are two-tuples
+ # consisting of lists of add-on group IDs. The first list is the add-ons specific
+ # to the environment, and the second list is the other add-ons possible for the
+ # environment.
+ self._environmentAddons = {}
+
@property
def kernelPackages(self):
kernels = ["kernel"]
@@ -896,6 +903,31 @@ class PackagePayload(Payload):
def environmentGroups(self, environmentid):
raise NotImplementedError()
+ @property
+ def environmentAddons(self):
+ return self._environmentAddons
+
+ def _isGroupVisible(self, grp):
+ raise NotImplementedError()
+
+ def _groupHasInstallableMembers(self, grp):
+ raise NotImplementedError()
+
+ def _refreshEnvironmentAddons(self):
+ log.info("Refreshing environmentAddons")
+ self._environmentAddons = {}
+
+ for environment in self.environments:
+ self._environmentAddons[environment] = ([], [])
+
+ # Determine which groups are specific to this environment and which other groups
+ # are available in this environment.
+ for grp in self.groups:
+ if self.environmentHasOption(environment, grp):
+ self._environmentAddons[environment][0].append(grp)
+ elif self._isGroupVisible(grp) and self._groupHasInstallableMembers(grp):
+ self._environmentAddons[environment][1].append(grp)
+
###
### METHODS FOR WORKING WITH GROUPS
###
@@ -906,7 +938,6 @@ class PackagePayload(Payload):
def groupDescription(self, groupid):
raise NotImplementedError()
-
def payloadInitialize(storage, ksdata, payload):
from pyanaconda.threads import threadMgr
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py
index ecfba1d..347cf01 100644
--- a/pyanaconda/packaging/dnfpayload.py
+++ b/pyanaconda/packaging/dnfpayload.py
@@ -338,6 +338,7 @@ class DNFPayload(packaging.PackagePayload):
map(self._sync_metadata, self._base.repos.iter_enabled())
self._base.fill_sack(load_system_repo=False)
self._base.read_comps()
+ self._refreshEnvironmentAddons()
def install(self):
progressQ.send_message(_('Starting package installation process'))
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 43ce236..c4b00d3 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -609,6 +609,9 @@ reposdir=%s
repo_id, e)
self.disableRepo(repo_id)
+ # Make sure environmentAddon information is current
+ self._refreshEnvironmentAddons()
+
log.info("metadata retrieval complete")
@property
diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index 424a98a..1b26b28 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -33,6 +33,9 @@ from pyanaconda.ui.gui.spokes.lib.detailederror import DetailedErrorDialog
from pyanaconda.ui.gui.utils import enlightbox, gtk_action_wait, escape_markup
from pyanaconda.ui.gui.categories.software import SoftwareCategory
+import logging
+log = logging.getLogger("anaconda")
+
import sys
__all__ = ["SoftwareSelectionSpoke"]
@@ -68,13 +71,6 @@ class SoftwareSelectionSpoke(NormalSpoke):
self._environmentListBox = self.builder.get_object("environmentListBox")
self._addonListBox = self.builder.get_object("addonListBox")
- # Used to determine which add-ons to display for each environment.
- # The dictionary keys are environment IDs. The dictionary values are two-tuples
- # consisting of lists of add-on group IDs. The first list is the add-ons specific
- # to the environment, and the second list is the other add-ons possible for the
- # environment.
- self._environmentAddons = {}
-
# Used to store how the user has interacted with add-ons for the default add-on
# selection logic. The dictionary keys are group IDs, and the values are selection
# state constants. See refreshAddons for how the values are used.
@@ -249,19 +245,6 @@ class SoftwareSelectionSpoke(NormalSpoke):
self._apply()
def _parseEnvironments(self):
- self._environmentAddons = {}
-
- for environment in self.payload.environments:
- self._environmentAddons[environment] = ([], [])
-
- # Determine which groups are specific to this environment and which other groups
- # are available in this environment.
- for grp in self.payload.groups:
- if self.payload.environmentHasOption(environment, grp):
- self._environmentAddons[environment][0].append(grp)
- elif self.payload._isGroupVisible(grp) and self.payload._groupHasInstallableMembers(grp):
- self._environmentAddons[environment][1].append(grp)
-
# Set all of the add-on selection states to the default
self._addonStates = {}
for grp in self.payload.groups:
@@ -347,11 +330,7 @@ class SoftwareSelectionSpoke(NormalSpoke):
self._add_row(self._addonListBox, name, desc, check)
def refreshAddons(self):
- # The source was changed, make sure the list is current
- if not self.txid_valid:
- self._parseEnvironments()
-
- if self.environment and (self.environment in self._environmentAddons):
+ if self.environment and (self.environment in self.payload.environmentAddons):
self._clear_listbox(self._addonListBox)
# We have two lists: One of addons specific to this environment,
@@ -364,10 +343,10 @@ class SoftwareSelectionSpoke(NormalSpoke):
# state will be used. Otherwise, the add-on will be selected if it is a default
# for this environment.
- addSep = len(self._environmentAddons[self.environment][0]) > 0 and \
- len(self._environmentAddons[self.environment][1]) > 0
+ addSep = len(self.payload.environmentAddons[self.environment][0]) > 0 and \
+ len(self.payload.environmentAddons[self.environment][1]) > 0
- for grp in self._environmentAddons[self.environment][0]:
+ for grp in self.payload.environmentAddons[self.environment][0]:
self._addAddon(grp)
# This marks a separator in the view - only add it if there's both environment
@@ -375,7 +354,7 @@ class SoftwareSelectionSpoke(NormalSpoke):
if addSep:
self._addonListBox.insert(Gtk.Separator(), -1)
- for grp in self._environmentAddons[self.environment][1]:
+ for grp in self.payload.environmentAddons[self.environment][1]:
self._addAddon(grp)
self._selectFlag = True
@@ -386,9 +365,9 @@ class SoftwareSelectionSpoke(NormalSpoke):
self.clear_info()
def _allAddons(self):
- return self._environmentAddons[self.environment][0] + \
+ return self.payload.environmentAddons[self.environment][0] + \
[""] + \
- self._environmentAddons[self.environment][1]
+ self.payload.environmentAddons[self.environment][1]
def _get_selected_addons(self):
retval = []
--
1.8.5.3