Beispiel #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) 
Beispiel #2
0
lock_switch = 27
unlock_switch = 22
lock_pin = 17
unlock_pin = 4 
pwm_pin = 18
motor_pin = 23
counter = 0
lockid = 0
red_led = 26
blue_led = 20
green_led = 21
manual_button = 12
GPIO.setup(red_led, GPIO.OUT)
GPIO.setup(green_led, GPIO.OUT)
GPIO.setup(blue_led, GPIO.OUT)
db = Database_Connection()
manual = False
motor1 = motor()

def run_motor(channel):
    global manual
    manual = True
    print ('ADASDFSDFASDFLJasdjkafnsdjklfh asjkld sdfhajkl hvzm,xcbvxc')

#set pins for input and output
GPIO.setup(lock_switch, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(unlock_switch, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(red_led, GPIO.OUT)
GPIO.setup(green_led, GPIO.OUT)
GPIO.setup(blue_led, GPIO.OUT)
GPIO.setup(manual_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)