Skip to content

Commit

Permalink
new: Script to delete a feed and reimport it
Browse files Browse the repository at this point in the history
Fix #9
  • Loading branch information
Rafiot committed Sep 25, 2023
1 parent 6297163 commit 9cddba4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tools/reimport_feed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3

from vulnerabilitylookup import VulnerabilityLookup

vl = VulnerabilityLookup()


def reimport_feed():
for source in vl.get_sources():
data = input(f'Do you want to reimport {source} from scratch?\n\tIf yes, type the name of the source. Otherwise, hit enter.')
if data == source:
if vl.del_source(source):
print(f'{source} deleted.')
else:
print(f'Unable to delete {source}')
else:
print(f'*not* deleting {source}')


if __name__ == "__main__":
print('Any feed you remove with this script will be reimported from scratch next time the feeder runs.')
reimport_feed()
1 change: 1 addition & 0 deletions vulnerabilitylookup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .vulnerabilitylookup import VulnerabilityLookup
3 changes: 3 additions & 0 deletions vulnerabilitylookup/vulnerabilitylookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def get_sources(self) -> Set[str]:
last_updates = self.storage.hgetall('last_updates')
return {name for name in last_updates.keys()}

def del_source(self, source: str) -> bool:
return self.storage.hdel('last_updates', source)

def get_info(self):
last_updates = self.storage.hgetall('last_updates')

Expand Down

0 comments on commit 9cddba4

Please sign in to comment.