import logging import argparse import pandas as pd from task_server.globeop import download_data, upload_data from sqlalchemy import create_engine logging.basicConfig(filename='/home/share/CorpCDOs/logs/globeop.log', level=logging.INFO, format='%(asctime)s %(message)s') parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group(required=True) ## options are technically not exclusive, but we will be running them ## at different times of the day group.add_argument("-d", "--download", action="store_true", help="download reports from GlobeOp") group.add_argument("-u", "--upload", action="store_true", help="upload marks to GlobeOp") parser.add_argument("date", nargs='?', type=lambda s: pd.datetime.strptime(s, "%Y-%m-%d"), default=pd.datetime.today()) args = parser.parse_args() if args.download: download_data(args.date) elif args.upload: engine = create_engine('postgresql://dawn_user@debian/dawndb') upload_data(engine, args.date)