new: Add manual ranking script.

pull/12/head
Raphaël Vinot 2019-04-09 11:32:57 +02:00
parent fd84482410
commit edb57a6e9c
2 changed files with 37 additions and 2 deletions

33
bin/manual_ranking.py Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
import logging
from dateutil.parser import parse
from datetime import timedelta
from bgpranking.libs.helpers import load_config_files
from bgpranking.ranking import Ranking
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s:%(message)s',
level=logging.DEBUG, datefmt='%I:%M:%S')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Manually force the ranking of a day or a time interval.')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-d', '--day', type=str, help='Day to rank (Format: YYYY-MM-DD).')
group.add_argument('-i', '--interval', type=str, nargs=2, help='Interval to rank (Format: YYYY-MM-DD YYYY-MM-DD).')
args = parser.parse_args()
ranking = Ranking(loglevel=logging.DEBUG)
config_files = load_config_files()
if args.day:
day = parse(args.day).date().isoformat()
ranking.rank_a_day(day, config_files)
else:
current = parse(args.interval[0]).date()
stop_date = parse(args.interval[0]).date()
while current >= stop_date:
ranking.rank_a_day(current.isoformat(), config_files)
current -= timedelta(days=1)

View File

@ -10,11 +10,13 @@ setup(
author_email='raphael.vinot@circl.lu',
maintainer='Raphaël Vinot',
url='https://github.com/D4-project/BGP-Ranking',
description='BGP Ranking, the new one..',
description='BGP Ranking, the new one.',
packages=['bgpranking'],
scripts=['bin/archiver.py', 'bin/dbinsert.py', 'bin/fetcher.py', 'bin/parser.py',
'bin/sanitizer.py', 'bin/run_backend.py', 'bin/ssfetcher.py', 'bin/start_website.py',
'bin/monitor.py', 'bin/ranking.py', 'bin/asn_descriptions.py', 'bin/start.py', 'bin/stop.py', 'bin/shutdown.py'],
'bin/monitor.py', 'bin/ranking.py', 'bin/asn_descriptions.py',
'bin/manual_ranking.py',
'bin/start.py', 'bin/stop.py', 'bin/shutdown.py'],
classifiers=[
'License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)',
'Development Status :: 3 - Alpha',