os.system() doesn't work in Python node

   1445   6   2
User Avatar
Member
474 posts
Joined: Dec. 2009
Offline
I have the following code in a Python Type Operator, which calls a program “oconv” to process a few files and output a new file whose name is specified by variable “oconv_file_path_and_name”.

However I couldn't get it run by using os.system() in the code.

I print out the full command before it is executed. Strangely, if I copy the fulll command string and paste it in the terminal and run it, I can get the results as expected.

So, I think I must have missed something here about how to execute command line program using os.system() …

Advices are greatly appreciated!

(using Mac OS X Yosemite, Houdini Apprentice 13.0.570)


The Code in Python Type Operator is:

# Create the OCONV command string
cmd_oconv = ‘oconv’ + ‘ ’ +\
mat_file + ‘ ’ +\
sky_file + ‘ ’ +\
geom_file + ‘ ’ +\
‘>’ + ‘ ’ +\
oconv_file_path_and_name
print cmd_oconv
os.system(cmd_oconv)


The full command string “cmd_oconv”as printed is something like the following:

oconv /Users/oat/Desktop/temp/materials.mat /Users/oat/Desktop/temp/sky.rad /Users/oat/Desktop/temp/scene.rad > /Users/oat/Desktop/temp/scene.oct
It's always a pleasure to learn from you!
User Avatar
Member
474 posts
Joined: Dec. 2009
Offline
I tried the subprocess.call() function, but it still doesn't work ..

something like:

subprocess.call(cmd_oconv, shell=True)
It's always a pleasure to learn from you!
User Avatar
Member
474 posts
Joined: Dec. 2009
Offline
… OK, I admit that I'm repeating my own question …

see my post before regarding this issue:
https://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=21725&highlight=os.system%28%29 [sidefx.com]

It seems if the command line program is copied to the /usr/bin folder, the problem will be solved, still using os.system().

Maybe I need to add the path of the folder where the “oconv” program is installed currently to the system “.profile” file …

Advices are still appreciated!
It's always a pleasure to learn from you!
User Avatar
Member
474 posts
Joined: Dec. 2009
Offline
sorry for bringing up this post again, since I still can't solve this problem on a Macbook Pro newly reinstalled and updated.

Even using the subprocess.call(cmd, shell=True) method instead of os.system(cmd), the problem is still the same:
1. the command line program can't be executed using Python withing Houdini DA, which can obviously run in the Terminal after pasting the entire cmd string in the terminal
2. After the command line program I'm using is copied from the place it's installed currently to the /usr/bin folder, it can be executed from within Houdini, but the output file is currupted or incomplete.

I'm quite frustrated about the issue as the same houdini file and the same command line program installed in the same way have no such problem on another iMac desktop…

Did I miss something here related to system configuration?

I sincerely hope you can give me some hints to solve this “should be simple and obvious” problem!

Thank you!
It's always a pleasure to learn from you!
User Avatar
Member
382 posts
Joined: June 2010
Offline
Same problem here but still didnt find a solution.
www.woogieworks.at
User Avatar
Member
844 posts
Joined: Sept. 2011
Offline
Works fine in the instant meshes bridge sop, it uses subprocess to call instantmeshes.exe. Is this a mac specific problem?
User Avatar
Member
382 posts
Joined: June 2010
Offline
No. I only experience the problem with win64 hou16 and hou16.5.
Will try to use popen directly today. Calling matplotlib gui to get some statistics on volumes and vector fields ..
www.woogieworks.at
  • Quick Links