def create_task(): #hardcoded. DEFINE the post request to trigger this function task_type = "wake_up" user_id = 'John' timestamp_wake_up = "123456" if task_type == "wake_up": job_name ="wake_up_classify.py" schedule_job(job_name, user_id=user_id, schedule_timestamp=timestamp_wake_up)
Notifications.sendNotifications_toParse("") def send_alarm(raw_data,event_type): print "sending alarm to caregiver" Notifications.sendNotifications_toTwilio('9198154800',"9198154800") def should_send_alarm(): print "checking response status" status = Notifications.getRespondedStatus() if status==False: send_alarm("", "") def should_schedule_for_next_day(): return False if __name__ == '__main__': #trigger model parser = __make_opt_parser() (options,args) = parser.parse_args() ts = time.time() event_type =args[1] raw_data = {"user_id":args[0],"timestamp":ts} #send_question("", "") if should_send_question(raw_data,event_type): send_question(raw_data,event_type) t = Timer(60*1/12, should_send_alarm) #after 15 mins t.start() if should_schedule_for_next_day(): schedule_job("wake_up_classify", args[0], ts+24*60*60*1000) #print "done"