Skip to content

Commit 6507c8b

Browse files
committed
FIXED: bug
1 parent f7e3c3b commit 6507c8b

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

cve.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ def __init__(self, db):
1616
self.host = db.host
1717
self.password = db.password
1818
self.cur = db.cur
19-
if self.database is not None:
20-
self.use_database(self.database)
19+
self.execption_list = {}
2120
else:
2221
raise TypeInstanceException("The variable 'db' is not instance of MySqlBase")
2322

cvemysql.py

+14
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,20 @@ def help(error=None):
271271
if year_based_task:
272272
for year in list_year:
273273
export_filepath.append(configure_task(base, table_name, year, filename, file_path))
274+
275+
if len(base.execption_list) != 0:
276+
filename = "err-{time}.log".format(time=datetime.now()).replace(" ", "").replace(":", ".")
277+
current_key = list(base.execption_list.keys())
278+
with open(filename, 'w+', encoding='utf-8') as fs:
279+
for ex in current_key:
280+
for v in list(base.execption_list.get(ex)):
281+
if isinstance(v, str) and re.compile("CVE-.").match(v):
282+
value = v
283+
fs.write("실패: Column에 값을 넣을 수 없습니다. -> {cve} | Reason: {r}\n".format(cve=v, r=ex))
284+
break
285+
fs.close()
286+
print("\n경고: {count} elements could not be inserted into the table. See {f} for more reasons.".format(count=len(base.execption_list), f=filename))
287+
base.execption_list.clear()
274288
else:
275289
export_filepath.append(configure_task(base, table_name, None, filename, file_path))
276290

nvdnist.py

-17
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
NVD_NIST_JSON_URL = 'https://nvd.nist.gov/feeds/json/cve/1.0/'
2121
NVD_NIST_XML_URL = 'https://nvd.nist.gov/feeds/xml/cve/2.0/'
2222

23-
execption_list = {}
24-
2523
class ThreadList:
2624
def __init__(self, process):
2725
self._entry = 0
@@ -409,21 +407,6 @@ def table_insert(self, tablename, jsonCollection):
409407
time.sleep(0.1)
410408
except (KeyboardInterrupt, SystemExit):
411409
sys.exit(-1)
412-
413-
414-
if len(execption_list) != 0:
415-
filename = "err-{time}.log".format(time=datetime.now()).replace(" ", "").replace(":", ".")
416-
current_key = list(execption_list.keys())
417-
with open(filename, 'w+', encoding='utf-8') as fs:
418-
for ex in current_key:
419-
for v in list(execption_list.get(ex)):
420-
if isinstance(v, str) and re.compile("CVE-.").match(v):
421-
value = v
422-
fs.write("실패: Column에 값을 넣을 수 없습니다. -> {cve} | Reason: {r}\n".format(cve=v, r=ex))
423-
break
424-
fs.close()
425-
print("\n경고: {count} elements could not be inserted into the table. See {f} for more reasons.".format(count=len(execption_list), f=filename))
426-
xecption_list.clear()
427410

428411
print("\nAll data has been inserted.")
429412

0 commit comments

Comments
 (0)