[SOLVED] egg2bam: Running via os.popen in Windows


#1

Greetings all!

Tripped over a little problem that may be shell-related; I was hoping someone might have some insight, as I’m pretty naive about the Windows shell.

We have a make script that recursively runs egg2bam across all directories under a specific file path. We run the command by assembling a shell string (‘egg2bam -o myfile.bam myfile.egg’) and then using Python’s ‘os.popen’ function to run the command.

When we do the above, it appears that ObjectType specifications we’ve defined in our Config.prc file aren’t used—as if the file is never read. I’m not able to capture egg2bam’s error pipe in this environment, so I can’t be sure whether the file is getting loaded. In any case, the output bam lacks the substitutions that our egg-object-type-* config entries should have created; the ObjectType tags appear to simply vanish from the bam output. Running the exact same command line outside of the python script (i.e. outside the os.popen method) has the desired result; our ObjectType tags are substituted with the proper content as per the egg-object-type specifiers in our Config.prc file.

Has anyone experienced a similar problem, or could recreate the problem I described? How does egg2bam locate the Config.prc files? Is there perhaps another way to get python to execute a shell command that I could try?

Thank you for the help!
-Mark


#2

you can check if egg2bam gives an error by using:

a = os.popen("egg2bam blah").read()
print a

#3

Unfortunately, that doesn’t appear to generate any error output. Perhaps the error output is coming through on another pipe (the Windows equivalent to stderr), and popen only grabs the standard out pipe?

I was able to make a bit of forward progress by switching from the popen command to the os.system command. I now see the following errors coming from the program:

:egg2pg(error): Unknown ObjectType customobjtype

The customobjtype tag is where I expect it to be, and I have the following line in my Config.prc file (panda3d1.2.3/etc/Config.prc):

egg-object-type-customobjtype	     <Tag> type { custom }

As I mentioned before, if I manually run egg2bam, everything works with no errors; it is only when I run via the os.popen or os.system commands that I get the errors I am currently seeing.

My hunch is that in this run context, egg2bam fails to find the Config.prc file in the panda install. What method does it use to locate that file?

-Mark


#4

We identified the problem. :slight_smile:

It wasn’t an issue with the use of Python to drive the Panda tools. Another part of our build process was setting the PANDA_PRC_DIR environment variable to an incorrect directory.

Thank you for your help!

-Mark