The following Code is what I have written to access my raspi and input a series of commands to run sequentially. What i cannot figure out, is how to make the "snapshot.py" command pause, and allow me to do the start and capture commands for the photo to show up on the device, when i input the command individually into the raspi it works and stores the photo in the proper directory but not when i have this running. I also need to make sure the results of the commands/onboarding tests get stored onto a txt file. Any advice is greatly appreciated, I am new to the raspi world so please all critique is welcome. Thank you
import paramiko, subprocess p = paramiko.SSHClient() p.set_missing_host_key_policy(paramiko.AutoAddPolicy()) p.connect("10.0.0.65", port=22, username="dev", password="Production1!") stdin, stdout, stderr = p.exec_command('ls') opt = stdout.readlines() opt = "".join(opt) print(opt) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo raspi-config') opt0 = stdout.readlines() opt0 = "".join(opt0) print(opt0) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sed -n 43p /proc/cpuinfo') opt1 = stdout.readlines() opt1 = "".join(opt1) print(opt1) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo nano /etc/hostname') opt2 = stdout.readlines() opt2 = "".join(opt2) print(opt2) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo nano /etc/hosts') opt3 = stdout.readlines() opt3 = "".join(opt3) print(opt3) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo touch ../../full_log.sh') opt4 = stdout.readlines() opt4 = "".join(opt4) print(opt4) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo touch ../../live_log.sh') opt5 = stdout.readlines() opt5 = "".join(opt5) print(opt5) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo touch ../../update.sh') opt6 = stdout.readlines() opt6 = "".join(opt6) print(opt6) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo touch ../../watch_and_update.sh') opt7 = stdout.readlines() opt7 = "".join(opt7) print(opt7) input("press enter to continue") stdin, stdout, stderr = p.exec_command('echo sudo journalctl -u spiderentry.service | sudo tee ../../full_log.sh') opt8 = stdout.readlines() opt8 = "".join(opt8) print(opt8) input("press enter to continue") stdin, stdout, stderr = p.exec_command('echo sudo journalctl -f -u spiderentry.service| sudo tee ../../live_log.sh') opt9 = stdout.readlines() opt9 = "".join(opt9) print(opt9) input("press enter to continue") stdin, stdout, stderr = p.exec_command('echo python3 ~/spiderkeypadpi/main/firmware_update.py | sudo tee ../../update.sh') opt10 = stdout.readlines() opt10 = "".join(opt10) print(opt10) input("press enter to continue") stdin, stdout, stderr = p.exec_command('echo python3 ~/spiderkeypadpi/main/firmware_update.py | sudo tee ../../watch_and_update.sh') opt11 = stdout.readlines() opt11 = "".join(opt11) print(opt11) input("press enter to continue") stdin, stdout, stderr = p.exec_command('echo sudo journalctl -f -u spiderentry.service | sudo tee -a ../../watch_and_update.sh') opt12 = stdout.readlines() opt12 = "".join(opt12) print(opt12) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod +x ../../full_log.sh') opt13 = stdout.readlines() opt13 = "".join(opt13) print(opt13) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod +x ../../live_log.sh') opt14 = stdout.readlines() opt14 = "".join(opt14) print(opt14) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod +x ../../update.sh') opt15 = stdout.readlines() opt15 = "".join(opt15) print(opt15) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod +x ../../watch_and_update.sh') opt16 = stdout.readlines() opt16 = "".join(opt16) print(opt16) input("press enter to continue") stdin, stdout, stderr = p.exec_command('ssh-keygen -f ~/.ssh/id_rsa -t rsa -N "') opt17 = stdout.readlines() opt17 = "".join(opt17) print(opt17) input("press enter to continue") stdin, stdout, stderr = p.exec_command('cat ~/.ssh/id_rsa.pub') opt18 = stdout.readlines() opt18 = "".join(opt18) print(opt18) input("press enter to continue") stdin, stdout, stderr = p.exec_command('git clone [email protected]:SpiderDoorLLC/spiderkeypadpi.git') opt19 = stdout.readlines() opt19 = "".join(opt19) print(opt19) input("press enter to continue") stdin, stdout, stderr = p.exec_command('cd spiderkeypadpi/services') opt20 = stdout.readlines() opt20 = "".join(opt20) print(opt20) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod +x setup.sh') opt21 = stdout.readlines() opt21 = "".join(opt21) print(opt21) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo ./setup.sh') opt22 = stdout.readlines() opt22 = "".join(opt22) print(opt22) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo chmod -x setup.sh') opt23 = stdout.readlines() opt23 = "".join(opt23) print(opt23) input("press enter to continue") stdin, stdout, stderr = p.exec_command('cd ../main') opt24 = stdout.readlines() opt24 = "".join(opt24) print(opt24) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 serial_number.py') opt25 = stdout.readlines() opt25 = "".join(opt25) print(opt25) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 relay.py') opt26 = stdout.readlines() opt26 = "".join(opt26) print(opt26) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 snapshot.py') opt27 = stdout.readlines() opt27 = "".join(opt27) print(opt27) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo rm 000*') opt28 = stdout.readlines() opt28 = "".join(opt28) print(opt28) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 main.py') opt29 = stdout.readlines() opt29 = "".join(opt29) print(opt29) input("press enter to continue") stdin, stdout, stderr = p.exec_command('cd spiderkeypadpi/services') opt30 = stdout.readlines() opt30 = "".join(opt30) print(opt30) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 stop_services.py') opt31 = stdout.readlines() opt31 = "".join(opt31) print(opt31) input("press enter to continue") stdin, stdout, stderr = p.exec_command('cd ../main ') opt32 = stdout.readlines() opt32 = "".join(opt32) print(opt32) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 snapshot.py') opt33 = stdout.readlines() # # capture and end commands # # report for photo or failure of camera opt33 = "".join(opt33) print(opt33) input("press enter to continue") stdin, stdout, stderr = p.exec_command('sudo python3 piezo.py') opt34 = stdout.readlines() opt34 = "".join(opt34) print(opt34)
buran write Oct-21-2020, 07:41 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.