Skip to content

Commit

Permalink
added download sources reset function
Browse files Browse the repository at this point in the history
  • Loading branch information
P-T-I committed Apr 10, 2024
1 parent ec5a1dc commit 745ea6e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CveXplore/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.24.dev6
0.3.24.dev9
3 changes: 1 addition & 2 deletions CveXplore/cli_cmds/db_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def reset_cmd(ctx):

sources = config.DEFAULT_SOURCES

with open(os.path.join(config.USER_HOME_DIR, ".sources.ini"), "w") as f:
f.write(json.dumps(sources))
ctx.obj["data_source"].database.reset_download_sources_to_default()

printer(input_data=[{"SOURCES RESET TO": sources}])
11 changes: 10 additions & 1 deletion CveXplore/core/database_maintenance/main_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Main Updater
============
"""

import json
import logging
import os
import time
from datetime import timedelta

Expand Down Expand Up @@ -61,6 +62,14 @@ def __repr__(self):
def validate_schema(self):
return self.schema_checker.validate_schema()

def reset_download_sources_to_default(self):
sources = self.config.DEFAULT_SOURCES

with open(os.path.join(self.config.USER_HOME_DIR, ".sources.ini"), "w") as f:
f.write(json.dumps(sources))

return True

def update(self, update_source: str | list = None):
"""
Method used for updating the database
Expand Down
6 changes: 3 additions & 3 deletions CveXplore/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def __init__(self, **kwargs):
"Missing datasource_connection_details for selected datasource ('api')"
)
elif self.datasource_type == "api":
self.datasource_connection_details["user_agent"] = (
f"CveXplore:{self.version}"
)
self.datasource_connection_details[
"user_agent"
] = f"CveXplore:{self.version}"

if (
self.mongodb_connection_details is not None
Expand Down

0 comments on commit 745ea6e

Please sign in to comment.