Python Forum
I want to search a variable for a string D90
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I want to search a variable for a string D90
#1
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),)
buran write Mar-29-2021, 04:28 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
Quote:Python version 2.7.16
This version of python has been obsolete since Jan 1, 2020.
Reply
#3
(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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 833 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  Replacing String Variable with a new String Name kevv11 2 729 Jul-29-2023, 12:03 PM
Last Post: snippsat
  Need help on how to include single quotes on data of variable string hani_hms 5 1,886 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  python r string for variable mg24 3 2,635 Oct-28-2022, 04:19 AM
Last Post: deanhystad
  USE string data as a variable NAME rokorps 1 920 Sep-30-2022, 01:08 PM
Last Post: deanhystad
  Removing Space between variable and string in Python coder_sw99 6 6,125 Aug-23-2022, 01:15 PM
Last Post: louries
  Remove a space between a string and variable in print sie 5 1,706 Jul-27-2022, 02:36 PM
Last Post: deanhystad
  Split string using variable found in a list japo85 2 1,238 Jul-11-2022, 08:52 AM
Last Post: japo85
  Can you print a string variable to printer hammer 2 1,891 Apr-30-2022, 11:48 PM
Last Post: hammer
Question How to convert string to variable? chatguy 5 2,231 Apr-12-2022, 08:31 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020