Example afterProjectLoad callback for handling dirmapping?


#1

Hello. Our studio has windows desktops and a linux render farm. Our composites are authored in windows and rendered on linux. I haven’t found anything in the documentation for handling differences in dos->unix filepaths but did see that there is a python api and an afterProjectLoad callback.

I have zero experience with Natron. I"m not sure if I’m going down the best route to solve this problem or not. Any advice would be greatly appreciated.

Thanks in advance.


#2

Natron can use relative path so maybe this isn’t an issue ?
But your idea of path remapping can be a good idea too if you’re using absolute path.


#3

As soap mentioned you can just prefix your input files with a variable from the Project Settings. You can create a new variable to point to a specific location, e.g:

Then indeed, in the afterProjectLoad callback you could do something like this:

def myAfterProjectLoadCallback(app):
    table = app.projectPaths.getTable()
    for i in table:
        if table[i][0] == "MyFiles":
            if NatronEngine.natron.isLinux():
                table[i][1] = "...."
            elif NatronEngine.natron.isMacOSX():
                table[i][1] = "...."
           elif NatronEngine.natron.isWindows():
                table[i][1] = "...."
           break
     app.projectPaths.setTable(table)

I just added the setTable(table) function to the Python API, it was missing before. It will be available in the next snapshots and next minor release.


#4

Thanks for the replies everyone. Much appreciated. When is the next minor release going to be available? Might I also suggest allowing for the expansion of environment variables in Read/Write nodes file paths?


#5

We might add a single environment variable for this purpose, but expanding all environment variables would probably slow down the whole thing