diff --git a/web/hp_cmd.py b/web/hp_cmd.py index 0693c60..be038d0 100644 --- a/web/hp_cmd.py +++ b/web/hp_cmd.py @@ -1,4 +1,6 @@ -from run import generate_csv_file_if_needed, init_console_logger +import sys + +from run import generate_csv_file_if_needed, init_console_logger, config from datetime import datetime import argparse @@ -7,12 +9,13 @@ if __name__ == "__main__": description='description') hp_parser.add_argument('-clog', '--console-log', action='store_true') + hp_parser.add_argument('-s', '--dry-run', action='store_true') subparsers = hp_parser.add_subparsers(dest='hpcmd_name') csvgen_parser = subparsers.add_parser('csv_gen', help='csv-gen help') - csvgen_parser.add_argument('-a', '--all') + csvgen_parser.add_argument('-a', '--all', action='store_true') csvgen_parser.add_argument('-t', '--target') csvgen_parser.add_argument('-i', '--input') csvgen_parser.add_argument('-b', '--begin') @@ -22,10 +25,22 @@ if __name__ == "__main__": if args.console_log: _logger = init_console_logger() - _logger.info("This is info") if args.hpcmd_name == 'csv_gen': + # todo: build default dates in not -b or -e start_date = datetime.strptime(args.begin, '%Y%m%d') stop_date = datetime.strptime(args.end, '%Y%m%d') - generate_csv_file_if_needed(args.target, args.input, start_date, stop_date) - + if args.all: + # build the {target_slug: [input list]} dictionnary from config.yaml + targets = {t['slug']: list(t['models'].keys()) for t in config['targets']} + else: + # todo: check -i an -t + targets = {args.target: [args.input]} + + for _t, _i_list in targets.items(): + # print(_t, _i_list) + for _i in _i_list: + print(f"generating csv for {_t}/ {_i}") + if args.dry_run: + continue + generate_csv_file_if_needed(_t, _i, start_date, stop_date) -- libgit2 0.21.2