Jump to content
berniebernie

writing to stdout using a python node

Recommended Posts

Hello

I'm sending alembic rops to hqueue and there's a lot of preroll. Even with alfred-style progress turned on, I have no feedback on what's going on.

I was thinking that I could add a python node to write to the stdout (which I though would show up in the hqueue logs) like so:

     import sys
     f= hou.frame()
     sys.stdout.write('frame: '+str(f) + '\n')

But it doesn't work. Any ideas ?

When I start houdini with the -foreground option (so that the shell it launches from doesn't spawn a new process and should receive outputs) and write to stdout, it only shows up in the python console

 

Thanks

Share this post


Link to post
Share on other sites

Hey,

I had the same problem with Tractor. Here's what worked for me in the end (no warranty that it also works with hqueue).

The script is run as a post-frame-script in the alembic rop.

import sys

start = hou.node(".").parm("f1").eval()
end = hou.node(".").parm("f2").eval()
current = hou.frame()

progress = str(int(hou.hmath.fit(current, start, end, 0.0, 100.0))).zfill(3)

print("\rFrame {0} done".format(current))
print("\rALF_PROGRESS {0}%".format(progress))
sys.stdout.flush()

It seems that both the carriage returns AND the flushing are necessary. If any of this is missing I will only get the information in the log when the whole caching process is done.

Hope this helps,

Dennis

Edited by dennis.albus
  • Like 1

Share this post


Link to post
Share on other sites
13 minutes ago, dennis.albus said:

Hey,

I had the same problem with Tractor. Here's what worked for me in the end (no warranty that it also works with hqueue).

The script is run as a post-frame-script in the alembic rop.


import sys

start = hou.node(".").parm("f1").eval()
end = hou.node(".").parm("f2").eval()
current = hou.frame()

progress = str(int(hou.hmath.fit(current, start, end, 0.0, 100.0))).zfill(3)

print("\rFrame {0} done".format(current))
print("\rALF_PROGRESS {0}%".format(progress))
sys.stdout.flush()

 

Hope this helps,

Dennis

Thanks for the snippet, it actually works in hqueue now, even the simple print, in a python node (instead of the alembic rop which only fires when a frame is written, not during preroll).

My problem was that my python node was after the dopnet which was simulating, so it never fired during preroll. Silly me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×