Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: Tim MeagherHey,
First, using the {{^File^}} implementation means that the property substituter will go through and attempt to substitute in the property prior to analyzing any of the python code. This is true for any case when you use the {{^^}} notation.
You can always set defaults to use in case the property isn't set, for example {{^File=NotDefined^}} or something similar. In this case, rather than the node failing straight away, if the File parameter is not defined, then the default of NotDefined is used.
Using the run time properties means within the python code means that the property is only attempted to be obtained if that line of code is ever executed.
You can try a similar thing by providing a default value (other than None) such that this won't throw an error if the property isn't defined - e.g. in your case, this could be something like:
inFile = self.properties.getString("ls.brain.node.tailFile. CreateTail.InputPath", "NotDefined")
However, this isn't really the best way.
Since the property isn't searched for unless the code reading it is executed, the best way to handle this is simply to make sure that this code isn't executed if you have an input pin.
This can be done using the following logic:
if len(self.inputs) == 0:
#Should attempt to read file parameter here
else:
#Attempt to read the stuff from input pin
Without knowing exactly what the use case is, this seems like it should fit with what you want to do.
I've attached a graph with a working example, which just spits out text onto the output pin, dependant on whether or not an input pin was present.
Attachments:
inputPinOrParmeter.brg