-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiaper.py
More file actions
26 lines (26 loc) · 902 Bytes
/
diaper.py
File metadata and controls
26 lines (26 loc) · 902 Bytes
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
#!/usr/bin/python
import gspread
import sys
import time
import datetime
from datetime import datetime
#toadd=sys.argv
#toadd.pop(0)
#mydate=sys.argv[0]
#buttonname=sys.argv[1]
from oauth2client.service_account import ServiceAccountCredentials
scope = "https://spreadsheets.google.com/feeds"
credentials = ServiceAccountCredentials.from_json_keyfile_name('/root/bin/credentials.json', scope)
gs = gspread.authorize(credentials)
gsheet = gs.open("testsheet")
wsheet = gsheet.worksheet("DiaperChange")
curtime=sys.argv[1]
diapertype=sys.argv[2]
curyear = str(datetime.now().year)
curtime = datetime.strptime(curtime + ' ' + curyear,'%b %d %H:%M:%S %Y' )# 7/9/2017 17:28:46
if diapertype == 'wet':
wsheet.insert_row([curtime.strftime('%m/%d/%Y %H:%M:%S'),'WET'],index=2)
print "WET DIAPER"
else:
wsheet.insert_row([curtime.strftime('%m/%d/%Y %H:%M:%S'),'SOILED'],index=2)
print "SOILED DIAPER"