summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-09-26 17:03:18 +0000
committerZac Medico <zmedico@gentoo.org>2007-09-26 17:03:18 +0000
commit432d0a083f8e8ba27687f177393cbb38bbc7d54d (patch)
tree397e11d4b200b2a045039fd1826876a7c111f527 /pym
parentc90c13bbbb1f6a4d7262c922b1413dadbf09eb5b (diff)
downloadportage-432d0a083f8e8ba27687f177393cbb38bbc7d54d.tar.gz
portage-432d0a083f8e8ba27687f177393cbb38bbc7d54d.tar.bz2
portage-432d0a083f8e8ba27687f177393cbb38bbc7d54d.zip
Bug #192341 - When the chflags command does not exit successfully,
try to generate an informative error. First, use stat or lstat to try and generate an ENOENT error. It the path exists, verify that the chflags binary exists and raise CommandNotFound if necessary. Finally, simply generate an EPERM OSError with the output of the command since we're not sure exactly why it failed or what the real errno was. svn path=/main/trunk/; revision=7834
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/__init__.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index db377fda5..7a2fa0855 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -47,11 +47,20 @@ if os.uname()[0] in ["FreeBSD"]:
def _chflags(path, flags, opts=""):
cmd = "chflags %s %o '%s'" % (opts, flags, path)
status, output = commands.getstatusoutput(cmd)
- retval = os.WEXITSTATUS(status)
- if os.WIFEXITED(status) and retval == os.EX_OK:
+ if os.WIFEXITED(status) and os.WEXITSTATUS(status) == os.EX_OK:
return
- e = OSError(retval, output)
- e.errno = retval
+ # Try to generate an ENOENT error if appropriate.
+ if "h" in opts:
+ os.lstat(path)
+ else:
+ os.stat(path)
+ # Make sure the binary exists.
+ if not portage.process.find_binary("chflags"):
+ raise portage.exception.CommandNotFound("chflags")
+ # Now we're not sure exactly why it failed or what
+ # the real errno was, so just report EPERM.
+ e = OSError(errno.EPERM, output)
+ e.errno = errno.EPERM
e.filename = path
e.message = output
raise e