summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/meta/cve-update-db-native.bb
diff options
context:
space:
mode:
authorChris Laplante <chris.laplante@agilent.com>2020-09-09 16:51:08 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-10 13:48:26 +0100
commitb59e0bc9fe6c6329e3c512ff6825489c7e659e38 (patch)
tree49dcdd4ce3a1fb4e6a3c0971bd86c8c948f55122 /meta/recipes-core/meta/cve-update-db-native.bb
parent9ba2f3b8c3937bb4a3376d5537774f1dbb321bef (diff)
downloadpoky-b59e0bc9fe6c6329e3c512ff6825489c7e659e38.tar.gz
cve-update-db-native: use context manager for cve_f
(From OE-Core rev: ff422652e1b5db62205fafc75ce56bb5951d478d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/meta/cve-update-db-native.bb')
-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() {
50 except OSError: 50 except OSError:
51 pass 51 pass
52 52
53 cve_f = open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a')
54
55 bb.utils.mkdirhier(db_dir) 53 bb.utils.mkdirhier(db_dir)
56 54
57 # Connect to database 55 # Connect to database
@@ -60,7 +58,7 @@ python do_populate_cve_db() {
60 58
61 initialize_db(c) 59 initialize_db(c)
62 60
63 with bb.progress.ProgressHandler(d) as ph: 61 with bb.progress.ProgressHandler(d) as ph, open(os.path.join(d.getVar("TMPDIR"), 'cve_check'), 'a') as cve_f:
64 total_years = date.today().year + 1 - YEAR_START 62 total_years = date.today().year + 1 - YEAR_START
65 for i, year in enumerate(range(YEAR_START, date.today().year + 1)): 63 for i, year in enumerate(range(YEAR_START, date.today().year + 1)):
66 ph.update((float(i + 1) / total_years) * 100) 64 ph.update((float(i + 1) / total_years) * 100)
@@ -108,7 +106,6 @@ python do_populate_cve_db() {
108 if year == date.today().year: 106 if year == date.today().year:
109 cve_f.write('CVE database update : %s\n\n' % date.today()) 107 cve_f.write('CVE database update : %s\n\n' % date.today())
110 108
111 cve_f.close()
112 conn.commit() 109 conn.commit()
113 conn.close() 110 conn.close()
114} 111}