]> code.ossystems Code Review - openembedded-core.git/commitdiff
oeqa/utils/ftools: From functions that expect data, check if None
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Mon, 19 Oct 2015 21:38:43 +0000 (21:38 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 21 Oct 2015 21:54:56 +0000 (22:54 +0100)
ftools functions that expect data may get 'None'; this patch does this check
and return immediately if this is the case.

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/lib/oeqa/utils/ftools.py

index 1ec8a0948f0d71da816b55c6d2f4e37c4480e8cd..1bd9a30a4044d07321233af2965e0ae4fb50ba18 100644 (file)
@@ -3,11 +3,17 @@ import re
 import errno
 
 def write_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     wdata = data.rstrip() + "\n"
     with open(path, "w") as f:
         f.write(wdata)
 
 def append_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     wdata = data.rstrip() + "\n"
     with open(path, "a") as f:
             f.write(wdata)
@@ -19,6 +25,9 @@ def read_file(path):
     return data
 
 def remove_from_file(path, data):
+    # In case data is None, return immediately
+    if data is None:
+        return
     try:
         rdata = read_file(path)
     except IOError as e: