-
Notifications
You must be signed in to change notification settings - Fork 7
/
next_global_entry.py
executable file
·37 lines (32 loc) · 1.1 KB
/
next_global_entry.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
#!/usr/bin/env python
"""Check for Global Entry interview openings in your city."""
import sys
import datetime
import requests
from twilio.rest import Client
import config
def log(text):
"""Write a one-line log message."""
print("{dt}\t{msg}".format(
dt=datetime.datetime.now(),
msg=text))
if __name__ == '__main__':
# calculate date
now = datetime.datetime.now()
delta = datetime.timedelta(weeks=config.look_ahead_weeks)
future = now + delta
request_url = config.global_entry_query_url.format(
timestamp=future.strftime("%Y-%m-%d"))
result = requests.get(request_url).json()
cities = [o.get('city').lower() for o in result]
if config.search_string.lower() in cities:
client = Client(config.twilio_account, config.twilio_token)
message = client.messages.create(
to=config.to_number,
from_=config.twilio_from_number,
body="Global Entry interview opportunity in {} \
opened up just now!".format(config.search_string))
log("text message sent")
sys.exit(0)
log("no news")
sys.exit(1)