Jump to content

os.system/subprocess.call python errors


qral

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

Link to comment
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.

Link to comment
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>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...