From: Leonardo Sandoval <leonardo.sandoval.gonza...@linux.intel.com> 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.gonza...@linux.intel.com> --- meta/lib/oeqa/utils/ftools.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py index 64ebe3d..1ec8a09 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)): -- 1.8.4.5 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core