diff --git a/meshroom/core/attribute.py b/meshroom/core/attribute.py index 387d2ce1..32d02b62 100644 --- a/meshroom/core/attribute.py +++ b/meshroom/core/attribute.py @@ -362,7 +362,14 @@ class Attribute(BaseObject): Return the value. If it is a string, expressions will be evaluated. ''' if isinstance(self.value, str): - return Template(self.value).safe_substitute(os.environ) + substituted = Template(self.value).safe_substitute(os.environ) + try: + varResolved = substituted.format(**self.node._cmdVars) + return varResolved + except (KeyError, IndexError): + # Catch KeyErrors and IndexErros to be able to open files created prior to the support of + # relative variables (when self.node._cmdVars was not used to evaluate expressions in the attribute) + return substituted return self.value def getValueStr(self, withQuotes=True): diff --git a/meshroom/core/node.py b/meshroom/core/node.py index d67e3593..f6456d84 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -758,6 +758,8 @@ class BaseNode(BaseObject): """ Generate command variables using input attributes and resolved output attributes names and values. """ self._cmdVars["uid"] = self._uid + self._cmdVars["nodeCacheFolder"] = self.internalFolder + self._cmdVars["nodeSourceCodeFolder"] = self.sourceCodeFolder # Evaluate input params for name, attr in self._attributes.objects.items(): @@ -1022,8 +1024,10 @@ class BaseNode(BaseObject): # Update command variables / output attributes self._cmdVars = { - 'cache': cacheDir or self.graph.cacheDir, - 'nodeType': self.nodeType, + "cache": cacheDir or self.graph.cacheDir, + "nodeType": self.nodeType, + "nodeCacheFolder": self._internalFolder, + "nodeSourceCodeFolder": self.sourceCodeFolder } self._computeUid() self._buildCmdVars() @@ -1445,7 +1449,7 @@ class Node(BaseNode): self.packageName = self.nodeDesc.packageName self.packageVersion = self.nodeDesc.packageVersion - self._internalFolder = self.nodeDesc.internalFolder + self._internalFolder = "{cache}/{nodeType}/{uid}" self._sourceCodeFolder = self.nodeDesc.sourceCodeFolder for attrDesc in self.nodeDesc.inputs: