aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-10-16 14:41:02 -0400
committerMike Frysinger <vapier@gentoo.org>2013-10-16 16:33:01 -0400
commitfbe5409a3bebeee9c729a21e2c88a3f93c26e992 (patch)
tree603ee7825f2682b039cc30cc9b7c2a3657a802bf /pym/portage/util/movefile.py
parenthelper-functions.sh: sync with multiprocessing.eclass (diff)
downloadportage-fbe5409a3bebeee9c729a21e2c88a3f93c26e992.tar.gz
portage-fbe5409a3bebeee9c729a21e2c88a3f93c26e992.tar.bz2
portage-fbe5409a3bebeee9c729a21e2c88a3f93c26e992.zip
movefile: simplify xattr fallback logic
The "with open()" construct handles exceptions just fine.
Diffstat (limited to 'pym/portage/util/movefile.py')
-rw-r--r--pym/portage/util/movefile.py10
1 files changed, 3 insertions, 7 deletions
diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py
index 65d81c6bb..4f158cd00 100644
--- a/pym/portage/util/movefile.py
+++ b/pym/portage/util/movefile.py
@@ -128,15 +128,11 @@ else:
"does not support extended attribute '%s'") %
(_unicode_decode(dest), _unicode_decode(attr)))
else:
- _devnull = open("/dev/null", "wb")
try:
- subprocess.call(["getfattr", "--version"], stdout=_devnull)
- subprocess.call(["setfattr", "--version"], stdout=_devnull)
- _has_getfattr_and_setfattr = True
+ with open(os.devnull, 'wb') as f:
+ subprocess.call(["getfattr", "--version"], stdout=f)
+ subprocess.call(["setfattr", "--version"], stdout=f)
except OSError:
- _has_getfattr_and_setfattr = False
- _devnull.close()
- if _has_getfattr_and_setfattr:
def _copyxattr(src, dest, exclude=None):
# TODO: implement exclude
getfattr_process = subprocess.Popen(["getfattr", "-d", "--absolute-names", src], stdout=subprocess.PIPE)