Wrap more exceptions in ensure_dirs().
authorZac Medico <zmedico@gentoo.org>
Mon, 12 Jun 2006 00:13:46 +0000 (00:13 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 12 Jun 2006 00:13:46 +0000 (00:13 -0000)
svn path=/main/trunk/; revision=3494

pym/portage_util.py

index e9e84e72d4dc0a275531ae82c221473690bbe380..b08187ad41c454e3e1d06c23dd402d3f51d255e2 100644 (file)
@@ -3,6 +3,7 @@
 # $Id$
 
 from portage_exception import PortageException, FileNotFound, OperationNotPermitted, ReadOnlyFileSystem
+import portage_exception
 
 import sys,string,shlex,os,errno
 try:
@@ -722,10 +723,15 @@ def ensure_dirs(dir_path, *args, **kwargs):
                os.makedirs(dir_path)
                created_dir = True
        except OSError, oe:
+               func_call = "makedirs('%s')" % dir_path
                if errno.EEXIST == oe.errno:
                        pass
-               elif  oe.errno in (errno.EPERM, errno.EROFS):
-                       raise portage_exception.OperationNotPermitted(str(oe))
+               elif oe.errno == errno.EPERM:
+                       raise OperationNotPermitted(func_call)
+               elif oe.errno == errno.EACCES:
+                       raise PermissionDenied(func_call)
+               elif oe.errno == errno.EROFS:
+                       raise ReadOnlyFileSystem(func_call)
                else:
                        raise
        perms_modified = apply_permissions(dir_path, *args, **kwargs)