summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2015-10-19 21:38:42 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-21 22:52:40 +0100
commit1136f9e02d9cbe2c2cda189321d72b763649ba42 (patch)
tree845f5c49efb4f91065427b0d9b527ec1e0a5df02
parentaed5b7aef33459f1bb5fa29560920c254a5fd637 (diff)
downloadopenembedded-core-1136f9e02d9cbe2c2cda189321d72b763649ba42.tar.gz
openembedded-core-1136f9e02d9cbe2c2cda189321d72b763649ba42.tar.bz2
openembedded-core-1136f9e02d9cbe2c2cda189321d72b763649ba42.zip
oeqa/utils/ftools: Ignore the exception if file does not exist
There may be cases where the configuration file (path) does not exist, thus the remove_from_file should catch this exception. In case the exception is not the latter (errno.ENOENT), then re-raise it. [YOCTO #8540] Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta/lib/oeqa/utils/ftools.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py
index 64ebe3d217..1ec8a0948f 100644
--- a/meta/lib/oeqa/utils/ftools.py
+++ b/meta/lib/oeqa/utils/ftools.py
@@ -1,5 +1,6 @@
import os
import re
+import errno
def write_file(path, data):
wdata = data.rstrip() + "\n"
@@ -18,7 +19,15 @@ def read_file(path):
return data
def remove_from_file(path, data):
- lines = read_file(path).splitlines()
+ 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)):