oe.types.path: Use with to control file handle lifetime

(From OE-Core rev: b6e7fee68d018e5f148a7a02cf110bc210022a72)

Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ola x Nilsson
2019-10-21 12:30:27 +02:00
committed by Richard Purdie
parent 864c8d67f2
commit c4f2a115f7

View File

@@ -154,7 +154,8 @@ def path(value, relativeto='', normalize='true', mustexist='false'):
if boolean(mustexist):
try:
open(value, 'r')
with open(value, 'r'):
pass
except IOError as exc:
if exc.errno == errno.ENOENT:
raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT)))
@@ -183,4 +184,3 @@ def qemu_use_kvm(kvm, target_arch):
elif build_arch == target_arch:
use_kvm = True
return use_kvm