[master 2/5] Add IDs to identify addon repositories
jkonecny12
installerbot-noreply at redhat.com
Tue Jul 14 09:02:43 UTC 2015
From: Jiri Konecny <jkonecny at redhat.com>
Choose to use identifiers for the repositories because I have found nothing
which wasn't changing in time.
This seems to fix most of the problems with the Source spoke.
---
pyanaconda/ui/gui/spokes/source.py | 63 ++++++++++++++++++++++----------------
1 file changed, 37 insertions(+), 26 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index a041f42..479c41a 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -391,6 +391,7 @@ def __init__(self, *args, **kwargs):
self._proxyUrl = ""
self._proxyChange = False
self._cdrom = None
+ self._repo_counter = 0
self._repoChecks = {}
@@ -945,7 +946,7 @@ def _checkURL(self, inputcheck, combo):
is_additional_repo = combo is None
if is_additional_repo:
# Input object contains repository name
- repo = self._get_repo_by_name(inputcheck.input_obj)
+ repo = self._get_repo_by_id(inputcheck.input_obj)
protocol = urlsplit(repo.baseurl)[0]
url_string = repo.baseurl.strip()[len(protocol) + 3:]
else:
@@ -1022,7 +1023,7 @@ def _checkDuplicateRepos(self, inputcheck):
def _checkRepoName(self, inputcheck):
# Input object is name of the repository
- repo_name = inputcheck.input_obj
+ repo_name = self._get_repo_by_id(inputcheck.input_obj).name
if not repo_name:
return _("Empty repository name")
@@ -1040,7 +1041,7 @@ def _checkRepoName(self, inputcheck):
def _checkRepoProxy(self, inputcheck):
# Input object contains repo name
- repo = self._get_repo_by_name(inputcheck.input_obj)
+ repo = self._get_repo_by_id(inputcheck.input_obj)
# If nfs is selected as the protocol, skip the proxy check
if repo.baseurl.startswith(PROTOCOL_NFS):
return InputCheck.CHECK_OK
@@ -1216,6 +1217,8 @@ def _reset_repoStore(self):
If the list has no element, clear the repo entry fields.
"""
+ log.debug("Clearing checks in source spoke")
+
# Remove the repo checks
for checks in self._repoChecks.values():
self.remove_check(checks.name_check)
@@ -1235,6 +1238,9 @@ def _reset_repoStore(self):
enabled=repo.enabled)
# Track the original name, user may change .name
ks_repo.orig_name = name
+ # Add addon repository id for identification
+ ks_repo.addon_repo_id = self._repo_counter
+ self._repo_counter += 1
self._repoStore.append([self.payload.isRepoEnabled(name),
ks_repo.name,
ks_repo])
@@ -1273,11 +1279,12 @@ def _unique_repo_name(self, name):
highest_index = max(matches) if matches else 0
return name + ("_%d" % (highest_index + 1))
- def _get_repo_by_name(self, name):
- """ Return a repository by given name"""
+ def _get_repo_by_id(self, id):
+ """ Return a repository by given name
+ """
for repo in self._repoStore:
- if repo.name == name:
- return repo
+ if repo[REPO_OBJ].addon_repo_id == id:
+ return repo[REPO_OBJ]
return None
def on_repoSelection_changed(self, *args):
@@ -1401,6 +1408,9 @@ def on_addRepo_clicked(self, button):
repo = self.data.RepoData(name=name)
repo.ks_repo = True
repo.orig_name = ""
+ # Set addon repo id and increment counter
+ repo.addon_repo_id = self._repo_counter
+ self._repo_counter += 1
itr = self._repoStore.append([True, repo.name, repo])
self._repoSelection.select_iter(itr)
@@ -1415,10 +1425,10 @@ def on_removeRepo_clicked(self, button):
# Remove the input validation checks for this repo
repo = self._repoStore[itr][REPO_OBJ]
- self.remove_check(self._repoChecks[repo.name].name_check)
- self.remove_check(self._repoChecks[repo.name].url_check)
- self.remove_check(self._repoChecks[repo.name].proxy_check)
- del self._repoChecks[repo.name]
+ self.remove_check(self._repoChecks[repo.addon_repo_id].name_check)
+ self.remove_check(self._repoChecks[repo.addon_repo_id].url_check)
+ self.remove_check(self._repoChecks[repo.addon_repo_id].proxy_check)
+ del self._repoChecks[repo.addon_repo_id]
self._repoStore.remove(itr)
if len(self._repoStore) == 0:
@@ -1439,17 +1449,12 @@ def on_repoNameEntry_changed(self, entry):
repo = self._repoStore[itr][REPO_OBJ]
name = self._repoNameEntry.get_text().strip()
- old_name = repo.name
- if name == old_name:
- # nothing changed
- return
-
repo.name = name
self._repoStore.set_value(itr, REPO_NAME_COL, name)
-
- self._repoChecks[name] = self._repoChecks[old_name]
- del self._repoChecks[old_name]
- self._repoChecks[name].name_check.update_check_status()
+ # do not update check status if check are not yet set up
+ # (populationg/refreshing the spoke)
+ if repo.addon_repo_id in self._repoChecks:
+ self._repoChecks[repo.addon_repo_id].name_check.update_check_status()
def on_repoUrl_changed(self, editable, data=None):
""" proxy url or protocol changed
@@ -1466,7 +1471,10 @@ def on_repoUrl_changed(self, editable, data=None):
else:
repo.baseurl = proto + url
- self._repoChecks[repo.name].url_check.update_check_status()
+ # do not update check status if check are not yet set up
+ # (populationg/refreshing the spoke)
+ if repo.addon_repo_id in self._repoChecks:
+ self._repoChecks[repo.addon_repo_id].url_check.update_check_status()
# Check for and remove a URL prefix that matches the protocol dropdown
self._removeUrlPrefix(editable, self._repoProtocolComboBox, self.on_repoUrl_changed)
@@ -1503,7 +1511,7 @@ def on_repoProxy_changed(self, *args):
# do not update check status if checks are not yet set up
# (populating/refreshing the spoke)
if repo.name in self._repoChecks:
- self._repoChecks[repo.name].proxy_check.update_check_status()
+ self._repoChecks[repo.addon_repo_id].proxy_check.update_check_status()
try:
proxy = ProxyString(url=url, username=username, password=password)
@@ -1533,13 +1541,16 @@ def on_repoStore_row_inserted(self, model, path, itr, user_data=None):
# to this method is different from the iter used everywhere else, and is useless
# once this method returns. Instead, create a TreeRowReference and work backwards
# from that using paths any time we need to reference the store.
- self._repoChecks[repo.name] = RepoChecks(InputCheckHandler.add_check(self, self._repoNameEntry,
+ self._repoChecks[repo.addon_repo_id] = RepoChecks(InputCheckHandler.add_check(self,
+ repo.addon_repo_id,
self._checkRepoName,
Gtk.TreeRowReference.new(model, path)),
- InputCheckHandler.add_check(self, self._repoUrlEntry,
+ InputCheckHandler.add_check(self,
+ repo.addon_repo_id,
self._checkRepoURL,
Gtk.TreeRowReference.new(model, path)),
- InputCheckHandler.add_check(self, self._repoProxyUrlEntry,
+ InputCheckHandler.add_check(self,
+ repo.addon_repo_id,
self._checkRepoProxy,
Gtk.TreeRowReference.new(model, path)))
@@ -1555,4 +1566,4 @@ def on_repoProtocolComboBox_changed(self, combobox, user_data=None):
itr = self._repoSelection.get_selected()[1]
if itr:
repo = self._repoStore[itr][REPO_OBJ]
- self._repoChecks[repo.name].proxy_check.update_check_status()
+ self._repoChecks[repo.addon_repo_id].proxy_check.update_check_status()
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/6f417c2f84bd12a012d0a62b8fe12754aa300410
More information about the anaconda-patches
mailing list