diff options
author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2015-10-19 21:38:42 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-21 22:56:05 +0100 |
commit | 900639c1b29cfca777ba78da1c413eb71c392978 (patch) | |
tree | a1393dd80572b6761c08ff24ce9dcb5a2917e1cf | |
parent | 2e91cbd12ddf5f65e914bd7fec36cfee23694a77 (diff) | |
download | poky-900639c1b29cfca777ba78da1c413eb71c392978.tar.gz |
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]
(From OE-Core rev: 1136f9e02d9cbe2c2cda189321d72b763649ba42)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/utils/ftools.py | 11 |
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 @@ | |||
1 | import os | 1 | import os |
2 | import re | 2 | import re |
3 | import errno | ||
3 | 4 | ||
4 | def write_file(path, data): | 5 | def write_file(path, data): |
5 | wdata = data.rstrip() + "\n" | 6 | wdata = data.rstrip() + "\n" |
@@ -18,7 +19,15 @@ def read_file(path): | |||
18 | return data | 19 | return data |
19 | 20 | ||
20 | def remove_from_file(path, data): | 21 | def remove_from_file(path, data): |
21 | lines = read_file(path).splitlines() | 22 | try: |
23 | rdata = read_file(path) | ||
24 | except IOError as e: | ||
25 | # if file does not exit, just quit, otherwise raise an exception | ||
26 | if e.errno == errno.ENOENT: | ||
27 | return | ||
28 | else: | ||
29 | raise | ||
30 | lines = rdata.splitlines() | ||
22 | rmdata = data.strip().splitlines() | 31 | rmdata = data.strip().splitlines() |
23 | for l in rmdata: | 32 | for l in rmdata: |
24 | for c in range(0, lines.count(l)): | 33 | for c in range(0, lines.count(l)): |