Python Forum

Full Version: I want to search a variable for a string D90
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Very sorry to post such a basic question,
I have been reading and trying so many things
with no luck.

Platform is rasberry PI 4 running astroberry OS build.
Python version 2.7.16

The camera did not respond, returncode=0.
Question here is, I need an if statement that will
interrupt the code if return is 0, how do I use the
returncode, or parse check_camera is it 0 or 1.
Thank You


# Controll my Nikon D90 with GPIO #2
import logging
import RPi.GPIO as GPIO
import time
import os
import subprocess
import sh
import sys
from sh import gphoto2 as gp

#run a test to confirm camera is communicating
check_camera = subprocess.run(["gphoto2", "--auto-detect"]), 

time.sleep(.5)
#print("stdout:", result.stdout)
#print("stderr:", result.stderr)

print (check_camera)

(CompletedProcess(args=['gphoto2','--auto-detect'] returncode=0),)
Quote:Python version 2.7.16
This version of python has been obsolete since Jan 1, 2020.
(Mar-29-2021, 09:40 PM)Larz60+ Wrote: [ -> ]
Quote:Python version 2.7.16
This version of python has been obsolete since Jan 1, 2020.
Thank your for input, despite warnings not to upgrade python
I have found so many help topics for version 3.5 and newer that
I now see newly added commands might be my best bet.