summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/emerge8
-rwxr-xr-xbin/portageq3
-rw-r--r--pym/portage/__init__.py11
-rw-r--r--pym/portage/exception.py1
4 files changed, 19 insertions, 4 deletions
diff --git a/bin/emerge b/bin/emerge
index 48f327170..0e12b173e 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -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)
diff --git a/bin/portageq b/bin/portageq
index 968cc129a..b9260fed5 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -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()
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 31f2f091c..f5a4893c1 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -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:
diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 4be72cf96..3d590a563 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -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):