repodb: Let check_distribution raise an error

This commit moves the check from cli code to api.py. Check is done
at every repo update. Also uses SourceName tag for getting distribution
name.
This commit is contained in:
Fatih Aşıcı
2010-05-20 12:21:40 +00:00
parent ed12a3efbf
commit cb220d98dd
3 changed files with 15 additions and 9 deletions
+2
View File
@@ -838,6 +838,8 @@ def __update_repo(repo, force=False):
else:
return
repodb.check_distribution(repo)
try:
index.check_signature(repouri, repo)
except pisi.file.NoSignatureFound, e:
-2
View File
@@ -89,8 +89,6 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
if not ctx.get_option('no_fetch'):
try:
pisi.api.update_repo(name)
if not ctx.get_option('ignore_check'):
self.check_distro(name)
except (pisi.fetcher.FetchError, IOError):
warning = _("%s repository could not be reached. Removing %s from system.") % (name, name)
self.warn_and_remove(warning, name)
+13 -7
View File
@@ -27,6 +27,9 @@ import pisi.db.lazydb as lazydb
class RepoError(pisi.Error):
pass
class IncompatibleRepoError(RepoError):
pass
class Repo:
def __init__(self, indexuri):
self.indexuri = indexuri
@@ -225,19 +228,22 @@ class RepoDB(lazydb.LazyDB):
def get_distribution(self, name):
doc = self.get_repo_doc(name)
return doc.getTag("Distribution").getTagData("DistributionName")
return doc.getTag("Distribution").getTagData("SourceName")
def get_distribution_release(self, name):
doc = self.get_repo_doc(name)
return doc.getTag("Distribution").getTagData("Version")
def check_distribution(self, name):
if ctx.get_option('ignore_check'):
return
dist_name = self.get_distribution(name)
dist_release = self.get_distribution_release(name)
if not dist_name:
# If distribution info is not available, ignore for now.
return True
return dist_name == ctx.config.values.general.distribution and \
dist_release == ctx.config.values.general.distribution_release
if dist_name != ctx.config.values.general.distribution or \
dist_release != ctx.config.values.general.distribution_release:
self.deactivate_repo(name)
raise IncompatibleRepoError(
_("Repository '%s' is not compatible with your "
"distribution. Repository is disabled.") % name)