def api(self): input_json = cherrypy.request.json print input_json try: s = WakeupInfo("wakeup_info.json", [], [], "", "", "") s.refresh() if "arrivalTime" in input_json.keys(): s.time = input_json["arrivalTime"].encode("ascii", "ignore") if "breakfastTime" in input_json.keys(): s.brekfast_time = input_json["breakfastTime"].encode("ascii", "ignore") s.save() except: print "API key time Error" else: print "Time updated! {0} and {1}".format(s.time, s.brekfast_time) if "alarmStatus" in input_json.keys(): if input_json["alarmStatus"] == "silence": self.silence = True if "url" in input_json.keys(): self.phone_url = input_json["url"] print "URL updated!" return "Hello. This is our API"
def register_wakeup_time(self, origins, destinations, time, brekfast_time): global weather_and_traffic weather_and_traffic = get_weather_and_traffic() s = WakeupInfo("wakeup_info.json", origins, destinations, time, 0, brekfast_time) routing_info = self.get_routing_info(s.origins, s.destinations) print (routing_info) estimating_time = routing_info["rows"][0]["elements"][0]["duration"]["value"] s.estimating_time = timediff_to_humantime(estimating_time) status = s.save() if status == True: return "1" else: return "0"