[yum-cvs] yum/yum Errors.py, 1.14, 1.15 __init__.py, 1.272, 1.273 config.py, 1.111, 1.112 yumRepo.py, 1.29, 1.30
Jeremy Katz
katzj at linux.duke.edu
Sat Feb 3 21:30:10 UTC 2007
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv21426/yum
Modified Files:
Errors.py __init__.py config.py yumRepo.py
Log Message:
start of pushing media handling into yum. define mediaid= in a repo config
file to say that a specific repo is tied to a specific media set. yum api
users need to set self.mediagrabber in their YumBase object to a function
that actually does the getting of the file.
Index: Errors.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/Errors.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Errors.py 3 Feb 2007 15:36:59 -0000 1.14
+++ Errors.py 3 Feb 2007 21:30:08 -0000 1.15
@@ -93,6 +93,10 @@
YumBaseError.__init__(self)
self.value = value
+class MediaError(YumBaseError):
+ def __init__(self, value=None):
+ YumBaseError.__init__(self, value)
+
class YumDeprecationWarning(DeprecationWarning):
def __init__(self, value=None):
DeprecationWarning.__init__(self, value)
Index: __init__.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/__init__.py,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -r1.272 -r1.273
--- __init__.py 3 Feb 2007 15:44:22 -0000 1.272
+++ __init__.py 3 Feb 2007 21:30:08 -0000 1.273
@@ -74,7 +74,17 @@
# Start with plugins disabled
self.disablePlugins()
- self.localPackages = [] # for local package handling
+ self.localPackages = [] # for local package handling
+
+ self.mediagrabber = None
+
+ def _mediaPlaceholder(self, *args, **kwargs):
+ # FIXME: this should be removed once the media bits are fully
+ # working, but this way we can do a little bit more easy testing
+ print "calling media placeholder"
+ print "args:", args
+ print "kwargs:", kwargs
+ import pdb; pdb.set_trace()
def _transactionDataFactory(self):
"""Factory method returning TransactionData object"""
@@ -304,7 +314,7 @@
num = 1
for repo in repos:
- repo.setup(self.conf.cache)
+ repo.setup(self.conf.cache, self.mediagrabber)
num += 1
Index: config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- config.py 31 Jan 2007 01:26:33 -0000 1.111
+++ config.py 3 Feb 2007 21:30:08 -0000 1.112
@@ -528,6 +528,7 @@
enabled = Inherit(YumConf.enabled)
baseurl = UrlListOption()
mirrorlist = UrlOption()
+ mediaid = Option()
gpgkey = UrlListOption()
exclude = ListOption()
includepkgs = ListOption()
Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- yumRepo.py 22 Jan 2007 04:33:22 -0000 1.29
+++ yumRepo.py 3 Feb 2007 21:30:08 -0000 1.30
@@ -30,6 +30,11 @@
from yum import config
from yum import misc
+import logging
+
+logger = logging.getLogger("yum.Repos")
+verbose_logger = logging.getLogger("yum.verbose.Repos")
+
class YumPackageSack(packageSack.PackageSack):
"""imports/handles package objects from an mdcache dict object"""
def __init__(self, packageClass):
@@ -171,6 +176,9 @@
self.failure_obj = None
self.mirror_failure_obj = None
self.interrupt_callback = None
+
+ # callback function for handling media
+ self.mediafunc = None
self.storage = storagefactory.GetStorage()
self.sack = self.storage.GetPackageSack()
@@ -245,7 +253,7 @@
def check(self):
"""self-check the repo information - if we don't have enough to move
on then raise a repo error"""
- if len(self.urls) < 1:
+ if len(self.urls) < 1 and (not self.mediaid or not self.mediafunc):
raise Errors.RepoError, \
'Cannot find a valid baseurl for repo: %s' % self.id
@@ -397,8 +405,17 @@
else: # ain't there - raise
raise Errors.RepoError, \
"Caching enabled but no local cache of %s from %s" % (local,
+
self)
+ if self.mediaid and self.mediafunc:
+ try:
+ result = self.mediafunc(local = local, checkfunc = checkfunc, relative = relative, text = text, copy_local = copy_local)
+ except MediaError, e:
+ verbose_logger(logginglevels.DEBUG_2, "Error getting package from media; falling back to url %s" %(e,))
+ else:
+ return result
+
if url is not None:
ug = URLGrabber(keepalive = self.keepalive,
bandwidth = self.bandwidth,
@@ -498,9 +515,10 @@
del fo
- def setup(self, cache):
+ def setup(self, cache, mediafunc = None):
try:
self.cache = cache
+ self.mediafunc = mediafunc
self.baseurlSetup()
self.dirSetup()
except Errors.RepoError, e:
More information about the Yum-cvs-commits
mailing list