cve-update-db-native: use context manager for cve_f

(From OE-Core rev: c8c307c4b28d93938887ecb1d87f6024e916c0f9)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit ff422652e1b5db62205fafc75ce56bb5951d478d)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Chris Laplante
2020-09-09 16:51:08 -04:00
committed by Richard Purdie
parent ed69955083
commit 738fe904c7

View File

@@ -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()
}