How to get Python output fron Houdini Engine

   6291   9   3
User Avatar
Member
44 posts
Joined: July 2017
Offline
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!
User Avatar
Member
323 posts
Joined: Jan. 2015
Offline
you might want to save them to a file.
User Avatar
Member
44 posts
Joined: July 2017
Offline
Olaf Finkbeiner
you might want to save them to a file.
Thanks Olaf!
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
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.
User Avatar
Member
44 posts
Joined: July 2017
Offline
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
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
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.
User Avatar
Member
44 posts
Joined: July 2017
Offline
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.
User Avatar
Member
603 posts
Joined: Sept. 2016
Offline
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.
User Avatar
Member
44 posts
Joined: July 2017
Offline
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
User Avatar
Member
13 posts
Joined: June 2018
Offline
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]
  • Quick Links