summaryrefslogtreecommitdiff
path: root/yocto-poky/meta/lib/oeqa/utils/ftools.py
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/meta/lib/oeqa/utils/ftools.py')
-rw-r--r--yocto-poky/meta/lib/oeqa/utils/ftools.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/yocto-poky/meta/lib/oeqa/utils/ftools.py b/yocto-poky/meta/lib/oeqa/utils/ftools.py
index 64ebe3d21..1bd9a30a4 100644
--- a/yocto-poky/meta/lib/oeqa/utils/ftools.py
+++ b/yocto-poky/meta/lib/oeqa/utils/ftools.py
@@ -1,12 +1,19 @@
import os
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)
@@ -18,7 +25,18 @@ def read_file(path):
return data
def remove_from_file(path, data):
- lines = read_file(path).splitlines()
+ # In case data is None, return immediately
+ if data is None:
+ return
+ try:
+ rdata = read_file(path)
+ except IOError as e:
+ # if file does not exit, just quit, otherwise raise an exception
+ if e.errno == errno.ENOENT:
+ return
+ else:
+ raise
+ lines = rdata.splitlines()
rmdata = data.strip().splitlines()
for l in rmdata:
for c in range(0, lines.count(l)):