I used the method described [*here*](http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi/%28offset%29/2) and [*here*](http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi/%28offset%29/4) , which is a python script based on interrupts, to enable safe shutdown via push-button press.

These are the steps in short:

1-

```
sudo nano test.py

```

2- and then:

```
# Import the modules to send commands to the system and access GPIO pins
from subprocess import call
import RPi.GPIO as gpio

# Define a function to keep script running
def loop():
    raw_input()

# Define a function to run when an interrupt is called
def shutdown(pin):
    call('halt', shell=False)

gpio.setmode(gpio.BOARD) # Set pin numbering to board numbering
gpio.setup(7, gpio.IN) # Set up pin 7 as an input
gpio.add_event_detect(7, gpio.RISING, callback=shutdown, bouncetime=200) # Set up an interrupt to look for button presses

loop() # Run the loop function to keep script running

```

3- and then add the following to `/etc/rc.local` :

```
python /home/pi/test.py

```

4- and these are the circuits:

![enter image description here](https://i.stack.imgur.com/FMDKT.png)

and

![enter image description here](https://i.stack.imgur.com/Cqo9C.png)

However, it didn't work.

The on-button and the hard-off-button work well. But when I press the soft-off-button, nothing happens at all.

My system is **Xbian/Kodi on RPi B+** .

What's wrong with this method !!?
And what should I do to get it to work !?

Thanks for your time and help.