Jump to content
Sign in to follow this  
qral

os.system/subprocess.call python errors

Recommended Posts

Hi

I am trying to get a Canon 7D camera to take a picture via a bash shell command from inside houdini using the Python os.system or the newer

subprocess.call commands. I am using houdini escape 12.0.581 on OSX 10.6.8 with python 2.6 and gPhoto2/libphoto2

subprocess.call("bash -c \"gphoto2 --capture-image\"", shell=True)

or

os.system("bash -c \"gphoto2 --capture-image\"")

both works fine in the system terminal python shell but in the houdini python shell I get errors.

For the os.system I get an error 32512 and for the subprocess.call I get back an error 127?

I am a novice in Python so I really hope some of you guys can help me!

best regards

Rasmus

Share this post


Link to post
Share on other sites

I would use Popen instead of call in the subprocess module. Then you can grab the output to get more stuff to find errors in.

Also imo it's prettier to use ' to avoid having to escape the " like this:

subprocess.call('bash -c "gphoto2 --capture-image"', shell=True)

Anyways exit code 127 is that the command can not be found so you could try using /bin/sh instead of bash as command.

Share this post


Link to post
Share on other sites

Thanks for helping me out Erik!

I have now tried:

subprocess.Popen(['/bin/sh', '-c', "gphoto2 --capture-image"])

and as the other methods before, it works fine in the system terminal python shell, the driver loads and the camera takes a picture:

<subprocess.Popen object at 0x39f590>

>>> Loading camera drivers from '/usr/local/Cellar/li... | \ 0,0%

New file is in location /capt0000.jpg on the camera

but in the houdini python shell I only get a:

<subprocess.Popen object at 0x12fd15190>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×