shell_tools.py (2131B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\nodegraph\common\shell_tools.py 2 from __future__ import print_function 3 import os 4 ng = sm.GetService('node_graph') 5 6 def print_graphs(): 7 info_lines = _get_active_graphs_info_lines() 8 for line in info_lines: 9 print(line) 10 11 12 def get_active_graphs_info(): 13 info_lines = _get_active_graphs_info_lines() 14 return '<br>'.join(info_lines) 15 16 17 def _get_active_graphs_info_lines(): 18 info_lines = ['***** Active Node Graphs *****'] 19 20 def get_info(graphs, parent_instance = None, depth = 0): 21 lines = [] 22 for g in graphs.itervalues(): 23 if g.parent_instance_id == parent_instance: 24 lines.append('-' * depth + ' instance_id: ' + str(g.instance_id)) 25 lines.append(' ' * depth + ' node_graph_id: ' + str(g.graph_id)) 26 lines.append(' ' * depth + ' active_node_ids: ' + str(list(g.active_node_ids))) 27 lines += get_info(graphs, g.instance_id, depth + 1) 28 29 return lines 30 31 active_graphs = sm.GetService('node_graph').get_active_node_graphs() 32 info_lines += get_info(active_graphs) 33 info_lines.append('***** End Active Node Graphs *****') 34 return info_lines 35 36 37 def print_bb(g): 38 print('***** Blackboard (', g.instance_id, ') *****') 39 for k, v in g.context.values.items(): 40 print(k, ':', v) 41 42 print('***** end ******') 43 44 45 def get_graph(instance_id = None): 46 ng = sm.GetService('node_graph') 47 if instance_id: 48 return ng.get_active_node_graph(instance_id) 49 all_keys = ng.get_active_node_graphs().keys() 50 if not all_keys: 51 return None 52 inst_id = all_keys[0] 53 inst_id = ng.get_root_instance_id(inst_id) 54 return ng.get_active_node_graph(inst_id) 55 56 57 def stop_all(): 58 ng = sm.GetService('node_graph') 59 ng.stop_all_node_graphs() 60 61 62 def reload_graphs(): 63 import nodegraph.common.nodedata as nd 64 nd.NodeGraphLoader.ReloadDataFromDisk() 65 66 67 def node_info(): 68 machoNet = sm.GetService('machoNet') 69 print('Pid:', os.getpid(), 'Node Index:', machoNet.nodeIndex, 'Node ID:', machoNet.GetNodeID())