[yum-cvs] yum/yum repos.py,1.90,1.90.2.1

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


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

Modified Files:
      Tag: yum-2_6_X
	repos.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: repos.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/repos.py,v
retrieving revision 1.90
retrieving revision 1.90.2.1
diff -u -r1.90 -r1.90.2.1
--- repos.py	11 Jan 2006 07:15:22 -0000	1.90
+++ repos.py	19 Apr 2006 14:59:37 -0000	1.90.2.1
@@ -342,7 +342,7 @@
         self.proxy_password = None
         self.proxy_username = None
         self.proxy = None
-        self.proxy_dict = {}
+        self._proxy_dict = {}
         self.metadata_cookie_fn = 'cachecookie'
         self.groups_added = False
         
@@ -447,10 +447,10 @@
         return self.setkeys
     
     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
@@ -468,9 +468,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
@@ -482,17 +482,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')
@@ -532,7 +527,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)
@@ -585,10 +580,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,
@@ -597,7 +588,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,
@@ -704,6 +695,16 @@
             raise URLGrabError(-1, 'Error importing repomd.xml for %s: %s' % (self, e))
 
 
+    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 _checkMD(self, fn, mdtype):
         """check the metadata type against its checksum"""
         
@@ -817,7 +818,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"""
@@ -835,7 +836,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