def test(): pytree = Tree('pytree', self.shot, 'ReadOnly') ip = pytree.getNode('\\ip') pytree.setDefault(ip) self.assertEqual( str(ip.record), 'Build_Signal(Build_With_Units(\\MAG_ROGOWSKI.SIGNALS:ROG_FG + 2100. * \\BTOR, "ampere"), *, DIM_OF(\\BTOR))' ) self.assertEqual(str(ip.record), str(ip.getData())) self.assertEqual(ip.segmented, ip.isSegmented()) self.assertEqual(ip.versions, ip.containsVersions()) self.assertEqual(ip.getNumSegments(), 0) self.assertEqual(ip.getSegment(0), None)
def copy_tree(shot): tree_raw = Tree('exl50', shot) tree_cop = Tree('exl50_copy', shot, 'NEW') pools = ["AI", "FBC"] for pool in pools: # nodes_list = [] nodes_array = tree_raw.getNode(pool).getDescendants() # nodes_list.extend(nodes_array) pool_nodes = [node.getNodeName() for node in nodes_array] tree_raw.setDefault(tree_raw.getNode(pool)) tree_cop.setDefault(tree_cop.addNode(pool, "STRUCTURE")) for node in pool_nodes: tree_cop.addNode(node, "SIGNAL").addTags(node) # print(node) try: data = tree_raw.getNode(node).getData() tree_cop.getNode(node).putData(data) print(str(shot) + ':' + node) except Exception as e: pass tree_raw.setDefault(tree_raw.getNode(r"\EXL50::TOP")) tree_cop.setDefault(tree_cop.getNode(r"\EXL50_COPY::TOP")) # tree_raw.setDefault(node.getParent()) # tree_cop.setDefault(node.getParent()) tree_cop.write()
def test(): pytree = Tree('pytree', self.shot, 'ReadOnly') ip = pytree.getNode('\\ip') pytree.setDefault(ip) self.assertEqual( str(ip.record), 'Build_Signal(Build_With_Units(\\MAG_ROGOWSKI.SIGNALS:ROG_FG + 2100. * \\BTOR, "ampere"), *, DIM_OF(\\BTOR))' ) self.assertEqual(str(ip.record), str(ip.getData())) self.assertEqual(ip.segmented, ip.isSegmented()) self.assertEqual(ip.versions, ip.containsVersions()) self.assertEqual(ip.getNumSegments(), 0) self.assertEqual(ip.getSegment(0), None) self.assertEqual(str(ip.getExtendedAttribute('ATT1')), '100') self.assertEqual(str(ip.getExtendedAttribute('ATT2')), '1 : 200 : *') self.assertEqual(str(ip.getExtendedAttribute('ATT3')), 'this is plasma current') self.assertEqual( str(ip.getExtendedAttributes()), "{'ATT3': 'this is plasma current', 'ATT2': 1 : 200 : *, 'ATT1': 100}" )
def doScopepanel(self): def getStringExp(self, name, response_headers): if name in self.args: try: response_headers.append( (name, str(Data.execute(self.args[name][-1]).data()))) except Exception: response_headers.append( (name + '_error:', str(sys.exc_info()))) def manageContinuousUpdate(self, x): if x.getShape().size == 1: new_max_x = x.data()[-1] else: new_max_x = x.data()[0][-1] curr_max_x = float(self.args['curr_max_x' + x_idx_s][-1]) displayed_width = float(self.args['displayed_width'][-1]) default_num_samples = float(self.args['default_num_samples'][-1]) num_samples = int( (new_max_x - curr_max_x) * default_num_samples / displayed_width) if new_max_x > curr_max_x and num_samples > 1: if issubclass(x.dtype.type, integer): min_req_x = floor(curr_max_x + 1) else: min_req_x = curr_max_x + finfo(new_max_x).eps update_function = 'MdsMisc->GetXYWave:DSC' infinity = sys.float_info.max if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': update_function = 'MdsMisc->GetXYWaveLongTimes:DSC' min_req_x = str(int(min_req_x)) + 'QU' infinity = str((1 << 63) - 1) + 'QU' sig = Data.execute( update_function + '(\'' + expr.replace('\\', '\\\\').replace('\'', '\\\'') + '\',' + str(min_req_x) + ',' + str(infinity) + ',' + str(num_samples) + ')') return makeData(sig.dim_of().data()), makeData(sig.data()) else: return Float64Array([]), Float64Array([]) response_headers = list() response_headers.append( ('Cache-Control', 'no-store, no-cache, must-revalidate')) response_headers.append(('Pragma', 'no-cache')) if 'tree' in self.args: Tree.usePrivateCtx() try: t = Tree(self.args['tree'][-1], int(self.args['shot'][-1].split(',')[0])) except: pass for name in ('title', 'xlabel', 'ylabel', 'xmin', 'xmax', 'ymin', 'ymax'): getStringExp(self, name, response_headers) continuous_update = 'continuous_update' in self.args sig_idx = 0 output = '' if 'tree' in self.args: shots = self.args['shot'][-1].split(',') for shot in shots: y_idx = 1 y_idx_s = '%d' % (y_idx, ) while 'y' + y_idx_s in self.args: x_idx_s = y_idx_s sig_idx = sig_idx + 1 sig_idx_s = '%d' % (sig_idx, ) expr = self.args['y' + y_idx_s][-1] y_idx = y_idx + 1 y_idx_s = '%d' % (y_idx, ) try: t = Tree(self.args['tree'][-1], int(shot)) response_headers.append(('SHOT' + sig_idx_s, str(t.shot))) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error opening tree %s, shot %s, error: %s' % (self.args['tree'][-1], shot, sys.exc_info()))) continue if 'default_node' in self.args: try: t.setDefault(t.getNode(self.args['default_node'][-1])) except Exception: response_headers.append(( 'ERROR' + sig_idx_s, 'Error setting default to %s in tree %s, shot %s, error: %s' % (self.args['default_node'][-1], self.args['tree'][-1], shot, sys.exc_info()))) continue try: sig = Data.execute(expr) if not continuous_update: y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue if 'x' + x_idx_s in self.args: expr = self.args['x' + x_idx_s][-1] try: x = Data.execute(expr) x = makeData(x.data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue else: try: x = makeData(sig.dim_of().data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s:, error: %s' % (expr, sys.exc_info()))) continue if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': x = Float64Array( x) # Javascript doesn't support 64 bit integers response_headers.append(('X_IS_DATETIME', 'true')) response_headers.append( ('X' + sig_idx_s + '_DATATYPE', x.__class__.__name__)) response_headers.append( ('Y' + sig_idx_s + '_DATATYPE', y.__class__.__name__)) response_headers.append( ('X' + sig_idx_s + '_LENGTH', str(len(x)))) response_headers.append( ('Y' + sig_idx_s + '_LENGTH', str(len(y)))) output = output + str(x.data().data) + str(y.data().data) else: y_idx = 1 y_idx_s = '%d' % (y_idx, ) while 'y' + y_idx_s in self.args: x_idx_s = y_idx_s expr = self.args['y' + y_idx_s][-1] y_idx = y_idx + 1 y_idx_s = '%d' % (y_idx, ) sig_idx = sig_idx + 1 sig_idx_s = '%d' % (sig_idx, ) try: sig = Data.execute(expr) if not continuous_update: y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue if 'x' + x_idx_s in self.args: expr = self.args['x' + x_idx_s][-1] try: x = Data.execute(expr) x = makeData(x.data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()))) continue else: try: x = makeData(sig.dim_of().data()) if continuous_update: x, y = manageContinuousUpdate(self, x) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s: "%s", error: %s' % (expr, sys.exc_info()))) continue if x.__class__.__name__ == 'Uint64Array' or x.__class__.__name__ == 'Int64Array': x = Float64Array( x) # Javascript doesn't support 64 bit integers response_headers.append(('X_IS_DATETIME', 'true')) response_headers.append( ('X' + sig_idx_s + '_DATATYPE', x.__class__.__name__)) response_headers.append( ('Y' + sig_idx_s + '_DATATYPE', y.__class__.__name__)) response_headers.append(('X' + sig_idx_s + '_LENGTH', str(len(x)))) response_headers.append(('Y' + sig_idx_s + '_LENGTH', str(len(y)))) output = output + str(x.data().data) + str(y.data().data) return ('200 OK', response_headers, output)
def thick(self): def testnci(thick, local, con, nci): l = local.S.__getattribute__(nci) t = thick.S.__getattribute__(nci) if nci.endswith("_nids"): l, t = str(l), str(t) try: c = str(con.get("getnci(getnci(S,$),'nid_number')", nci)) except TreeNNF: c = '[]' else: c = con.get("getnci(S,$)", nci) try: self.assertEqual(t, c) self.assertEqual(t, l) except: print(nci, t, l, c) raise server, server_port = self._setup_mdsip('ACTION_SERVER', 'ACTION_PORT', 7000 + self.index, True) svr, svr_log = self._start_mdsip(server, server_port, 'thick') try: con = Connection(server) self.assertEqual( con.get("zero([1,1,1,1,1,1,1,1],1)").tolist(), [[[[[[[[0]]]]]]]]) with Tree(self.tree, -1, "new") as local: local.addNode(self.treesub, "SUBTREE") s = local.addNode("S", "SIGNAL") s.addTag("tagS") s.record = ADD(Float32(1), Float32(2)) t = local.addNode("T", "TEXT") t.addNode("TT", "TEXT").addTag("tagTT") t.record = t.TT t.TT = "recTT" local.write() with Tree(self.treesub, -1, "new") as sub: sub.addNode("OK") sub.write() local.normal() Tree.setCurrent(self.tree, 7) setenv("%s_path" % self.tree, "%s::" % server) print(con.get("getenv($//'_path')", self.tree)) con.get("TreeShr->TreeOpen(ref($),val($),val(1))", self.tree, -1) thick = Tree(self.tree, -1) thick.createPulse(1) thick1 = Tree(self.tree, 1) self.assertEqual( getattr(local, self.treesub.upper()).OK.nid, getattr(thick1, self.treesub.upper()).OK.nid) local_filename = local.getFileName() thick_filename = thick.getFileName() self.assertTrue("::" in thick_filename, thick_filename) self.assertTrue(local_filename, thick_filename.split("::", 1)[1]) """ TreeTurnOff / TreeTurnOn """ thick.S.on = False self.assertEqual(local.S.on, False) thick.S.on = True self.assertEqual(local.S.on, True) """ TreeSetCurrentShotId / TreeGetCurrentShotId """ Tree.setCurrent(self.tree, 1) self.assertEqual(Tree.getCurrent(self.tree), 1) """ TreeGetRecord / TreeSetRecord """ self.assertEqual(str(local.S.record), "1. + 2.") self.assertEqual(str(thick.S.record), "1. + 2.") thick.S.record = ADD(Float32(2), Float32(4)) self.assertEqual(str(local.S.record), "2. + 4.") self.assertEqual(str(thick.S.record), "2. + 4.") self.assertEqual(str(local.T.record), str(thick.T.record)) """ GetDefaultNid / SetDefaultNid """ self.assertEqual(thick.getDefault(), thick.top) thick.setDefault(thick.S) self.assertEqual(thick.getDefault(), thick.top.S) thick.setDefault(thick.top) """ FindNodeWildRemote """ self.assertEqual(str(thick.getNodeWild("T*")), str(local.getNodeWild("T*"))) """ FindTagWildRemote """ self.assertEqual(thick.findTags("*"), local.findTags("*")) """ nci """ thick.S.write_once = True self.assertEqual(thick.S.write_once, True) for nci in ( 'on', 'depth', 'usage_str', 'dtype', 'length', 'rlength', 'fullpath', 'minpath', 'member_nids', 'children_nids', 'rfa', 'write_once', ): testnci(thick, local, con, nci) """ new stuff """ self.assertEqual(local.getFileName(), con.get("treefilename($,-1)", self.tree)) finally: if svr_log: svr_log.close() self._stop_mdsip((svr, server))
def doScopepanel(self): def getStringExp(self,name,response_headers): if name in self.args: try: response_headers.append((name,str(Data.execute(self.args[name][-1]).data()))) except Exception: response_headers.append((name,str(sys.exc_info()[1]))) response_headers=list() response_headers.append(('Cache-Control','no-store, no-cache, must-revalidate')) response_headers.append(('Pragma','no-cache')) if 'tree' in self.args: Tree.usePrivateCtx() try: t=Tree(self.args['tree'][-1],int(self.args['shot'][-1].split(',')[0])) except: pass for name in ('title','xlabel','ylabel','xmin','xmax','ymin','ymax'): getStringExp(self,name,response_headers) sig_idx=0 output='' if 'tree' in self.args: shots=self.args['shot'][-1].split(',') for shot in shots: y_idx=1 y_idx_s='%d' % (y_idx,) while 'y'+y_idx_s in self.args: x_idx_s=y_idx_s sig_idx=sig_idx+1 sig_idx_s='%d' % (sig_idx,) expr=self.args['y'+y_idx_s][-1] y_idx=y_idx+1 y_idx_s='%d' % (y_idx,) try: t=Tree(self.args['tree'][-1],int(shot)) response_headers.append(('SHOT'+sig_idx_s,str(t.shot))) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error opening tree %s, shot %s, error: %s' % (self.args['tree'][-1],shot,sys.exc_info()[1]))) continue if 'default_node' in self.args: try: t.setDefault(t.getNode(self.args['default_node'][-1])) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error setting default to %s in tree %s, shot %s, error: %s' % (self.args['default_node'][-1], self.args['tree'][-1],shot,sys.exc_info()[1]))) continue try: sig=Data.execute(expr) y=makeData(sig.data()) except Exception: response_headers.append(('ERROR' + sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue if 'x'+x_idx_s in self.args: expr=self.args['x'+x_idx_s][-1] try: x=Data.execute(expr) x=makeData(x.data()) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue else: try: x=makeData(sig.dim_of().data()) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error getting x axis of %s: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue response_headers.append(('X'+sig_idx_s+'_DATATYPE',x.__class__.__name__)) response_headers.append(('Y'+sig_idx_s+'_DATATYPE',y.__class__.__name__)) response_headers.append(('X'+sig_idx_s+'_LENGTH',str(len(x)))) response_headers.append(('Y'+sig_idx_s+'_LENGTH',str(len(y)))) output=output+str(x.data().data)+str(y.data().data) else: y_idx=1 y_idx_s='%d' % (y_idx,) while 'y'+y_idx_s in self.args: x_idx_s = y_idx_s expr=self.args['y'+y_idx_s][-1] y_idx=y_idx+1 y_idx_s='%d' % (y_idx,) sig_idx=sig_idx+1 sig_idx_s='%d' % (sig_idx,) try: sig=Data.execute(expr) y=makeData(sig.data()) except Exception: response_headers.append(('ERROR' + sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue if 'x'+x_idx_s in self.args: expr=self.args['x'+x_idx_s][-1] try: x=Data.execute(expr) x=makeData(x.data()) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue else: try: x=makeData(sig.dim_of().data()) except Exception: response_headers.append(('ERROR'+sig_idx_s,'Error getting x axis of %s: "%s", error: %s' % (expr,sys.exc_info()[1]))) continue response_headers.append(('X'+sig_idx_s+'_DATATYPE',x.__class__.__name__)) response_headers.append(('Y'+sig_idx_s+'_DATATYPE',y.__class__.__name__)) response_headers.append(('X'+sig_idx_s+'_LENGTH',str(len(x)))) response_headers.append(('Y'+sig_idx_s+'_LENGTH',str(len(y)))) output=output+str(x.data().data)+str(y.data().data) return ('200 OK', response_headers, output)
def doScopepanel(self): def getStringExp(self, name, response_headers): if name in self.args: try: response_headers.append( (name, str(Data.execute(self.args[name][-1]).data()))) except Exception: response_headers.append((name, str(sys.exc_info()[1]))) response_headers = list() response_headers.append( ('Cache-Control', 'no-store, no-cache, must-revalidate')) response_headers.append(('Pragma', 'no-cache')) if 'tree' in self.args: Tree.usePrivateCtx() try: t = Tree(self.args['tree'][-1], int(self.args['shot'][-1].split(',')[0])) except: pass for name in ('title', 'xlabel', 'ylabel', 'xmin', 'xmax', 'ymin', 'ymax'): getStringExp(self, name, response_headers) sig_idx = 0 output = '' if 'tree' in self.args: shots = self.args['shot'][-1].split(',') for shot in shots: y_idx = 1 y_idx_s = '%d' % (y_idx, ) while 'y' + y_idx_s in self.args: x_idx_s = y_idx_s sig_idx = sig_idx + 1 sig_idx_s = '%d' % (sig_idx, ) expr = self.args['y' + y_idx_s][-1] y_idx = y_idx + 1 y_idx_s = '%d' % (y_idx, ) try: t = Tree(self.args['tree'][-1], int(shot)) response_headers.append(('SHOT' + sig_idx_s, str(t.shot))) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error opening tree %s, shot %s, error: %s' % (self.args['tree'][-1], shot, sys.exc_info()[1]))) continue if 'default_node' in self.args: try: t.setDefault(t.getNode(self.args['default_node'][-1])) except Exception: response_headers.append(( 'ERROR' + sig_idx_s, 'Error setting default to %s in tree %s, shot %s, error: %s' % (self.args['default_node'][-1], self.args['tree'][-1], shot, sys.exc_info()[1]))) continue try: sig = Data.execute(expr) y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue if 'x' + x_idx_s in self.args: expr = self.args['x' + x_idx_s][-1] try: x = Data.execute(expr) x = makeData(x.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue else: try: x = makeData(sig.dim_of().data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue response_headers.append( ('X' + sig_idx_s + '_DATATYPE', x.__class__.__name__)) response_headers.append( ('Y' + sig_idx_s + '_DATATYPE', y.__class__.__name__)) response_headers.append( ('X' + sig_idx_s + '_LENGTH', str(len(x)))) response_headers.append( ('Y' + sig_idx_s + '_LENGTH', str(len(y)))) output = output + str(x.data().data) + str(y.data().data) else: y_idx = 1 y_idx_s = '%d' % (y_idx, ) while 'y' + y_idx_s in self.args: x_idx_s = y_idx_s expr = self.args['y' + y_idx_s][-1] y_idx = y_idx + 1 y_idx_s = '%d' % (y_idx, ) sig_idx = sig_idx + 1 sig_idx_s = '%d' % (sig_idx, ) try: sig = Data.execute(expr) y = makeData(sig.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue if 'x' + x_idx_s in self.args: expr = self.args['x' + x_idx_s][-1] try: x = Data.execute(expr) x = makeData(x.data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error evaluating expression: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue else: try: x = makeData(sig.dim_of().data()) except Exception: response_headers.append( ('ERROR' + sig_idx_s, 'Error getting x axis of %s: "%s", error: %s' % (expr, sys.exc_info()[1]))) continue response_headers.append( ('X' + sig_idx_s + '_DATATYPE', x.__class__.__name__)) response_headers.append( ('Y' + sig_idx_s + '_DATATYPE', y.__class__.__name__)) response_headers.append(('X' + sig_idx_s + '_LENGTH', str(len(x)))) response_headers.append(('Y' + sig_idx_s + '_LENGTH', str(len(y)))) output = output + str(x.data().data) + str(y.data().data) return ('200 OK', response_headers, output)
def test(): from numpy import array, int32 pytree = Tree('pytree', self.shot, 'ReadOnly') top = TreeNode(0, pytree) members = pytree.getNodeWild(':*') self.assertEqual((members == top.member_nids).all(), True) self.assertEqual((members == top.getMembers()).all(), True) self.assertEqual(top.member.nid_number, members[0].nid_number) member = top.member for idx in range(1, len(members)): self.assertEqual(member.brother.nid_number, members[idx].nid_number) member = member.brother children = pytree.getNodeWild('.*') self.assertEqual((children == top.children_nids).all(), True) self.assertEqual((children == top.getChildren()).all(), True) self.assertEqual(top.child.nid_number, children[0].nid_number) child = top.child for idx in range(1, len(children)): self.assertEqual(child.brother.nid_number, children[idx].nid_number) child = child.brother self.assertEqual(top.child.nid_number, pytree.getNode(str(top.child)).nid_number) self.assertEqual(top.child.child.parent.nid_number, top.child.nid_number) x = array(int32(0)).repeat(len(members) + len(children)) x[0:len(children)] = children.nid_number.data() x[len(children):] = members.nid_number.data() self.assertEqual( (makeArray(x) == top.descendants.nid_number).all(), True) self.assertEqual( (top.descendants.nid_number == top.getDescendants().nid_number ).all(), True) self.assertEqual(top.child.child.depth, 3) self.assertEqual(top.getNumDescendants(), len(x)) self.assertEqual(top.getNumMembers(), len(members)) self.assertEqual(top.getNumChildren(), len(children)) self.assertEqual(top.number_of_members, len(members)) self.assertEqual(top.number_of_children, len(children)) self.assertEqual(top.number_of_descendants, len(x)) devs = pytree.getNodeWild('\\PYTREESUB::TOP.***', 'DEVICE') dev = devs[0].conglomerate_nids self.assertEqual( (dev.nid_number == devs[0].getConglomerateNodes().nid_number ).all(), True) self.assertEqual( (dev.conglomerate_elt == makeArray(array(range(len(dev))) + 1)).all(), True) for idx in range(len(dev)): self.assertEqual(dev[idx].conglomerate_elt, idx + 1) self.assertEqual(dev[idx].getConglomerateElt(), idx + 1) self.assertEqual(top.child.is_child, True) self.assertEqual(top.child.is_member, False) self.assertEqual(top.member.is_child, False) self.assertEqual(top.member.is_member, True) self.assertEqual(top.child.is_child, top.child.isChild()) self.assertEqual(top.child.is_member, top.child.isMember()) ip = pytree.getNode('\\ip') pytree.setDefault(ip) self.assertEqual(ip.fullpath, "\\PYTREE::TOP.PYTREESUB:IP") self.assertEqual(ip.fullpath, ip.getFullPath()) self.assertEqual(ip.minpath, "\\IP") self.assertEqual(ip.minpath, ip.getMinPath()) self.assertEqual(ip.node_name, 'IP') self.assertEqual(ip.node_name, ip.getNodeName()) self.assertEqual(ip.path, "\\PYTREESUB::IP") self.assertEqual(ip.path, ip.getPath())
def test(): pytree = Tree('pytree', self.shot, 'ReadOnly') pytree2 = Tree('pytree', self.shot, 'ReadOnly') pytree.setDefault(pytree._IP) self.assertEqual(str(pytree.getDefault()), '\\PYTREESUB::IP') self.assertEqual(str(pytree2.getDefault()), '\\PYTREE::TOP')
while 'y'+y_idx_s in self.args: x_idx_s=y_idx_s sig_idx=sig_idx+1 sig_idx_s='%d' % (sig_idx,) expr=self.args['y'+y_idx_s][-1] y_idx=y_idx+1 y_idx_s='%d' % (y_idx,) try: t=Tree(self.args['tree'][-1],int(shot)) response_headers.append(('SHOT'+sig_idx_s,str(t.shot))) except Exception,e: response_headers.append(('ERROR'+sig_idx_s,'Error opening tree %s, shot %s, error: %s' % (self.args['tree'][-1],shot,e))) continue if 'default_node' in self.args: try: t.setDefault(t.getNode(self.args['default_node'][-1])) except Exception,e: response_headers.append(('ERROR'+sig_idx_s,'Error setting default to %s in tree %s, shot %s, error: %s' % (self.args['default_node'][-1], self.args['tree'][-1],shot,e))) continue try: sig=Data.execute(expr) y=makeData(sig.data()) except Exception,e: response_headers.append(('ERROR' + sig_idx_s,'Error evaluating expression: "%s", error: %s' % (expr,e))) continue if 'x'+x_idx_s in self.args: expr=self.args['x'+x_idx_s][-1] try: x=Data.execute(expr) x=makeData(x.data())