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

svn path=/main/branches/2.1.2/; revision=8703

pym/getbinpkg.py

index b57da2ca1fd6af717a1ac798d798862417d574e2..d20a549ed7dd7be77cc445c8d2dd0897cf54cf3d 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()
@@ -489,7 +491,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