aboutsummaryrefslogtreecommitdiffstats
path: root/python/task_server/__main__.py
blob: 72754733a8d5d026df8794b926004f29887b034a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import logging
import argparse
import datetime
import os
from .globeop import download_data, upload_data
from sqlalchemy import create_engine

logging.basicConfig(filename=os.path.join(os.environ["LOG_DIR"], '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: datetime.datetime.strptime(s, "%Y-%m-%d"),
                    default=datetime.datetime.today())
args = parser.parse_args()

if args.download:
    download_data(args.date.date())
elif args.upload:
    engine = create_engine('postgresql://dawn_user@debian/dawndb')
    upload_data(engine, args.date)