def main(): #print "Starting.... %s"%(strftime("%Y-%m-%d %H:%M:%S", gmtime())) # use GPS data for message coords = GpsData.getCoords() lat = str(coords['lat']) lon = str(coords['lon']) utc = str(coords['utc']) url = 'http://maps.google.com/maps?f=q&q=%s,%s' % (lat, lon) #msg = MIMEText(u'SITA Notification -- my location: '+url+' ('+utc+')') msg = 'SITA Notification -- my location: ' + url + ' (' + utc + ')' #msg = 'SITA Notification -- my location: '+url+' ('+strftime("%Y-%m-%d %H:%M:%S", gmtime())+')' # set up recipients # get recipients from SIM card or props file from /boot/phonebook.properties phonebook = [] phonebook = Sms.phonebook() if phonebook == []: # if no numbers on SIM card, check properties file filepath = '/boot/phonebook.properties' with open(filepath) as fp: line = fp.readline().replace('\r', '').replace('\n', '') if line != '': phonebook.append(line) while line: line = fp.readline().replace('\r', '').replace('\n', '') if line != '': phonebook.append(line) # broadcast location twice for addr in phonebook: Sms.sendsms(addr, msg) sleep(2) sleep(30) for addr in phonebook: Sms.sendsms(addr, msg) sleep(2)
def post(self): #try: #print self.request.body root = ET.fromstring(self.request.body) if root.find('result_code').text == 'SUCCESS': o_id = ObjectId(root.find('attach').text) order = DB.AccOrder.find_one({'_id':o_id}) msgs = [] user = DB.WechatUser.find_one({'_id':order['u_id']}) jmsg = {"t":order['h_ln'], "h":"order_payed"} msgs.append(jmsg) order['d_p'] = datetime.datetime.utcnow() order['u_pay'] = str(float(root.find('cash_fee').text)/100) order['u_payt'] = root.find('fee_type').text order['u_pn'] = user['phone'] DB.PayedOrder.insert_one(order) oid = str(order['_id']) hotelname = order['h_na'] art = datetime.datetime.now()+datetime.timedelta(0,3600) roomtype = order['h_r'] hprice = order['h_p'] cname = user['nickname'] cphone = user['phone'] DB.AccOrder.delete_one({'_id':o_id}) #发送邮件 mailto_list=order['h_em'] sub = "订单确认-"+oid data = { "oid":oid, "hotel":hotelname, "date":art.strftime('%x'), "time":art.strftime('%X'), "roomtype":roomtype, "price":hprice, "cname":cname, "cphone":cphone, "leave":"第二天中午", "tdate":"()", "rtime":"()", "compen":"100", } if send_booking_mail(mailto_list, sub, data): #print "发送成功" pass else: #print "发送失败" pass #发送短消息 sendsms(cphone,hotelname,roomtype,hprice) #返回post执行结果 self.finish('SUCCESS') else: self.finish('SUCCESS')
def webhooks(): # Get the json data json = request.json # parse the message id, person id, person email, and room id message_id = json["data"]["id"] person_id = json["data"]["personId"] person_email = json["data"]["personEmail"] room_id = json["data"]["roomId"] # convert the message id into readable text msg = message.retrieve(message_id) #send SMS sms.sendsms(msg)
def sendmsg(): import sms status = sms.sendsms(name) #video_capture.release() #cv2.destroyAllWindows() if (status == True): print("Criminal Found")
# Display the results for (top, right, bottom, left), name in zip(face_locations, face_names): # Scale back up face locations since the frame we detected in was scaled to 1/4 size top *= 4 right *= 4 bottom *= 4 left *= 4 # Draw a box around the face cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2) # Draw a label with a name below the face cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED) font = cv2.FONT_HERSHEY_DUPLEX cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1) # Display the resulting image cv2.imshow('Video', frame) # Hit 'q' on the keyboard to quit! if cv2.waitKey(1) & 0xFF == ord('q'): break # Release handle to the webcam import sms sms.sendsms(name) video_capture.release() cv2.destroyAllWindows()
import serial import time import string import pynmea2 from sms import sendsms while True: try: port = "/dev/ttyAMA0" ser = serial.Serial(port, baudrate=9600, timeout=0.5) dataout = pynmea2.NMEAStreamReader() newdata = ser.readline() if newdata[0:6] == "$GNGGA": newmsg = pynmea2.parse(newdata) lat = newmsg.latitude lng = newmsg.longitude gps = " Latitude= " + str(lat) + " and Longitude= " + str(lng) sendsms(gps) print(gps) time.sleep(5) except Exception: print("No connection") time.sleep(2)
def send_sms(number,text): sms.sendsms(number,text) print "successful"
landmarks = predictor(gray, face) landmarks = face_utils.shape_to_np(landmarks) #The numbers are actually the landmarks which will show eye left_blink = blinked(landmarks[36], landmarks[37], landmarks[38], landmarks[41], landmarks[40], landmarks[39]) right_blink = blinked(landmarks[42], landmarks[43], landmarks[44], landmarks[47], landmarks[46], landmarks[45]) #Now judge what to do for the eye blinks if (left_blink == 0 or right_blink == 0): sleep += 1 drowsy = 0 active = 0 if (sleep > 20): status = sms.sendsms() "WARNING,SLEEPING massage sent successful to your personals!!!" playsound( "C:\\Users\\Vikrant\\Desktop\python_codeWithHarry\\Drowsiness dectation system.py\\Censored_Beep-Mastercard-569981218.mp3" ) color = (0, 0, 255) elif (left_blink == 1 or right_blink == 1): sleep = 0 active = 0 drowsy += 1 if (drowsy > 8): status = "Drowsy,Take Rest !" playsound( "C:\\Users\\Vikrant\\Desktop\\python_codeWithHarry\\Drowsiness dectation system.py\\salamisound-3834747-alarm-electric-alarm-clock.mp3" )
cv2.rectangle(frame, (xmin, label_ymin - labelSize[1] - 10), (xmin + labelSize[0], label_ymin + baseLine - 10), (255, 255, 255), cv2.FILLED) # Draw white box to put label text in cv2.putText(frame, label, (xmin, label_ymin - 7), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 2) # Draw label text # check if person is detected in frame if (object_name == 'person'): if ( time.time() - last_epoch ) > email_update_interval: #if present time is greater than email time interval then send email and sms # warnings.filterwarnings('ignore') cv2.imwrite('frame.jpg', frame) sendEmailfast(frame) sendsms() last_epoch = time.time() print('Email sent..') # All the results have been drawn on the frame, so it's time to display it. cv2.imshow(frame) # Press 'q' to quit if cv2.waitKey(1) == ord('q'): break #print(object_name) # Clean up video.release() cv2.destroyAllWindows()