Currently tying to stop the middle of a command if the user presses a certain button. I tried this bit of code below and it doesn't seem to work. I know that you can use
control-C to have a KeyboardInterrupt, but I would like it so that I could use a button.
import os def put(command): os.system(command) elif (RPIO.input(25) == GPIO.LOW):#button 3 if direct == "": time.sleep(.5) while True: put("sudo ffmpeg -i \"" + q3 + "\" -f s16le -ar 22.05k -ac 1 - | sudo ./pifm - " + str(freq)) rebootpro() #reboot the program if RPIO.input(25) == GPIO.LOW: #if the button is pushed, stop the program. rebootpro() else: put("sudo ffmpeg -i \"" + q3 + "/" + direct + "\" -f s16le -ar 22.05k -ac 1 - | sudo ./pifm - " + str(freq)) rebootpro()
I am trying to stop the program while a
os.system command is running, is there any way to do this? (python 2.7)