Exemplo n.º 1
0
from databse_connection import Database_Connection
import RPi.GPIO as GPIO
import pysftp
import os
import time
import subprocess
import datetime
with pysftp.Connection('104.236.252.214', username = '******', password = '******') as sftp:
   with sftp.cd('/var/Images'):
      sftp.put('/home/pi/image.jpg')

db = Database_Connection()
db.connect()
db.add_image('104.236.252.214/var/Images/image.jpg')
db.close()
#os.system('fswebcam mages.fpg')

#subprocess.call(['fswebcam', '%s.jpg' % datetime.datetime.utcnow().strftime('%Y-%M-%D-%H-%M-%S')]) 
#file_name = '/home/pi/Documents/images/{0}.jpg'.format(datetime.datetime.utcnow())

#subprocess.call(['fswebcam', file_name]) 

#things = 'INSERT INTO Thigns (thigns, thinsgs) VALUES (1,{0})'.format("'.txt'")

#print (things)
#db.add_message(
#result = db.check_messages()
#print (result)
#action_id = result['action_id']
#message_id = result['message_id']
#db.update_message(message_id, 1) 
Exemplo n.º 2
0
                if loop:
                    db.connect()
                    db.update_message(message_id)
                    db.add_history(fingerprint, 1)
                    db.close()
                    loop = False
                manual = False
                

        # if a user is not allowed in the door
        else:
            led('red')
            result = take_picture()
            image = result[0]
            server_path = result[1]
            sftp(image)
            db.connect()
            db.add_history()
            db.add_image(server_path)
            db.update_message(message_id)
            db.close() 

    elif result[1] == 1:
        fingerprint = int(arduino.enroll())
        db.connect()
        db.insert_user(user_id, fingerprint)
        db.update_message(message_id)
        db.close() 

GPIO.cleanup()