Bug #192298 - Handle PermissionDenied error in cache.update_eclasses().
authorZac Medico <zmedico@gentoo.org>
Wed, 12 Sep 2007 14:59:04 +0000 (14:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 12 Sep 2007 14:59:04 +0000 (14:59 -0000)
svn path=/main/trunk/; revision=7769

pym/portage/eclass_cache.py

index 5a0d3c3ad0d2a48ce653b827e96d71dbc8274fbf..6e4eebd185115a3da64dfe10576b3c133173b761 100644 (file)
@@ -4,8 +4,9 @@
 # $Id$
 
 from portage.util import normalize_path, writemsg
-import os, sys
+import errno, os, sys
 from portage.data import portage_gid
+from portage.exception import PermissionDenied
 
 class cache(object):
        """
@@ -44,7 +45,19 @@ class cache(object):
                for x in [normalize_path(os.path.join(y,"eclass")) for y in self.porttrees]:
                        if not os.path.isdir(x):
                                continue
-                       for y in [y for y in os.listdir(x) if y.endswith(".eclass")]:
+                       eclass_filenames = []
+                       try:
+                               for y in os.listdir(x):
+                                       if y.endswith(".eclass"):
+                                               eclass_filenames.append(y)
+                       except OSError, e:
+                               if e.errno == errno.ENOENT:
+                                       del e
+                                       continue
+                               elif e.errno == PermissionDenied.errno:
+                                       raise PermissionDenied(x)
+                               raise
+                       for y in eclass_filenames:
                                try:
                                        mtime = long(os.stat(os.path.join(x, y)).st_mtime)
                                except OSError: