mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-03 12:16:51 +02:00
[core] Add default relative paths to the command line variables
Add 2 default entries to the command line variables: - `nodeCacheFolder`, which contains the location of the cache folder - `nodeSourceCodeFolder`, which contains the location of the file describing the node
This commit is contained in:
parent
40fd46d476
commit
6cbb97d9a8
2 changed files with 15 additions and 4 deletions
|
@ -362,7 +362,14 @@ class Attribute(BaseObject):
|
||||||
Return the value. If it is a string, expressions will be evaluated.
|
Return the value. If it is a string, expressions will be evaluated.
|
||||||
'''
|
'''
|
||||||
if isinstance(self.value, str):
|
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
|
return self.value
|
||||||
|
|
||||||
def getValueStr(self, withQuotes=True):
|
def getValueStr(self, withQuotes=True):
|
||||||
|
|
|
@ -758,6 +758,8 @@ class BaseNode(BaseObject):
|
||||||
|
|
||||||
""" Generate command variables using input attributes and resolved output attributes names and values. """
|
""" Generate command variables using input attributes and resolved output attributes names and values. """
|
||||||
self._cmdVars["uid"] = self._uid
|
self._cmdVars["uid"] = self._uid
|
||||||
|
self._cmdVars["nodeCacheFolder"] = self.internalFolder
|
||||||
|
self._cmdVars["nodeSourceCodeFolder"] = self.sourceCodeFolder
|
||||||
|
|
||||||
# Evaluate input params
|
# Evaluate input params
|
||||||
for name, attr in self._attributes.objects.items():
|
for name, attr in self._attributes.objects.items():
|
||||||
|
@ -1022,8 +1024,10 @@ class BaseNode(BaseObject):
|
||||||
|
|
||||||
# Update command variables / output attributes
|
# Update command variables / output attributes
|
||||||
self._cmdVars = {
|
self._cmdVars = {
|
||||||
'cache': cacheDir or self.graph.cacheDir,
|
"cache": cacheDir or self.graph.cacheDir,
|
||||||
'nodeType': self.nodeType,
|
"nodeType": self.nodeType,
|
||||||
|
"nodeCacheFolder": self._internalFolder,
|
||||||
|
"nodeSourceCodeFolder": self.sourceCodeFolder
|
||||||
}
|
}
|
||||||
self._computeUid()
|
self._computeUid()
|
||||||
self._buildCmdVars()
|
self._buildCmdVars()
|
||||||
|
@ -1445,7 +1449,7 @@ class Node(BaseNode):
|
||||||
|
|
||||||
self.packageName = self.nodeDesc.packageName
|
self.packageName = self.nodeDesc.packageName
|
||||||
self.packageVersion = self.nodeDesc.packageVersion
|
self.packageVersion = self.nodeDesc.packageVersion
|
||||||
self._internalFolder = self.nodeDesc.internalFolder
|
self._internalFolder = "{cache}/{nodeType}/{uid}"
|
||||||
self._sourceCodeFolder = self.nodeDesc.sourceCodeFolder
|
self._sourceCodeFolder = self.nodeDesc.sourceCodeFolder
|
||||||
|
|
||||||
for attrDesc in self.nodeDesc.inputs:
|
for attrDesc in self.nodeDesc.inputs:
|
||||||
|
|
Loading…
Add table
Reference in a new issue