def takePicture(): cur, con = initConn() id = getIdFromLastPicture(cur, con) idFromNextPicture = int(id) + 1 imageName = "image" + str(idFromNextPicture) + ".jpg" imagePath = "/etc/scripts/img/" + imageName os.system('raspistill -o "%s" -w 200 -h 150' % (imagePath) ) remotehost = '193.191.187.55' remotefile = '/var/www/img/'+ imageName os.system('scp "%s" "%s:%s"' % (imagePath, remotehost, remotefile) ) cur, con = initConn() logPhoto(cur, con, idFromNextPicture)
def takePicture(): cur, con = initConn() id = getIdFromLastPicture(cur, con) idFromNextPicture = int(id) + 1 imageName = "image" + str(idFromNextPicture) + ".jpg" imagePath = "./img/" + imageName GPIO.output(camera_led_pin, True) sleep(5) #os.system('raspistill -o "%s" -w 200 -h 150' % (imagePath) ) GPIO.output(camera_led_pin, False) remotehost = '193.191.187.55' remotefile = '/var/www/img/'+ imageName os.system('scp "%s" "%s:%s"' % (imagePath, remotehost, remotefile) ) cur, con = initConn() logPhoto(cur, con, idFromNextPicture)
def safeSequence(): cur, conn = initConn() print("Someone opened the safe, logging to db, sending notification... \n") logAlarm(cur, conn, "The safe just opened!") notify("Someone opened the safe", "2") playAlarm() GPIO.output(motor_pin, True) sleep(2) GPIO.output(motor_pin, False)
def doorSequence(): cur, conn = initConn() logAlarm(cur, conn, 'Door opened while alarm is active') print("Intruder detected, door opened") playAlarm()
def pressurePlateSequence(): cur, conn = initConn() print("Someone on pressure plate, logging to db, photo uploading... \n") logAlarm(cur, conn, "Someone on pressure plate, photo uploading...") takePicture()
from logToDb import initConn as initConn from logToDb import logAlarm as logAlarm cur, conn = initConn() logAlarm(cur, conn, 'door opened') cur, conn = initConn() logAlarm(cur, conn, 'safe opened') cur, conn = initConn() logAlarm(cur, conn, 'pressure plate triggered')