-
Notifications
You must be signed in to change notification settings - Fork 43
/
main.py
33 lines (30 loc) · 1.37 KB
/
main.py
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
29
30
31
32
33
from logzero import logger, logfile
import argparse
import sys
from dhis2 import is_valid_uid
# setup the logger
logfile("./dummyDataTracker.log")
if __name__ == '__main__':
my_parser = argparse.ArgumentParser(description='Create dummy data flat file in Google Spreadsheets')
my_parser.add_argument('Program_UID', metavar='program_uid', type=str,
help='the uid of the program to use')
my_parser.add_argument('--with_teis_from_ou', action="store", dest="OrgUnit", type=str)
my_parser.add_argument('--stage_repeat', action="append", metavar=('stage_uid', 'number_repeats'), nargs=2)
args = my_parser.parse_args()
program_uid = args.Program_UID
if not is_valid_uid(program_uid):
print('The program uid specified is not valid')
sys.exit()
if args.OrgUnit is not None and not is_valid_uid(args.OrgUnit ):
print('The orgunit uid specified is not valid')
sys.exit()
if args.stage_repeat is not None and len(args.stage_repeat) > 0:
for param in args.stage_repeat:
if not is_valid_uid(param[0]):
print('The program stage uid specified ' + param[0] + ' is not valid')
sys.exit()
try:
int(param[1])
except ValueError:
print('The repetition value ' + param[1] + ' is not an integer')
sys.exit()