summaryrefslogtreecommitdiffstats
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-17 12:51:24 +0100
commit738fe904c7d2ed0c4f1c57fa0b153c173d80c4cd (patch)
treef0e4e04b874910a5153cb18dcf2d4ae86a997ad3
parented6995508336f294f226b494e156b7a77f5c3e60 (diff)
downloadpoky-738fe904c7d2ed0c4f1c57fa0b153c173d80c4cd.tar.gz
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>
-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}