Bug #200231 - Make dir_get_metadata() handle an exception thrown
authorZac Medico <zmedico@gentoo.org>
Tue, 27 Nov 2007 01:11:10 +0000 (01:11 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 Nov 2007 01:11:10 +0000 (01:11 -0000)
from dir_get_list() when there's a problem connection problem.

svn path=/main/trunk/; revision=8702

pym/portage/getbinpkg.py

index 87f20552824ad195453e73dd18b796c33e6bb30b..d2d1f75ab5f051cb448ea2a3603da1656e7a5ba2 100644 (file)
@@ -307,7 +307,9 @@ def dir_get_list(baseurl,conn=None):
                        del page
                        listing = parser.get_anchors()
                else:
-                       raise Exception, "Unable to get listing: %s %s" % (rc,msg)
+                       import portage.exception
+                       raise portage.exception.PortageException(
+                               "Unable to get listing: %s %s" % (rc,msg))
        elif protocol in ["ftp"]:
                if address[-1] == '/':
                        olddir = conn.pwd()
@@ -486,7 +488,14 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
                sys.stderr.write("!!! Permission denied: '%s'\n" % cache_path)
                return metadata[baseurl]["data"]
 
-       filelist = dir_get_list(baseurl, conn)
+       import portage.exception
+       try:
+               filelist = dir_get_list(baseurl, conn)
+       except portage.exception.PortageException, e:
+               sys.stderr.write("!!! Error connecting to '%s'.\n" % baseurl)
+               sys.stderr.write("!!! %s\n" % str(e))
+               del e
+               return metadata[baseurl]["data"]
        tbz2list = match_in_array(filelist, suffix=".tbz2")
        metalist = match_in_array(filelist, prefix="metadata.idx")
        del filelist