-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_request.py
More file actions
57 lines (46 loc) · 1.8 KB
/
pull_request.py
File metadata and controls
57 lines (46 loc) · 1.8 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
from lifxlan import *
import requests
import datetime
import json
lifx = LifxLAN()
# list of lights
lights = lifx.get_lights()
bulb = lights[0]
original_power = bulb.get_power()
original_color = bulb.get_color()
bulb.set_power("on")
all_power = lifx.get_power_all_lights()
all_color = lifx.get_color_all_lights()
# ---------------------------------------------------------------------------- #
helios = "https://api.github.com/repos/WarbyParker/helios/pulls?sort=updated&direction=dsc"
response = requests.get(helios, auth=('floramjp', '*'))
response_json = response.json()
response_dict = json.dumps(response_json)
load_dict = json.loads(response_dict)
# Update initial time
print "Initialization! Current time is: " + datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
init_time = datetime.datetime.now() - datetime.timedelta(minutes=20)
while True:
for x in load_dict:
tics_time = datetime.datetime.strptime(x["updated_at"], "%Y-%m-%dT%H:%M:%SZ")
if tics_time > init_time:
# Time: UTC
tics_str = tics_time.strftime("%Y-%m-%dT%H:%M:%SZ")
print "************************************************************"
print "PR number: " + str(x["number"])
print "PR user login: " + x["user"]["login"]
print "PR title: " + x["title"]
print "PR updated_at timestamp: " + tics_str
print "************************************************************"
init_time = tics_time
# alert bulb
bulb.set_color(BLUE)
sleep(1)
bulb.set_color(original_color)
# sleep for 5 minutes
sleep(300)
response = requests.get(helios, auth=('floramjp', '*'))
response_json = response.json()
response_dict = json.dumps(response_json)
load_dict = json.loads(response_dict)
print "Current time is: " + datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")