[yum-cvs] yum/yum yumRepo.py,1.1,1.2

Jeremy Katz katzj at linux.duke.edu
Wed Apr 19 14:59:36 UTC 2006


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv28706/yum

Modified Files:
	yumRepo.py 
Log Message:
ensure consistent access of proxy information so that it's always set up even
if you're not setting up all the repo callbacks (rh#185309)

also, use the proxies for grabbing the mirror list (rh#161190)


Index: yumRepo.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/yumRepo.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- yumRepo.py	12 Apr 2006 19:01:06 -0000	1.1
+++ yumRepo.py	19 Apr 2006 14:59:34 -0000	1.2
@@ -148,8 +148,8 @@
         self.yumvar = {} # empty dict of yumvariables for $string replacement
         self.proxy_password = None
         self.proxy_username = None
-        self.proxy = None 
-        self.proxy_dict = {}
+        self.proxy = None
+        self._proxy_dict = {}
         self.metadata_cookie_fn = 'cachecookie'
         self.groups_added = False
         
@@ -181,6 +181,16 @@
         self.sack = self._selectSackType()
 
 
+    def __getProxyDict(self):
+        self.doProxyDict()
+        if self._proxy_dict:
+            return self._proxy_dict
+        return None
+
+    # consistent access to how proxy information should look (and ensuring
+    # that it's actually determined for the repo)
+    proxy_dict = property(__getProxyDict)
+
     def _selectSackType(self):
 
         if (self.sqlite):
@@ -279,10 +289,10 @@
              'Cannot find a valid baseurl for repo: %s' % self.id
 
     def doProxyDict(self):
-        if self.proxy_dict:
+        if self._proxy_dict:
             return
 
-        self.proxy_dict = {} # zap it
+        self._proxy_dict = {} # zap it
         proxy_string = None
         if self.proxy not in [None, '_none_']:
             proxy_string = '%s' % self.proxy
@@ -300,9 +310,9 @@
                               proxy_host, proxy_rest)
 
         if proxy_string is not None:
-            self.proxy_dict['http'] = proxy_string
-            self.proxy_dict['https'] = proxy_string
-            self.proxy_dict['ftp'] = proxy_string
+            self._proxy_dict['http'] = proxy_string
+            self._proxy_dict['https'] = proxy_string
+            self._proxy_dict['ftp'] = proxy_string
 
     def setupGrab(self):
         """sets up the grabber functions with the already stocked in urls for
@@ -314,17 +324,12 @@
             mgclass = urlgrabber.mirror.MirrorGroup
 
 
-        self.doProxyDict()
-        prxy = None
-        if self.proxy_dict:
-            prxy = self.proxy_dict
-
         self.grabfunc = URLGrabber(keepalive=self.keepalive,
                                    bandwidth=self.bandwidth,
                                    retry=self.retries,
                                    throttle=self.throttle,
                                    progress_obj=self.callback,
-                                   proxies = prxy,
+                                   proxies = self.proxy_dict,
                                    failure_callback=self.failure_obj,
                                    timeout=self.timeout,
                                    reget='simple')
@@ -365,7 +370,7 @@
 
         goodurls = []
         if self.mirrorlist and not self.mirrorlistparsed:
-            mirrorurls = getMirrorList(self.mirrorlist)
+            mirrorurls = getMirrorList(self.mirrorlist, self.proxy_dict)
             self.mirrorlistparsed = 1
             for url in mirrorurls:
                 url = parser.varReplace(url, self.yumvar)
@@ -418,10 +423,6 @@
                     "Caching enabled but no local cache of %s from %s" % (local,
                            self)
 
-        self.doProxyDict()
-        prxy = None
-        if self.proxy_dict:
-            prxy = self.proxy_dict
         if url is not None:
             ug = URLGrabber(keepalive = self.keepalive,
                             bandwidth = self.bandwidth,
@@ -430,7 +431,7 @@
                             progres_obj = self.callback,
                             copy_local = copy_local,
                             reget = reget,
-                            proxies = prxy,
+                            proxies = self.proxy_dict,
                             failure_callback = self.failure_obj,
                             timeout=self.timeout,
                             checkfunc=checkfunc,
@@ -695,7 +696,7 @@
 
 
 
-def getMirrorList(mirrorlist):
+def getMirrorList(mirrorlist, pdict = None):
     """retrieve an up2date-style mirrorlist file from a url,
        we also s/$ARCH/$BASEARCH/ and move along
        returns a list of the urls from that file"""
@@ -713,7 +714,7 @@
         url = mirrorlist
 
     try:
-        fo = urlresolver.urlopen(url)
+        fo = urlresolver.urlopen(url, proxies=pdict)
     except urlgrabber.grabber.URLGrabError, e:
         fo = None
 




More information about the Yum-cvs-commits mailing list