#!/usr/bin/python3
from RPi import GPIO
import time
from subprocess import call

def buttonPress(pin):
    if not GPIO.input(3):
        call(['sudo', 'shutdown', '-h', 'now'])

GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN)
GPIO.add_event_detect(3, GPIO.BOTH, callback=buttonPress)
while True:
    time.sleep(10)
