Created
August 8, 2017 19:37
-
-
Save Evantm/4d4b7890dc07627a4612da4514fdbe3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
report = {} | |
worksheet = None | |
if (len(list_of_dicts) == 0): | |
report["value1"] = ('No elements') | |
else: | |
# 0 Monday | |
# 1 Tuesday | |
# 2 Wednesday | |
# 3 Thursday | |
# 4 Friday | |
# 5 Saturday | |
# 6 Sunday | |
today = datetime.now().today().weekday() | |
if(today < 4): | |
start = time(8,00) | |
end = time(18,00) | |
elif(today == 4): | |
start = time(9,30) | |
end = time(17,00) | |
else:#if chainging cause python doesnt have switch. Add more to customize cl osing times | |
avg = -1 | |
d = datetime.now() | |
timestamp = datetime.time(d) | |
avg = float('%.2f' % (avg / len(list_of_dicts))) # math to find average to two decimal places | |
if worksheet is None: | |
worksheet = login_open_sheet(GDOCS_OAUTH_JSON, GDOCS_SPREADSHEET_NAME) | |
# Append the data in the spreadsheet, including a timestamp | |
try: | |
start = time(16,30) | |
end = time (18,30) | |
if (timestamp < start or timestamp > end): | |
avg = -1 | |
curr = datetime.combine(datetime.date(d.today()), timestamp) | |
worksheet.append_row((curr.strftime("%Y-%m-%d %H:%M"), math.ceil(avg), l en(total))) | |
except Exception as E: | |
# Error appending data, most likely because credentials are stale. | |
print(E) | |
worksheet = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment