mirror of
https://git.yoctoproject.org/poky
synced 2026-05-08 17:19:20 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
2e91cbd12d
commit
900639c1b2
@@ -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)):
|
||||
|
||||
Reference in New Issue
Block a user