示例#1
0
def runAutoMode():
    print "\nAuto Mode Running..."
    setCurrentAction('off')
    global check_stream
    global check_door
    roomState = readingRoomSensor()

    if roomState == True:
        insert_motion()
        take_pic()

    doorState = readingDoorSensor()

    if doorState == True:
        if check_door == 0:
            insert_door()
            print "Email sending.."
            email('*****@*****.**')
            print "Email sent"
            print "Check stream..."
            stream()
            check_door = 1
        elif check_stream == 0:
            stream()
        else:
            pass
    else:
        kill_stream()
        setCurrentAction('off')
        check_stream = 0
        check_door = 0
示例#2
0
def check(url, dest="0", passwd="0"):
    """checks the PF site and compares status from last execution if there is
    any change prints it and update the pickle file if not returns 'No change',
    optionally sends email"""
    from mailer import email
    regex = '//td/text()'
    status = scrapper(url, regex)
    last = file_handler('last.txt', 'r')

    if status[len(status) - 1] == last:
        print("No change")
        if dest != "0" or passwd != "0":
            email(status, "No Change", dest, passwd)
    else:
        for i in status:
            print(i)
        if dest != "0" or passwd != "0":
            email(status, "NEW STATUS", dest, passwd)

        file_handler("last.txt", "w", status)
示例#3
0
    def rand_pass(self, args):
        """Email the user a new random password.
Usage:
	user rand_pass USERNAME"""

        if len(args) < 1:
            print self.rand_pass.__doc__
            return

        uname = args[0]
        u = sr.users.user( uname )

        if not u.in_db:
            print "User '%s' not found\n" % (args[0])
            return False

        new_passwd = sr.users.GenPasswd()
        u.set_passwd( new = new_passwd )

        msg = """Hi %s,
Your student robotics password has been changed.  Your login details
are now:

  Username: %s
  Password: %s

You can change your password at:

http://www.studentrobotics.org/passwd

Thanks,

The Student Robotics Team
""" % (u.cname,uname,new_passwd)

        mailer.email( mailer.fromaddr,
                      u.email,
                      "New Student Robotics Password",
                      msg )
        return True
示例#4
0
				# Convert image to grayscale.
				image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
				# Get coordinates of single face in captured image.
				result = face.detect_single(image)
				if result is None:
					print 'Could not detect single face!  Check the image in capture.pgm' \
						  ' to see what was captured and try again with only one face visible.'
					continue
				x, y, w, h = result
				# Crop and resize image to face.
				crop = face.resize(face.crop(image, x, y, w, h))
				# Test face against model.
				label, confidence = model.predict(crop)
				print 'Predicted {0} face with confidence {1} (lower is more confident).'.format(
					'POSITIVE' if label == config.POSITIVE_LABEL else 'NEGATIVE', 
					confidence)
				if label == config.POSITIVE_LABEL and confidence < config.POSITIVE_THRESHOLD:
					print 'Recognized face!'
					box.unlock()
				else:
					print 'Did not recognize face!'
					# Someone other than the box owner is trying to get in. Save a picture of their face...
					if (not emailSent):
						# Only send an email if the user has email information stored
						if (not config.SENDER_EMAIL == ''):
							filename = os.path.join('./culprits/', str(now.year) + str(now.month) + str(now.day) +'_face.png')
							cv2.imwrite(filename, crop)
							# Then email it to the box owner
							mailer.email(filename)
							emailSent = True
示例#5
0
        if confidence < config.POSITIVE_THRESHOLD:
            print 'Recognized face!'
            GPIO.setmode(GPIO.BOARD)
            GPIO.setup(11, GPIO.OUT)
            GPIO.output(11, 1)
            print 'Led On!!!!!!!!!'
        else:
            print 'Did not recognize face!'
            # Someone other than the box owner is trying to get in. Save a picture of their face...
            if (not emailSent):
                # Only send an email if the user has email information stored
                if (not config.SENDER_EMAIL == ''):
                    filename = os.path.join('./culprits/',
                                            time.strftime('%Y') + '_face.png')
                    cv2.imwrite(filename, crop)
                    mailer.email(filename)
                    emailSent = True

                    os.system(
                        "raspivid -o - -t 0 -hf -w 800 -h 400 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8000}' :demux=h264"
                    )

                    mail = imaplib.IMAP4_SSL('imap.gmail.com')
                    mail.login('*****@*****.**', '1Sarthakkapoor')
                    mail.list()
                    # Out: list of "folders" aka labels in gmail.
                    mail.select("inbox")  # connect to inbox.
                    result, data = mail.search(None, "ALL")

                    ids = data[0]  # data is a list.
                    id_list = ids.split()  # ids is a space separated string