-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9df70e6
commit 650cb20
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import requests | ||
import json | ||
import urllib2 | ||
|
||
bet_url = "http://google.co.uk" | ||
print "checking altitude is more than 29500m...\n" | ||
triggered = False # boolean to prevent duplicating bet | ||
altitude_json_link = "http://habitat.habhub.org/habitat/_design/ept/_list/json/payload_telemetry/payload_time?include_docs=true&startkey=[%227830c4b51e021511a9bb8ff5dc1df89a%22]&endkey=[%227830c4b51e021511a9bb8ff5dc1df89a%22,[]]&fields=altitude" # altitude link from Habitat | ||
trigger_json_link = "http://habitat.habhub.org/habitat/_design/ept/_list/json/payload_telemetry/payload_time?include_docs=true&startkey=[%227830c4b51e021511a9bb8ff5dc1df89a%22]&endkey=[%227830c4b51e021511a9bb8ff5dc1df89a%22,[]]&fields=trigger" # trigger link from Habitat | ||
|
||
while True: # forever | ||
|
||
r = requests.get(altitude_json_link) # get the JSON information | ||
altitude = float(r.json()[-1]["altitude"]) # parse altitude to get a float | ||
print "The altitude is: " + str(altitude) # print altitude | ||
|
||
r = requests.get(trigger_json_link) # get the JSON information | ||
trigger = str(r.json()[-1]["trigger"]) # parse trigger | ||
print "The trigger is: " + trigger # print trigger | ||
|
||
if altitude >= 29500 and trigger == "True" and triggered == False: # if altitude = 29500m and altitude hasn't already been reached | ||
response = urllib2.urlopen(bet_url) | ||
print response.info() | ||
|
||
|
||
|
||
print "Bet Placed! Exiting..." | ||
triggered = True | ||
break |