From 0f4ec13e11bb8abe21aba2a28547dfb9372bc377 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 21 May 2016 12:26:45 +0100 Subject: meta/scripts: python3: rename file -> open file() API doesn't exist in python 3, convert to open(). Also handle some cases where files aren't closed. Compatible with python 2.7. [Contributions from Ed and Richard] Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- meta/classes/insane.bbclass | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'meta/classes') diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 0b151c214d..116abc428b 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass @@ -177,9 +177,8 @@ def package_qa_write_error(type, error, d): logfile = d.getVar('QA_LOGFILE', True) if logfile: p = d.getVar('P', True) - f = file( logfile, "a+") - print >> f, "%s: %s [%s]" % (p, error, type) - f.close() + with open(logfile, "a+") as f: + f.write("%s: %s [%s]" % (p, error, type)) def package_qa_handle_error(error_class, error_msg, d): package_qa_write_error(error_class, error_msg, d) -- cgit 1.2.3-korg