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
os.system() doesn't work in Python node
5096 6 2- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
- oat
- Member
- 479 posts
- Joined: Dec. 2009
- Offline
- oat
- Member
- 479 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!
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!
- oat
- Member
- 479 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!
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!
- dulo
- Member
- 383 posts
- Joined: June 2010
- Offline
- jsmack
- Member
- 7658 posts
- Joined: Sept. 2011
- Online
- dulo
- Member
- 383 posts
- Joined: June 2010
- Offline
-
- Quick Links