From 7f86aefa173ab452a905dffb8a00afabe43a7b08 Mon Sep 17 00:00:00 2001 From: Paul Tikken Laptop Date: Thu, 2 Sep 2021 16:32:07 +0000 Subject: [PATCH] restructure initialize database --- CveXplore/cli_cmds/db_cmds/commands.py | 6 +++--- CveXplore/database/maintenance/main_updater.py | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/CveXplore/cli_cmds/db_cmds/commands.py b/CveXplore/cli_cmds/db_cmds/commands.py index b1402650..0af8f7af 100644 --- a/CveXplore/cli_cmds/db_cmds/commands.py +++ b/CveXplore/cli_cmds/db_cmds/commands.py @@ -15,7 +15,7 @@ def update_cmd(ctx): ctx.obj["data_source"].database.update() -@db_cmd.group("populate", invoke_without_command=True, help="Populate the database") +@db_cmd.group("initialize", invoke_without_command=True, help="Initialize the database") @click.pass_context -def populate_cmd(ctx): - ctx.obj["data_source"].database.populate() +def initialize_cmd(ctx): + ctx.obj["data_source"].database.initialize() diff --git a/CveXplore/database/maintenance/main_updater.py b/CveXplore/database/maintenance/main_updater.py index 2c867b28..0b631145 100644 --- a/CveXplore/database/maintenance/main_updater.py +++ b/CveXplore/database/maintenance/main_updater.py @@ -37,14 +37,12 @@ def update(self): self.datasource.set_handlers_for_collections() - def populate(self): + def initialize(self): - for source in self.sources: - populator = source["updater"]() - populator.populate() + cpe_pop = CPEDownloads() + cpe_pop.populate() - for post in self.posts: - indexer = post["updater"]() - indexer.create_indexes() + cve_pop = CVEDownloads() + cve_pop.populate() - self.datasource.set_handlers_for_collections() + self.update()