-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
45 lines (36 loc) · 1.47 KB
/
run.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
45
import time
import datetime
from pyminder.pyminder import Pyminder
def main():
break_start = datetime.datetime(2019,12,23)
break_end = datetime.datetime(2019,12,28)
enable_breaks(break_start, break_end)
def token():
return open("token.secret").read()
def enable_breaks(break_start, break_end):
pyminder = Pyminder(user='[your username - dummy field]', token=token())
goals = pyminder.get_goals()
print("Hello,")
print("")
print("Sadly, it is too late for me to enable a break manually.")
print("I need to request a manual break override - from ", break_start.date(), "to", break_end.date(), "for following goals:")
print("")
for goal in goals:
# Goal objects expose all API data as dynamic properties.
# http://api.beeminder.com/#attributes-2
# https://stackoverflow.com/a/46090618/4130619
ep = datetime.datetime(1970,1,1,0,0,0)
x = (break_end - ep).total_seconds()
needed = goal.get_needed(x)
if needed > 0:
print(goal.slug)
#print(goal.title)
#print(goal.fineprint)
#print(goal.losedate) # unix timestamp
# Goal objects also implement a handful of helper functions.
# Note: These functions probably contain bugs! Issues & pull requests welcome.
# https://github.com/narthur/pyminder/blob/master/pyminder/goal.py
now = time.time()
sum_ = goal.get_data_sum(now)
needed = goal.get_needed(now)
main()