Jump to content

setting an environment variable via external hython


ch3

Recommended Posts

I am putting together a python script to render multiple files sequentially on a windows machine via cygwin. A rather big pain as I had to resolve all the path madness (\ vs /)... but it's almost there...

 

For some strange reason $HIPNAME on the output path of the rop node, evaluates to the full path and not just the file name. So whenever I use it on my output path (...project/renders/$HIPNAME:r/$HIPNAME:r.$F4.exr), it resolves to a non existing long path (...project/renders/...project\renders/...project\renders.$F4.exr) and fails

 

When I render my scene from the terminal via hscript it works fine. I wouldn't be surprised if it's another confusion caused by cygwin. But I was wondering if it's possible to change the content of a variable via python, in the same way you can do via the Alias & Variables UI. I just want to test whether it will work if I set it my self to the filename, prior to executing the render.

 

thanks

 

 

 

 

Link to comment
Share on other sites

Hey!  Yeah, you can do that, although I'm not sure of the python specific version.  When I've been wanting to change a global variable in some code evaluated by hython or hscript, I just use this:
set -g name = value

I don't know that there's a hython equivalent, but this will let you do it in hython as a workaround:

hou.hscript('set -g name = value')

 

Does anyone else have a better way to do that?

 

 

I am putting together a python script to render multiple files sequentially on a windows machine via cygwin. A rather big pain as I had to resolve all the path madness (\ vs /)... but it's almost there...

 

For some strange reason $HIPNAME on the output path of the rop node, evaluates to the full path and not just the file name. So whenever I use it on my output path (...project/renders/$HIPNAME:r/$HIPNAME:r.$F4.exr), it resolves to a non existing long path (...project/renders/...project\renders/...project\renders.$F4.exr) and fails

 

When I render my scene from the terminal via hscript it works fine. I wouldn't be surprised if it's another confusion caused by cygwin. But I was wondering if it's possible to change the content of a variable via python, in the same way you can do via the Alias & Variables UI. I just want to test whether it will work if I set it my self to the filename, prior to executing the render.

 

thanks

Link to comment
Share on other sites

Although, according to the help files you could use setenv, too.

setenv name = value

hou.hscript('setenv name = value')

 

 

Hey!  Yeah, you can do that, although I'm not sure of the python specific version.  When I've been wanting to change a global variable in some code evaluated by hython or hscript, I just use this:
set -g name = value

I don't know that there's a hython equivalent, but this will let you do it in hython as a workaround:

hou.hscript('set -g name = value')

 

Does anyone else have a better way to do that?

Link to comment
Share on other sites

Cool, thanks a lot Dee

I managed to make it work.

 

I now have a .bat icon on my desktop that runs cygwin and a shell batch file for multiple sequential renders. Each render command is a python script that does various checks and runs a hython script to do the actual render. Between all theses, I had to wrangle the madness between unix/win paths, slashes, backslashes, double backslashes, quadruple backslashes, global variables and more! :wacko:

I think I now need a beer!

Link to comment
Share on other sites

Why not run it through a process or something?  Set up your paths so they are similar on both...  I'm just doing this off the top of my head and I'm still learning python, but wouldn't it be something like this:

path = 'path/to/information'

def makePath(path):
  basepathwin = 'C:\\'
  basepathlin = '/media/storage/houdini/data/'
  import platform
  platform = platform.system()
  
  finalpath = ''
  
  if platform == 'Linux':
    finalpath = basepathlin + path
  else:
    pathsplit = path.split('/')
    finalpath = pathwin
    foreach item pathsplit:
      finalpath = finalpath + item + '\'
  return finalpath

print makePath(path)

Would that not allow you to store your paths in the unix standard but, if you were on windows, convert them to the proper paths depending?  That does sound like a lot of hassle, though.   :(

Edited by Dee
Link to comment
Share on other sites

cygwin provides a command to do that and turn a path from windows to unix and vice versa. But even with that it was a bit of a pain, as passing windows line paths as arguments and variables, require to double the backslashes before hand, so they are not considered as escape characters.

It's all done now... I may just need to re-work the retry logic for certain cases.

 

Actually while on the topic... do you know of a way to tell if an exr is incomplete? Right now I am just checking with the file size, but it's hard to decide on an accurate threshold, as an incomplete exr still has partial data in it.

Link to comment
Share on other sites

Awesome!  I didn't know that.  Where is that?  It sounds like a useful function.

 

 

I just noticed there is iinfo which comes with houdini and check the integrity of an image file!
I think this will do the job!

=]

 

 

cygwin provides a command to do that and turn a path from windows to unix and vice versa. But even with that it was a bit of a pain, as passing windows line paths as arguments and variables, require to double the backslashes before hand, so they are not considered as escape characters.

It's all done now... I may just need to re-work the retry logic for certain cases.

 

Actually while on the topic... do you know of a way to tell if an exr is incomplete? Right now I am just checking with the file size, but it's hard to decide on an accurate threshold, as an incomplete exr still has partial data in it.

Link to comment
Share on other sites

$ iinfo
Usage: iinfo [-i] [-s] picfile [picfile*]
Gives information about picture files
        -i       check file integrity
        -s       supress output
        -b       print out basic information only
 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...