def haltSystem(): print 'Halt...' os.system("sudo halt") # GPIO.add_event_detect(HALT_PIN, GPIO.FALLING, callback = haltSystem, bouncetime = 2000)