summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2020-09-09 16:51:08 -0400
committerSteve Sakoman <steve@sakoman.com>2020-09-14 04:26:37 -1000
commitc8c307c4b28d93938887ecb1d87f6024e916c0f9 (patch)
tree643fadd637f3e934706b7033bb4d85d04ca3653c
parentf08604d27ecacfd37bd37bfaf4c76f17b8f65604 (diff)
downloadopenembedded-core-contrib-c8c307c4b28d93938887ecb1d87f6024e916c0f9.tar.gz
cve-update-db-native: use context manager for cve_f
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit ff422652e1b5db62205fafc75ce56bb5951d478d) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-core/meta/cve-update-db-native.bb5
1 files changed, 1 insertions, 4 deletions
diff --git a/meta/recipes-core/meta/cve-update-db-native.bb b/meta/recipes-core/meta/cve-update-db-native.bb
index d22b66f6c7..328f6ab364 100644
--- a/meta/recipes-core/meta/cve-update-db-native.bb
+++ b/meta/recipes-core/meta/cve-update-db-native.bb
@@ -50,8 +50,6 @@ python do_populate_cve_db() {
except OSError:
pass
- cve_f = open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a')
-
bb.utils.mkdirhier(db_dir)
# Connect to database
@@ -60,7 +58,7 @@ python do_populate_cve_db() {
initialize_db(c)
- with bb.progress.ProgressHandler(d) as ph:
+ with bb.progress.ProgressHandler(d) as ph, open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a') as cve_f:
total_years = date.today().year + 1 - YEAR_START
for i, year in enumerate(range(YEAR_START, date.today().year + 1)):
ph.update((float(i + 1) / total_years) * 100)
@@ -108,7 +106,6 @@ python do_populate_cve_db() {
if year == date.today().year:
cve_f.write('CVE database update : %s\n\n' % date.today())
- cve_f.close()
conn.commit()
conn.close()
}