For bug #180165, make portageq print a "Permission denied" error when appropriate...
authorZac Medico <zmedico@gentoo.org>
Wed, 20 Jun 2007 00:01:49 +0000 (00:01 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 20 Jun 2007 00:01:49 +0000 (00:01 -0000)
svn path=/main/trunk/; revision=6881

bin/emerge
bin/portageq
pym/portage/__init__.py
pym/portage/exception.py

index 48f327170acd7c5ec9ebad7cbaeca30953ca7dbc..0e12b173e59dc3b2b4f65b0e6eab32eb5a4c4405 100755 (executable)
@@ -13,4 +13,10 @@ except ImportError:
 
 if __name__ == "__main__":
        import sys
-       sys.exit(emerge_main())
+       from portage.exception import PermissionDenied
+       try:
+               retval = emerge_main()
+       except PermissionDenied, e:
+               sys.stderr.write("Permission denied: '%s'\n" % str(e))
+               sys.exit(e.errno)
+       sys.exit(retval)
index 968cc129a207cb438e3ba298427fd5cf53e8a489..b9260fed574610df9f210365a450ccb85e8e7af7 100755 (executable)
@@ -383,6 +383,9 @@ def main():
        except KeyError:
                usage(sys.argv)
                sys.exit(os.EX_USAGE)
+       except portage.exception.PermissionDenied, e:
+               sys.stderr.write("Permission denied: '%s'\n" % str(e))
+               sys.exit(e.errno)
 
 main()
 
index 31f2f091c7c678d3f889948e91b6d9eee234b967..f5a4893c1215f7b524d55e18c2a1a2e51357c728 100644 (file)
@@ -185,7 +185,14 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        mtime = pathstat[stat.ST_MTIME]
                else:
                        raise portage.exception.DirectoryNotFound(mypath)
-       except (IOError,OSError,portage.exception.PortageException):
+       except EnvironmentError, e:
+               if e.errno == portage.exception.PermissionDenied.errno:
+                       raise portage.exception.PermissionDenied(mypath)
+               del e
+               if EmptyOnError:
+                       return [], []
+               return None, None
+       except portage.exception.PortageException:
                if EmptyOnError:
                        return [], []
                return None, None
@@ -199,8 +206,6 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        if e.errno != errno.EACCES:
                                raise
                        del e
-                       if EmptyOnError:
-                               return [], []
                        raise portage.exception.PermissionDenied(mypath)
                ftype = []
                for x in list:
index 4be72cf965e0f3616dcf76e3c625f84cf8b65842..3d590a5638b42fa30a9b13e6a278440f6e7a8728 100644 (file)
@@ -53,6 +53,7 @@ class OperationNotPermitted(PortageException):
        """An operation was not permitted operating system"""
 
 class PermissionDenied(PortageException):
+       from errno import EACCES as errno
        """Permission denied"""
 
 class ReadOnlyFileSystem(PortageException):