qral Posted December 27, 2012 Share Posted December 27, 2012 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 Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted December 27, 2012 Share Posted December 27, 2012 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. Quote Link to comment Share on other sites More sharing options...
qral Posted December 28, 2012 Author Share Posted December 28, 2012 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> Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted December 28, 2012 Share Posted December 28, 2012 http://stackoverflow.com/a/1388807 Do this to capture the actual output and also use poll() to get the exitcode. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.