I am trying to use this script with my raspi to open another script when a button is released, and close the opened script when the button is pressed.
If i hold the button i get a constant feed of "camera is not on" which is good thats what i want it to do, Then when i release the button the script opens as it should and my output says "camera is on" and the camera turns on also good. I need to call this script to open the camera.
This is what I have so far.
from gpiozero import Button
import sys
import os
import subprocess
button = Button(17)
p = subprocess.Popen(['python', 'objectident.py', 'arg1', 'arg2'])
while True:
    if button.is_pressed:
        print("camera is not on")
        p.terminate()
        p.wait()
    else:
        print("camera is on")
        os.system("python objectident.py")
        continue
This is the output that I am getting. Image of output
any help would be greatly appreciated this is my first big python project, and for some reason i cant find the solution i am looking for.