Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions rss2email/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ def run(feeds, args):
finally:
feeds.save()

def cleandb(feeds, args):
"Keep only last seen entries in the database"
args.send = False
if not args.index:
args.index = range(len(feeds))
try:
for index in args.index:
feed = feeds.index(index)
_LOG.info('resetting feed {}'.format(feed))
feed.reset()
try:
feed.run(send=args.send)
except _error.RSS2EmailError as e:
e.log()
finally:
feeds.save()

def list(feeds, args):
"List all the feeds in the database"
for i,feed in enumerate(feeds):
Expand Down
7 changes: 7 additions & 0 deletions rss2email/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def run(*args, **kwargs):
'email', nargs='?',
help='target email for the new feed')

cleandb_parser = subparsers.add_parser(
'cleandb', help=_command.cleandb.__doc__.splitlines()[0])
cleandb_parser.set_defaults(func=_command.cleandb)
cleandb_parser.add_argument(
'index', nargs='*',
help='feeds to clean in the database (defaults to cleaning all feeds)')

run_parser = subparsers.add_parser(
'run', help=_command.run.__doc__.splitlines()[0])
run_parser.set_defaults(func=_command.run)
Expand Down