-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
31 lines (27 loc) · 1.18 KB
/
manage.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
#!/usr/bin/env python
import argparse
from utils.commands import clean_desc, collect_data, init, push, report
# Parse arguments
parser = argparse.ArgumentParser(description="My example explanation")
parser.add_argument("command", type=str, help="what do you want? you can: report/push/init")
parser.add_argument("-c", "--coeff", type=float, help="coefficient for every time entry")
parser.add_argument("-t", "--target", type=float, help="total time entry")
my_namespace = parser.parse_args()
# Validate arguments
if my_namespace.coeff and my_namespace.target:
raise Exception("Укажите максимум одно значение")
elif (my_namespace.coeff and my_namespace.coeff <= 0) or (my_namespace.target and my_namespace.target <= 0):
raise Exception("Значение должно быть положительным")
# Work
collect_data(coeff=my_namespace.coeff, target=my_namespace.target)
if my_namespace.command == "init":
init()
elif my_namespace.command == "clean":
clean_desc()
elif my_namespace.command == "report":
report()
elif my_namespace.command == "push":
report()
push()
else:
raise Exception("Unknown command. Use 'dc exec app ./manage.py -h'")