mrWolf Posted February 5, 2015 Share Posted February 5, 2015 I'm using a small python script to open a hip file, "do something" , save, and press the button "render" on the proprietary node that sends the job on the farm. Of course this all happens without ui, so my script errors out cause somewhere there is some python code that uses hou.ui.setStatusMessage, and I guess hbatch doesn't load the ui module. This is the error I get: hou.ui.setStatusMessage( "Creating the render data", hou.severityType.Message) AttributeError: 'module' object has no attribute 'ui' This the script: import hou hou.hipFile.load("myfile.hip",True) <change parameters and do interesting stuff> print ("submitting job on the farm\n") farmrender=hou.node("/out/farm_render") farmrender.parm("FarmRender").pressButton() print ("done\n") hou.exit() and this is the error message ... hou.ui.setStatusMessage( "Creating the render data", hou.severityType.Message) AttributeError: 'module' object has no attribute 'ui' I already tried to execute the actual code contained in the button, but I get the same exact error. Is there any way to suppress any call to hou.ui when a script is executed via hbatch ? Quote Link to comment Share on other sites More sharing options...
graham Posted February 5, 2015 Share Posted February 5, 2015 You need to put the hou.ui call inside an if statement that checks if the ui is available: if hou.isUIAvailable(): hou.ui.setStatusMessage(.....) Quote Link to comment Share on other sites More sharing options...
mrWolf Posted February 5, 2015 Author Share Posted February 5, 2015 You need to put the hou.ui call inside an if statement that checks if the ui is available: if hou.isUIAvailable(): hou.ui.setStatusMessage(.....) thank you for your reply Graham, unfortunately I cannot access the content of whatever script executes the call to hou.ui cause it's a pipeline script. I was wondering if there is any way to catch any call to ui, and ignore it. I tried with a try: except: structure but it doesn't work. Quote Link to comment Share on other sites More sharing options...
graham Posted February 5, 2015 Share Posted February 5, 2015 If you can't have someone change the bad code you could probably just monkeypatch hou in your script and generate a dummy hou.ui.displayMessage function that does nothing and won't error. Quote Link to comment Share on other sites More sharing options...
mrWolf Posted February 5, 2015 Author Share Posted February 5, 2015 If you can't have someone change the bad code you could probably just monkeypatch hou in your script and generate a dummy hou.ui.displayMessage function that does nothing and won't error. ehi Graham ! this seems very interesting ! I am not the most expert python coder out there at all, I am trying to figure out the syntax for this to work but I am struggling a bit with the syntax I tried this code: import hou def setStatusMessage(message, severity=hou.severityType.Message): print (message) hou.ui.setStatusMessage=setStatusMessage But I get this message: hbatch Version 13.0.447 (Compiled on 06/17/14) Traceback (most recent call last): File "actor001.py", line 18, in <module> hou.ui.setStatusMessage=setStatusMessage AttributeError: 'module' object has no attribute 'ui' Can you give me a hint on what I am doing wrong ? Quote Link to comment Share on other sites More sharing options...
graham Posted February 5, 2015 Share Posted February 5, 2015 You can probably do something like this to fake it: def setStatusMessage(message, severity=hou.severityType.Message): print (message) hou.ui = lambda: None setattr(hou.ui, "setStatusMessage", setStatusMessage) Quote Link to comment Share on other sites More sharing options...
mrWolf Posted February 6, 2015 Author Share Posted February 6, 2015 You can probably do something like this to fake it: def setStatusMessage(message, severity=hou.severityType.Message): print (message) hou.ui = lambda: None setattr(hou.ui, "setStatusMessage", setStatusMessage) Graham, it works great. Thank you a lot man Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.