Search - User list
Full Version: How to get Python output fron Houdini Engine
Root » Houdini Engine API » How to get Python output fron Houdini Engine
Francois Devic
Hello!

In our hdas, we have Python scripts.
Some of them are logging infos thank to the python logging system.
In Houdini, everything is working fine and the output is output in the Houdini Console.

Is it possible to get these output and to display them somewhere else when you are using the hdas in HoudiniEngine?

Thanks!
Olaf Finkbeiner
you might want to save them to a file.
Francois Devic
Olaf Finkbeiner
you might want to save them to a file.
Thanks Olaf!
chrisgreb
Python has a lot of options for logging handlers - you could install a fancy socket or file handler in houdini to pipe these messages wherever you like.
Francois Devic
chrisgreb
Python has a lot of options for logging handlers - you could install a fancy socket or file handler in houdini to pipe these messages wherever you like.
Indeed.
But if there any way to get the standard output of the HoudiniEngine and redirect it in our output?

Thanks
chrisgreb
The UE4 part would take some work - you'd have to have to write a custom editor plugin that watches for new houdini log messages and enters them into the UE4 logging system. Maybe there's an easy way to do it with a Blutility or the python plugin.
Francois Devic
chrisgreb
The UE4 part would take some work - you'd have to have to write a custom editor plugin that watches for new houdini log messages and enters them into the UE4 logging system. Maybe there's an easy way to do it with a Blutility or the python plugin.
We are not in UE4

I was wndering how to hook ourselves to some place where the new houdini log messages are generated.
chrisgreb
Ah, I misread - you could add this to your scripts/123.py file like:

import logging
handler = logging.StreamHandler(sys.stdout)
logger = logging.getLogger()
logger.addHandler(handler)

Except instead of a normal logging.StreamHandler, you would use your own handler that can forward the messages appropriately.
Francois Devic
chrisgreb
Ah, I misread - you could add this to your scripts/123.py file like:

import logging
handler = logging.StreamHandler(sys.stdout)
logger = logging.getLogger()
logger.addHandler(handler)

Except instead of a normal logging.StreamHandler, you would use your own handler that can forward the messages appropriately.
Ok!

It is what I wanted to avoid
Thanks for your help
LithLoren
You can redirect the console output form the HARS process using pipes:
https://docs.microsoft.com/en-us/windows/desktop/ProcThread/creating-a-child-process-with-redirected-input-and-output [docs.microsoft.com]


Just keep in mind your python scripts may need to manually flush the output buffers to get the output to show up:
https://stackoverflow.com/questions/230751/how-to-flush-output-of-print-function [stackoverflow.com]
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB