#!/usr/bin/python import RPi.GPIO as GPIO import time import os, subprocess # SoC als Pinreferenz waehlen GPIO.setmode(GPIO.BOARD) # Ausschaltknopf konfigurieren ausschaltknopf=38 copyknopf=40 GPIO.setup(ausschaltknopf, GPIO.IN, pull_up_down = GPIO.PUD_UP) GPIO.setup(copyknopf, GPIO.IN, pull_up_down = GPIO.PUD_UP) # LED konfigurieren blinkled=16 GPIO.setup(blinkled, GPIO.OUT) def copycontent(channel): time.sleep(1) GPIO.remove_event_detect(channel) os.system("/home/pi/copycontent.sh") print "Copy Content finished. Stick unmounted" GPIO.add_event_detect(copyknopf, GPIO.FALLING, callback = copycontent, bouncetime = 300) # Interrupt-Handler def ausschalten(channel): os.system("/sbin/shutdown -h now") print "Exit" # Interrupt-Handler registrieren GPIO.add_event_detect(ausschaltknopf, GPIO.FALLING, callback = ausschalten, bouncetime = 300) GPIO.add_event_detect(copyknopf, GPIO.FALLING, callback = copycontent, bouncetime = 300) # Endlosschleife while True: time.sleep(1.75) GPIO.output(blinkled,GPIO.HIGH) time.sleep(0.25) GPIO.output(blinkled,GPIO.LOW)