@@ -164,6 +164,8 @@ def _get_full_path_plug(plug):
164164 """
165165 node = plug .partition ('.' )[0 ]
166166 attr = plug .partition ('.' )[- 1 ]
167+ # NOTE: We assume the plug exists, so we assume the full path of
168+ # such a node must exist.
167169 node = maya .cmds .ls (node , long = True )[0 ]
168170 full_path = node + '.' + attr
169171 return str (full_path )
@@ -207,6 +209,7 @@ def _get_connected_nodes(tfm_node):
207209 node_name = tfm_node
208210 out_nodes = _get_upstream_nodes (node_name )
209211 all_nodes += out_nodes
212+ # TODO: Can we limit this more?
210213 max_iter_count = 9
211214 iter_count = 0
212215 while len (out_nodes ) > 0 :
@@ -216,18 +219,30 @@ def _get_connected_nodes(tfm_node):
216219 out_nodes = list (set (out_nodes ).difference (all_nodes ))
217220 all_nodes += out_nodes
218221 if iter_count > max_iter_count :
219- msg = 'Gathering connected nodes exceeded %r iterations,' ' stopping.'
222+ msg = 'Gathering connected nodes exceeded %r iterations, stopping.'
220223 LOG .warn (msg , max_iter_count )
221224 break
222225 return sorted (list (set (all_nodes )))
223226
224227
225228def __get_and_fill_cache_value (cache , key , func ):
229+ BAD_CACHE_VALUE = 'bad value'
226230 if cache is None :
227- return func ()
231+ try :
232+ value = func ()
233+ except RuntimeError :
234+ LOG .exception ('Could not evaluate func for key in cache: key=%r func=%r' , key , func )
235+ value = BAD_CACHE_VALUE
236+ return
228237 value = cache .get (key )
238+ if value == BAD_CACHE_VALUE :
239+ return None
229240 if value is None :
230- value = func ()
241+ try :
242+ value = func ()
243+ except RuntimeError :
244+ LOG .exception ('Could not evaluate func for key in cache: key=%r func=%r' , key , func )
245+ value = BAD_CACHE_VALUE
231246 cache [key ] = value
232247 return value
233248
@@ -317,7 +332,7 @@ def _convert_node_to_plugs(
317332 if not node_utils .attribute_exists (attr__ , node_ ):
318333 continue
319334 node_attr = node_ + '.' + attr__
320- compound_attrs = maya .cmds .listAttr (node_attr , multi = True )
335+ compound_attrs = maya .cmds .listAttr (node_attr , multi = True ) or []
321336 if len (compound_attrs ) > 1 :
322337 for array_item in compound_attrs :
323338 node_attr = node_ + '.' + array_item
0 commit comments