Example #1
0
        def execute(self):
            """Execute the PutMany by sending the instructions to the remote server. The remote server will attempt to
            put the data in each of the nodes listed and after completion return a dict instance of the status of each put.
            @return: dict instance with status of each put. The key of the result will be the node name.
            """
            if self.connection is None:
                self.result=Dictionary()
                for val in self:
                    node=val['node']
                    try:
                        exp='TreePut($,$'
                        args=[node,val['exp']]
                        for i in range(len(val['args'])):
                            exp=exp+',$'
                            args.append(val['args'][i])
                        exp=exp+')'
                        status=Data.execute(exp,tuple(args))
                        if (status & 1) == 1:
                            self.result[node]='Success'
                        else:
                            self.result[node]=MdsGetMsg(status)
                    except Exception:
                        import sys
                        e=sys.exc_info()[1]
                        self.result[node]=str(e)
                return self.result
            else:
                ans=self.connection.get("PutManyExecute($)",self.serialize())
            if isinstance(ans,str):
                raise Exception("Error putting any data: "+ans)
#            self.result=ans.deserialize()
            self.result=ans.deserialize(ans)
            return self.result
Example #2
0
 def __getitem__(self,idx):
     """Subscripting <==> signal[subscript]. Uses the dimension information for subscripting
     @param idx: index or Range used for subscripting the signal based on the signals dimensions
     @type idx: Data
     @rtype: Signal
     """
     return Data.execute('$[$]',self,idx)
Example #3
0
 def oplot(self,y,x=None,row=1,col=1,color="black"):
     """Overplot data in scope panel
     @param y: Y-axis of the data to plot
     @type y: Array
     @param x: X-axis of the data to plot in the panel
     @type x: Array
     @param row: Row of plot panel where row 1 is the top row
     @type row: int
     @param col: Column of plot panel where column 1 is the left column
     @type col: int
     @param color: Color of the plot line
     @type color: str
     @rtype: None
     """
     if x is None:
         x=Data.dim_of(y)
     Data.execute("JavaAddSignal($,$,$,$,$,$)",self.idx,y,x,row,col,color)
Example #4
0
 def nciInfo(self):
     ip=self.pytree2.getNode('\\ip')
     self.assertEqual(ip.getUsage(),'SIGNAL')
     self.assertEqual(ip.usage,ip.getUsage())
     if ip.getClass() != 'CLASS_R':
         print( "ip.nid=%d" % (ip.nid,))
         print( "Error with ip in %s" % (str(ip.tree),))
         from os import _exit
         _exit(1)
     self.assertEqual(ip.getClass(),'CLASS_R')
     self.assertEqual(ip.class_str,'CLASS_R')
     self.assertEqual(ip.compressible,False)
     self.assertEqual(ip.compressible,ip.isCompressible())
     self.assertEqual(ip.compress_on_put,True)
     self.assertEqual(ip.compress_on_put,ip.isCompressOnPut())
     self.assertEqual(ip.data_in_nci,False)
     self.assertEqual(ip.on,True)
     self.assertEqual(ip.on,ip.isOn())
     self.assertEqual(ip.do_not_compress,False)
     self.assertEqual(ip.do_not_compress,ip.isDoNotCompress())
     self.assertEqual(ip.dtype_str,'DTYPE_SIGNAL')
     self.assertEqual(ip.dtype_str,ip.getDtype())
     self.assertEqual(ip.essential,False)
     self.assertEqual(ip.essential,ip.isEssential())
     mhdtree=self.pytree2.getNode('\\PYTREESUB::TOP')
     self.assertEqual(mhdtree.include_in_pulse,True)
     self.assertEqual(mhdtree.include_in_pulse,mhdtree.isIncludedInPulse())
     self.assertEqual(ip.length,int(Data.execute('getnci($,"LENGTH")',ip)))
     self.assertEqual(ip.length,ip.getLength())
     self.assertEqual(ip.no_write_shot,False)
     self.assertEqual(ip.no_write_shot,ip.isNoWriteShot())
     self.assertEqual(ip.no_write_model,False)
     self.assertEqual(ip.no_write_model,ip.isNoWriteModel())
     self.assertEqual(ip.write_once,False)
     self.assertEqual(ip.write_once,ip.isWriteOnce())
     devs=self.pytree2.getNodeWild('\\PYTREESUB::TOP.***','DEVICE')
     dev=devs[0].conglomerate_nids
     self.assertEqual(dev[3].original_part_name,':COMMENT')
     self.assertEqual(dev[3].original_part_name,dev[3].getOriginalPartName())
     """
     self.assertEqual(ip.owner_id,Uint32(65602548))
     """
     self.assertEqual(ip.owner_id,ip.getOwnerId())
     self.assertEqual(ip.rlength,168)
     self.assertEqual(ip.rlength,ip.getCompressedLength())
     self.assertEqual(ip.setup_information,False)
     self.assertEqual(ip.setup_information,ip.isSetup())
     self.assertEqual(ip.status,0)
     self.assertEqual(ip.status,ip.getStatus())
     self.assertEqual((ip.tags==makeArray(['IP','MAGNETICS_IP','MAG_IP','MAGNETICS_PLASMA_CURRENT','MAG_PLASMA_CURRENT'])).all(),True)
     self.assertEqual((ip.tags==ip.getTags()).all(),True)
     """
     self.assertEqual(ip.time_inserted.date,' 4-FEB-2005 16:55:28.00')
     """
     self.assertEqual(ip.time_inserted,ip.getTimeInserted())
     return
Example #5
0
def test_all(*arg):
    warnings.filterwarnings("ignore","tmpnam",RuntimeWarning,__name__)
    dir=os.tmpnam()
    print "Creating trees in %s" % (dir,)
    cleanup.dir=dir
    try:
      os.mkdir(dir)
    except:
      pass
    Data.execute('setenv("pytree_path='+dir.replace('\\','\\\\')+'")')
    Data.execute('setenv("pytreesub_path='+dir.replace('\\','\\\\')+'")')
    tests=list()
    tests.append(treeUnitTest.suite())
    if os.getenv('TEST_THREADS') is not None:
	tests.append(threadsUnitTest.suite())
    tests.append(dataUnitTest.suite())
    tests.append(TestSuite([cleanup('cleanup')]))
    ans = TestSuite(tests)
    return ans
Example #6
0
 def execute(self):
     """Execute the list. Send the list to the remote server for evaluation and return the answer as a dict instance."""
     if self.connection is None:
         self.result=Dictionary()
         for val in self:
             name=val['name']
             try:
                 self.result[name]=Dictionary({'value':Data.execute('data('+val['exp']+')',tuple(val['args']))})
             except Exception,e:
                 self.result[name]=Dictionary({'error':str(e)})
         return self.result
Example #7
0
 def __init__(self,title='',x=100,y=100,width=400,height=300):
     """Initialize a Scope instance
     @param title: Title of scop window
     @type title: string
     @param x: X location on screen of scope window in pixels from left edge
     @type x: int
     @param y: Y location on screen of scope window in pixels from the top edge
     @type y: int
     @param width: Width of the scope window in pixels
     @type width: int
     @param height: Height of the scope window in pixels
     @type height: int
     @rtype: None
     """
     self.idx=Data.execute("JavaNewWindow($,-1)",title)
     self.x=x
     self.y=y
     self.width=width
     self.height=height
Example #8
0
        def execute(self):
            """Execute the list. Send the list to the remote server for evaluation and return the answer as a dict instance."""
            if self.connection is None:
                self.result=Dictionary()
                for val in self:
                    name=val['name']
                    try:
                        self.result[name]=Dictionary({'value':Data.execute('data('+val['exp']+')',tuple(val['args']))})
                    except Exception:
                        import sys
                        e=sys.exc_info()[1]
                        self.result[name]=Dictionary({'error':str(e)})
                return self.result
            else:
                ans=self.connection.get("GetManyExecute($)",self.serialize())
            if isinstance(ans,str):
                raise Exception("Error fetching data: "+ans)
            self.result=ans.deserialize(ans)
#            self.result=ans.deserialize()
            return self.result
Example #9
0
 def execute(self):
     """Execute the PutMany by sending the instructions to the remote server. The remote server will attempt to
     put the data in each of the nodes listed and after completion return a dict instance of the status of each put.
     @return: dict instance with status of each put. The key of the result will be the node name.
     """
     if self.connection is None:
         self.result=Dictionary()
         for val in self:
             node=val['node']
             try:
                 exp='TreePut($,$'
                 args=[node,val['exp']]
                 for i in range(len(val['args'])):
                     exp=exp+',$'
                     args.append(val['args'][i])
                 exp=exp+')'
                 status=Data.execute(exp,tuple(args))
                 if (status & 1) == 1:
                     self.result[node]='Success'
                 else:
                     self.result[node]=MdsGetMsg(status)
             except Exception,e:
                 self.result[node]=str(e)
         return self.result
Example #10
0
def test_all(*arg):
    import tempfile
    dir=tempfile.mkdtemp()
    print ("Creating trees in %s" % (dir,))
    cleanup.dir=dir
    if (str(Data.execute('getenv("TEST_DISTRIBUTED_TREES")')) == ""):
        hostpart=""
    else:
        hostpart="localhost::" 
    Data.execute('setenv("pytree_path='+hostpart+dir.replace('\\','\\\\')+'")')
    Data.execute('setenv("pytreesub_path='+hostpart+dir.replace('\\','\\\\')+'")')
    print (Data.execute('getenv("pytree_path")'))
    tests=list()
    tests.append(treeTests())
    if os.getenv('TEST_THREADS') is not None:
        tests.append(threadsSuite())
    tests.append(dataSuite())
    tests.append(TestSuite([cleanup('cleanup')]))
    return TestSuite(tests)
Example #11
0
 def show(self):
     """Show the scope window
     @rtype: None
     """
     Data.execute("JavaShowWindow($,$,$,$,$)",self.idx,self.x,self.y,self.width,self.height)