Hi Anthony,
Thanks for your reply. I'm only calling hasError on nodes which read files
and *have* no input tree, e.g. Read, ReadGeo etc. so I don't accept the
supposition that the method shouldn't, you know, work.
Doing this has been reliable so I'm going with it:
bool(nuke.expression("{0}.error".format(node.fullName()))
Cheers
On Thu, Feb 18, 2016 at 12:58 PM, Anthony Tan <[email protected]>
wrote:
> TL;DR: asking a node if it's broken isn't always safe, because it might
> not know it is broken. Try an alt approach? (see below)
>
>
> I'd hazard a guess that hasError is a pretty context-sensitive call, since
> you can error out depending on a whole host of factors (trivially, a
> missing frame won't error out til you hit it) and errors tend to stop DAG
> tree processing in interesting ways.
>
> Nuke 9.0v8/x64/Win7 here, my results using two groups, each containing a
> working read and a hard errored read (one pointing to a dummy file, and one
> pointing at a PDF - both the output pipe of the Group wrapping them). I
> made three variants, all executed from the script editor:
>
> def withHasError1():
> groups = nuke.allNodes('Group')
> reads = [read for grp in groups for read in nuke.allNodes(group = grp)
> if read.Class() == 'Read' and not read.hasError()]
> print 'withHasError1: ', [x.fullName() for x in reads]
>
> def withHasError2():
> groups = nuke.allNodes('Group')
> reads = []
> for grp in groups:
> with grp:
> reads += [node for node in nuke.allNodes() if node.Class() ==
> 'Read' and node.hasError()]
> print 'withHasError2: ', [x.fullName() for x in reads]
>
> def withHasError3():
> groups = nuke.allNodes('Group')
> reads = []
> for grp in groups:
> groupnodes = nuke.allNodes(group = grp)
> reads += [node for node in groupnodes if node.Class() == 'Read'
> and node.hasError()]
> print 'withHasError3: ', [x.fullName() for x in reads]
>
>
> def withHasError4():
> groups = nuke.allNodes('Group')
> reads = []
> for grp in groups:
> groupnodes = nuke.allNodes(group = grp)
> reads += [node for node in groupnodes if node.Class() == 'Read']
>
> for grp in groups:
> grp.begin()
> reads = [node for node in reads if node.hasError()]
> grp.end()
> print 'withHasError4: ', [x.fullName() for x in reads]
>
> def withoutHasError():
> groups = nuke.allNodes('Group')
> reads = [read for grp in groups for read in nuke.allNodes(group = grp)
> if read.Class() == 'Read']
> print 'withoutHasError: ', [x.fullName() for x in reads]
>
> print
> withHasError1()
> withHasError2()
> withHasError3()
> withHasError4()
> withoutHasError()
>
> # Result:
> # withHasError1: ['Group1.Read2']
> # withHasError2: ['Group1.Err', 'Group2.err']
> # withHasError3: ['Group1.Err', 'Group2.Read1', 'Group2.err']
> # withHasError4: ['Group1.Err', 'Group2.err']
> # withoutHasError: ['Group1.Read2', 'Group1.Err', 'Group2.Read1',
> 'Group2.err']
>
> I also stuck them in the nodes menu, and got the exact same result. Two
> thoughts:
>
> - hasError is probably (almost certainly) not what you're after.
> From the help: "Error state of the node itself, regardless of the state of
> the ops in its input tree. Note that an error on a node may not appear *if
> there is an error somewhere in its input tree,* because it may not be
> possible to validate the node itself correctly in that case" Emphasis mine,
> but errors are a bit.. twitchy. The group.begin() calls help bake down the
> problem a little, and give you the right result (that's my hunch at work)
> but...
>
>
> - If you just want to know if the read node isn't reading I'd suggest this
> approach instead
>
> def unreadableFile():
> groups = nuke.allNodes('Group')
> reads = [read for grp in groups for read in nuke.allNodes(group = grp)
> if read.Class() == 'Read' and not read.metadata("input/filename")]
> print 'withoutHasError: ', reads
>
> and ask the direct question to the Read node - what file did you read?
> (which is much more answerable than 'are you broken?')
>
>
> -Anthony
>
>
> On Tue, Feb 16, 2016, at 07:41 PM, Ean Carr wrote:
>
> Hi Sören,
>
> I'm seeing this exact behavior and it's baffling. Nuke 9.0v7.
>
> Did you ever report this? Anyone else?
>
> Cheers
> Ean
>
> On Fri, Sep 17, 2010 at 4:11 PM, sv022 <[email protected]> wrote:
>
> Hey folks,
>
> I've came across this really weird behaviour of Nuke, when using the
> hasError() method of a Read node.
>
> I've got a python script that gets all read nodes of the entire nuke
> script, i.e. all reads from root level and all reads within groups and all
> of their subgroups.
> Now I want only the nodes that have no error, put them in a list and
> return the list, which works flawlessly... as long as I run these functions
> out of the Script Editor.
>
> example code of the part that collects the reads in groups:
>
> def withHasError():
>
> groups = nuke.allNodes('Group')
> reads = [read for grp in groups for read in nuke.allNodes(group =
> grp) if read.Class() == 'Read' and not read.hasError()]
> print 'withHasError: ', reads
>
> def withoutHasError():
> groups = nuke.allNodes('Group')
> reads = [read for grp in groups for read in nuke.allNodes(group =
> grp) if read.Class() == 'Read']
> print 'withoutHasError: ', reads
>
> out of the Script Editor I get this:
>
> withHasError()
> withoutHasError()
>
> Result:
> withHasError: [<Read6 at 0x00000000049E8710>, <Read5 at
> 0x00000000049E86F0>]
>
> withoutHasError: [<Read6 at 0x00000000049E8710>, <Read5 at
> 0x00000000049E86F0>]
>
>
> now add these functions to the menu and run them again, you'll come to
> this:
>
>
> withHasError: []
>
> withoutHasError: [<Read6 at 0x00000000049E8710>, <Read5 at
> 0x00000000049E86F0>]
>
>
> huh?! why is that?
> Any of you guys got a different, more reliable solution to get rid of
> erroneous Reads or even an explanation why this doesn't work?
>
>
> Big thanks in advance!
> cheers, Sören
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
> *_______________________________________________*
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python