-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnew_driver.py
44 lines (31 loc) · 1.37 KB
/
new_driver.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
34
35
36
37
38
39
40
41
42
43
44
import argparse
from oauth2client import tools
from google_sheets import GoogleSheets
from list_formatting import Runner
def get_input_args():
# Creates Argument Parser object named parser
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter,
parents=[tools.argparser]
)
parser.add_argument('-t', "--token", required=True, type=str, help="The TSheets token to be able to use the API")
parser.add_argument('-n', "--notification", type=int, default=0,
help="If you want to send notifications or not (0 for false, 1 for true)")
parser.add_argument("-s", '--spreadsheet_id', type=str, help="The google sheets id to paste the information to")
return parser
if __name__ == '__main__':
args = get_input_args().parse_args()
print(args.token)
print(args.notification)
formatter = Runner(args.token, "info.json")
info = formatter.run()
spreadsheet_id = formatter.info['spreadsheet_id']
if args.spreadsheet_id is not None:
spreadsheet_id = args.spreadsheet_id
google_sheets = GoogleSheets(spreadsheet_id, flags=args)
google_sheets.send_to_google_sheets(formatter)
google_sheets.open_spreadsheet()
if args.notification:
print("Sent notifications")
formatter.compose_and_send_notifications(google_sheets)