Commit a5e8081bdeb15ddcce2d3df0c82cb141101e6867

Authored by hitier
1 parent ad0b3602
Exists in rhitier-dev

New command facility

Showing 1 changed file with 31 additions and 0 deletions   Show diff stats
web/hp_cmd.py 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +from run import generate_csv_file_if_needed, init_console_logger
  2 +from datetime import datetime
  3 +import argparse
  4 +
  5 +if __name__ == "__main__":
  6 + hp_parser = argparse.ArgumentParser(prog='Descritpor',
  7 + description='description')
  8 +
  9 + hp_parser.add_argument('-clog', '--console-log', action='store_true')
  10 +
  11 + subparsers = hp_parser.add_subparsers(dest='hpcmd_name')
  12 +
  13 + csvgen_parser = subparsers.add_parser('csv_gen',
  14 + help='csv-gen help')
  15 + csvgen_parser.add_argument('-a', '--all')
  16 + csvgen_parser.add_argument('-t', '--target')
  17 + csvgen_parser.add_argument('-i', '--input')
  18 + csvgen_parser.add_argument('-b', '--begin')
  19 + csvgen_parser.add_argument('-e', '--end')
  20 +
  21 + args = hp_parser.parse_args()
  22 +
  23 + if args.console_log:
  24 + _logger = init_console_logger()
  25 + _logger.info("This is info")
  26 +
  27 + if args.hpcmd_name == 'csv_gen':
  28 + start_date = datetime.strptime(args.begin, '%Y%m%d')
  29 + stop_date = datetime.strptime(args.end, '%Y%m%d')
  30 + generate_csv_file_if_needed(args.target, args.input, start_date, stop_date)
  31 +
... ...