Changeset 1123 for trunk/bindings/python


Ignore:
Timestamp:
14/11/08 21:07:48 (4 years ago)
Author:
Paul Kienzle
Message:

python: suppress error printing in NAPI. Refs #101.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bindings/python/nxs/napi.py

    r1121 r1123  
    9090  'uint8' 'uint16' 'uint32' 'uint64' 
    9191 
    92   Use 'char' for string data.   
     92  Use 'char' for string data. 
    9393 
    9494You can use the numpy A.dtype attribute for the type of array A. 
     
    248248    raise OSError, "Set NEXUSLIB or move NeXus to one of: %s"%(", ".join(files)) 
    249249 
     250def _init(): 
     251    lib = _libnexus() 
     252    lib.NXMDisableErrorReporting() 
     253    return lib 
     254 
     255# Define the interface to the dll 
     256nxlib = _init() 
    250257 
    251258 
     
    258265class NeXus(object): 
    259266 
    260     # Define the interface to the dll 
    261     lib = _libnexus() 
    262  
    263267    # ==== File ==== 
    264     #lib.nxiopen_.restype = c_int 
    265     #lib.nxiopen_.argtypes = [c_char_p, c_int, c_void_pp] 
     268    nxlib.nxiopen_.restype = c_int 
     269    nxlib.nxiopen_.argtypes = [c_char_p, c_int, c_void_pp] 
    266270    def __init__(self, filename, mode='r'): 
    267271        """ 
     
    276280            nxs.ACC_CREATEXML 'wx' 
    277281 
     282        Raises ValueError if the open mode is invalid. 
     283 
    278284        Raises RuntimeError if the file could not be opened, with the 
    279285        filename as part of the error message. 
     
    291297        self.handle = c_void_p(None) 
    292298        self.path = [] 
    293         status = self.lib.nxiopen_(filename,mode,_ref(self.handle)) 
     299        status = nxlib.nxiopen_(filename,mode,_ref(self.handle)) 
    294300        if status == ERROR: 
    295301            if mode in [ACC_READ, ACC_RDWR]: 
     
    317323        """ 
    318324        Opens the NeXus file handle if it is not already open. 
     325 
     326        Raises RuntimeError if the file could not be opened. 
     327 
     328        Corresponds to NXopen(filename,mode,&handle) 
    319329        """ 
    320330        if self.isopen: return 
     
    323333        else: 
    324334            mode = ACC_RDWR 
    325         status = self.lib.nxiopen_(self.filename,mode,_ref(self.handle)) 
     335        status = nxlib.nxiopen_(self.filename,mode,_ref(self.handle)) 
    326336        if status == ERROR: 
    327337            raise RuntimeError, "Could not open %s"%(self.filename) 
    328338        self.path = [] 
    329339 
    330     #lib.nxiclose_.restype = c_int 
    331     #lib.nxiclose_.argtypes = [c_void_pp] 
     340    nxlib.nxiclose_.restype = c_int 
     341    nxlib.nxiclose_.argtypes = [c_void_pp] 
    332342    def close(self): 
    333343        """ 
    334344        Close the NeXus file associated with handle. 
    335345 
    336         Raises RuntimeError if file could not be opened. 
     346        Raises RuntimeError if file could not be closed. 
    337347 
    338348        Corresponds to NXclose(&handle) 
     
    340350        if self.isopen: 
    341351            self.isopen = False 
    342             status = self.lib.nxiclose_(_ref(self.handle)) 
     352            status = nxlib.nxiclose_(_ref(self.handle)) 
    343353            if status == ERROR: 
    344354                raise RuntimeError, "Could not close NeXus file %s"%(self.filename) 
    345355        self.path = [] 
    346356 
    347     lib.nxiflush_.restype = c_int 
    348     lib.nxiflush_.argtypes = [c_void_pp] 
     357    nxlib.nxiflush_.restype = c_int 
     358    nxlib.nxiflush_.argtypes = [c_void_pp] 
    349359    def flush(self): 
    350360        """ 
     
    355365        Corresponds to NXflush(&handle) 
    356366        """ 
    357         status = self.lib.nxiflush_(_ref(self.handle)) 
     367        status = nxlib.nxiflush_(_ref(self.handle)) 
    358368        if status == ERROR: 
    359369            raise RuntimeError, "Could not flush NeXus file %s"%(self.filename) 
    360370 
    361     lib.nxisetnumberformat_.restype = c_int 
    362     lib.nxisetnumberformat_.argtypes = [c_void_p, c_int, c_char_p] 
     371    nxlib.nxisetnumberformat_.restype = c_int 
     372    nxlib.nxisetnumberformat_.argtypes = [c_void_p, c_int, c_char_p] 
    363373    def setnumberformat(self,type,format): 
    364374        """ 
     
    366376        applies to XML). 
    367377 
    368         Raises ValueError if this fails. 
     378        Raises ValueError if the number format is incorrect. 
    369379 
    370380        Corresponds to NXsetnumberformat(&handle,type,format) 
    371381        """ 
    372382        type = _nxtype_code[type] 
    373         status = self.lib.nxisetnumberformat_(self.handle,type,format) 
    374         if status == ERROR: 
    375             raise RuntimeError,\ 
     383        status = nxlib.nxisetnumberformat_(self.handle,type,format) 
     384        if status == ERROR: 
     385            raise ValueError,\ 
    376386                "Could not set %s to %s in %s"%(type,format,self.filename) 
    377387 
    378388    # ==== Group ==== 
    379     lib.nximakegroup_.restype = c_int 
    380     lib.nximakegroup_.argtypes = [c_void_p, c_char_p, c_char_p] 
     389    nxlib.nximakegroup_.restype = c_int 
     390    nxlib.nximakegroup_.argtypes = [c_void_p, c_char_p, c_char_p] 
    381391    def makegroup(self, name, nxclass): 
    382392        """ 
     
    387397        Corresponds to NXmakegroup(handle, name, nxclass) 
    388398        """ 
    389         status = self.lib.nximakegroup_(self.handle, name, nxclass) 
     399        status = nxlib.nximakegroup_(self.handle, name, nxclass) 
    390400        if status == ERROR: 
    391401            raise RuntimeError,\ 
    392402                "Could not create %s:%s in %s"%(nxclass,name,self._loc()) 
    393403 
    394     lib.nxiopenpath_.restype = c_int 
    395     lib.nxiopenpath_.argtypes = [c_void_p, c_char_p] 
     404    nxlib.nxiopenpath_.restype = c_int 
     405    nxlib.nxiopenpath_.argtypes = [c_void_p, c_char_p] 
    396406    def openpath(self, path): 
    397407        """ 
     
    403413        Corresponds to NXopenpath(handle, path) 
    404414        """ 
    405         status = self.lib.nxiopenpath_(self.handle, path) 
     415        status = nxlib.nxiopenpath_(self.handle, path) 
    406416        if status == ERROR: 
    407417            raise ValueError, "Could not open %s in %s"%(path,self._loc()) 
     
    413423 
    414424 
    415     lib.nxiopengrouppath_.restype = c_int 
    416     lib.nxiopengrouppath_.argtypes = [c_void_p, c_char_p] 
     425    nxlib.nxiopengrouppath_.restype = c_int 
     426    nxlib.nxiopengrouppath_.argtypes = [c_void_p, c_char_p] 
    417427    def opengrouppath(self, path): 
    418428        """ 
     
    425435        Corresponds to NXopengrouppath(handle, path) 
    426436        """ 
    427         status = self.lib.nxiopengrouppath_(self.handle, path) 
     437        status = nxlib.nxiopengrouppath_(self.handle, path) 
    428438        if status == ERROR: 
    429439            raise ValueError, "Could not open %s in %s"%(path,self.filename) 
     
    435445 
    436446 
    437     lib.nxiopengroup_.restype = c_int 
    438     lib.nxiopengroup_.argtypes = [c_void_p, c_char_p, c_char_p] 
     447    nxlib.nxiopengroup_.restype = c_int 
     448    nxlib.nxiopengroup_.argtypes = [c_void_p, c_char_p, c_char_p] 
    439449    def opengroup(self, name, nxclass): 
    440450        """ 
     
    446456        """ 
    447457        #print "open group",nxclass,name 
    448         status = self.lib.nxiopengroup_(self.handle, name, nxclass) 
     458        status = nxlib.nxiopengroup_(self.handle, name, nxclass) 
    449459        if status == ERROR: 
    450460            raise ValueError,\ 
     
    452462        self.path.append(name) 
    453463 
    454     lib.nxiclosegroup_.restype = c_int 
    455     lib.nxiclosegroup_.argtypes = [c_void_p] 
     464    nxlib.nxiclosegroup_.restype = c_int 
     465    nxlib.nxiclosegroup_.argtypes = [c_void_p] 
    456466    def closegroup(self): 
    457467        """ 
     
    463473        """ 
    464474        #print "close group" 
    465         status = self.lib.nxiclosegroup_(self.handle) 
     475        status = nxlib.nxiclosegroup_(self.handle) 
    466476        group = self.path.pop() 
    467477        if status == ERROR: 
    468478            raise RuntimeError, "Could not close %s:"%(group,self._loc()) 
    469479 
    470     lib.nxigetinfo_.restype = c_int 
    471     lib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_char_p, c_char_p] 
     480    nxlib.nxigetinfo_.restype = c_int 
     481    nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_char_p, c_char_p] 
    472482    def getgroupinfo(self): 
    473483        """ 
     
    484494        nxclass = ctypes.create_string_buffer(MAXNAMELEN) 
    485495        n = c_int(0) 
    486         status = self.lib.nxigetgroupinfo_(self.handle,_ref(n),path,nxclass) 
     496        status = nxlib.nxigetgroupinfo_(self.handle,_ref(n),path,nxclass) 
    487497        if status == ERROR: 
    488498            raise ValueError, "Could not get group info: %s"%(self._loc()) 
     
    490500        return n.value,path.value,nxclass.value 
    491501 
    492     lib.nxiinitgroupdir_.restype = c_int 
    493     lib.nxiinitgroupdir_.argtypes = [c_void_p] 
     502    nxlib.nxiinitgroupdir_.restype = c_int 
     503    nxlib.nxiinitgroupdir_.argtypes = [c_void_p] 
    494504    def initgroupdir(self): 
    495505        """ 
     
    500510        Corresponds to NXinitgroupdir(handle) 
    501511        """ 
    502         status = self.lib.nxiinitgroupdir_(self.handle) 
     512        status = nxlib.nxiinitgroupdir_(self.handle) 
    503513        if status == ERROR: 
    504514            raise RuntimeError, \ 
    505515                "Could not reset group scan: %s"%(self._loc()) 
    506516 
    507     lib.nxigetnextentry_.restype = c_int 
    508     lib.nxigetnextentry_.argtypes = [c_void_p, c_char_p, c_char_p, c_int_p] 
     517    nxlib.nxigetnextentry_.restype = c_int 
     518    nxlib.nxigetnextentry_.argtypes = [c_void_p, c_char_p, c_char_p, c_int_p] 
    509519    def getnextentry(self): 
    510520        """ 
     
    522532        nxclass = ctypes.create_string_buffer(MAXNAMELEN) 
    523533        storage = c_int(0) 
    524         status = self.lib.nxigetnextentry_(self.handle,name,nxclass,_ref(storage)) 
     534        status = nxlib.nxigetnextentry_(self.handle,name,nxclass,_ref(storage)) 
    525535        if status == ERROR or status == EOD: 
    526536            raise RuntimeError, \ 
     
    572582 
    573583    # ==== Data ==== 
    574     lib.nxigetinfo_.restype = c_int 
    575     lib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
     584    nxlib.nxigetinfo_.restype = c_int 
     585    nxlib.nxigetinfo_.argtypes = [c_void_p, c_int_p, c_void_p, c_int_p] 
    576586    def getinfo(self): 
    577587        """ 
     
    596606        shape = numpy.zeros(MAXRANK, 'i') 
    597607        storage = c_int(0) 
    598         status = self.lib.nxigetinfo_(self.handle, _ref(rank), shape.ctypes.data, 
     608        status = nxlib.nxigetinfo_(self.handle, _ref(rank), shape.ctypes.data, 
    599609                                     _ref(storage)) 
    600610        if status == ERROR: 
     
    605615        return shape,dtype 
    606616 
    607     lib.nxiopendata_.restype = c_int 
    608     lib.nxiopendata_.argtypes = [c_void_p, c_char_p] 
     617    nxlib.nxiopendata_.restype = c_int 
     618    nxlib.nxiopendata_.argtypes = [c_void_p, c_char_p] 
    609619    def opendata(self, name): 
    610620        """ 
     
    616626        """ 
    617627        #print "opening data",name 
    618         status = self.lib.nxiopendata_(self.handle, name) 
     628        status = nxlib.nxiopendata_(self.handle, name) 
    619629        if status == ERROR: 
    620630            raise ValueError, "Could not open data %s: %s"%(name, self._loc()) 
    621631        self.path.append(name) 
    622632 
    623     lib.nxiclosedata_.restype = c_int 
    624     lib.nxiclosedata_.argtypes = [c_void_p] 
     633    nxlib.nxiclosedata_.restype = c_int 
     634    nxlib.nxiclosedata_.argtypes = [c_void_p] 
    625635    def closedata(self): 
    626636        """ 
     
    633643        """ 
    634644        #print "closing data" 
    635         status = self.lib.nxiclosedata_(self.handle) 
     645        status = nxlib.nxiclosedata_(self.handle) 
    636646        name = self.path.pop() 
    637647        if status == ERROR: 
     
    639649                "Could not close data %s: %s"%(name,self._loc()) 
    640650 
    641     lib.nximakedata_.restype = c_int 
    642     lib.nximakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p] 
     651    nxlib.nximakedata_.restype = c_int 
     652    nxlib.nximakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p] 
    643653    def makedata(self, name, dtype=None, shape=None): 
    644654        """ 
     
    660670        storage = _nxtype_code[str(dtype)] 
    661671        shape = numpy.array(shape,'i') 
    662         status = self.lib.nximakedata_(self.handle,name,storage,len(shape), 
     672        status = nxlib.nximakedata_(self.handle,name,storage,len(shape), 
    663673                                  shape.ctypes.data_as(c_int_p)) 
    664674        if status == ERROR: 
    665675            raise ValueError, "Could not create data %s: %s"%(name,self._loc()) 
    666676 
    667     lib.nxicompmakedata_.restype = c_int 
    668     lib.nxicompmakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p, 
     677    nxlib.nxicompmakedata_.restype = c_int 
     678    nxlib.nxicompmakedata_.argtypes  = [c_void_p, c_char_p, c_int, c_int, c_int_p, 
    669679                                      c_int, c_int_p] 
    670680    def compmakedata(self, name, dtype=None, shape=None, mode='lzw', 
     
    693703        else: 
    694704            chunks = numpy.array(chunks,'i') 
    695         status = self.lib.nxicompmakedata_(self.handle,name,storage,len(dims), 
     705        status = nxlib.nxicompmakedata_(self.handle,name,storage,len(dims), 
    696706                                      dims.ctypes.data_as(c_int_p), 
    697707                                      _compression_code[mode], 
     
    701711                "Could not create compressed data %s: %s"%(name,self._loc()) 
    702712 
    703     lib.nxigetdata_.restype = c_int 
    704     lib.nxigetdata_.argtypes = [c_void_p, c_void_p] 
     713    nxlib.nxigetdata_.restype = c_int 
     714    nxlib.nxigetdata_.argtypes = [c_void_p, c_void_p] 
    705715    def getdata(self): 
    706716        """ 
     
    709719        length 1), a python numeric scalar is returned. 
    710720 
    711         Raises RuntimeError if this fails. 
     721        Raises ValueError if this fails. 
    712722 
    713723        Corresponds to NXgetdata(handle, data) 
     
    716726        shape,dtype = self.getinfo() 
    717727        datafn,pdata,size = self._poutput(dtype,shape) 
    718         status = self.lib.nxigetdata_(self.handle,pdata) 
     728        status = nxlib.nxigetdata_(self.handle,pdata) 
    719729        if status == ERROR: 
    720730            raise ValueError, "Could not read data: %s"%(self._loc()) 
     
    722732        return datafn() 
    723733 
    724     lib.nxigetslab_.restype = c_int 
    725     lib.nxigetslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
     734    nxlib.nxigetslab_.restype = c_int 
     735    nxlib.nxigetslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
    726736    def getslab(self, slab_offset, slab_shape): 
    727737        """ 
     
    740750        slab_offset = numpy.array(slab_offset,'i') 
    741751        slab_shape = numpy.array(slab_shape,'i') 
    742         status = self.lib.nxigetslab_(self.handle,pdata, 
     752        status = nxlib.nxigetslab_(self.handle,pdata, 
    743753                                      slab_offset.ctypes.data_as(c_int_p), 
    744754                                      slab_shape.ctypes.data_as(c_int_p)) 
     
    748758        return datafn() 
    749759 
    750     lib.nxiputdata_.restype = c_int 
    751     lib.nxiputdata_.argtypes = [c_void_p, c_void_p] 
     760    nxlib.nxiputdata_.restype = c_int 
     761    nxlib.nxiputdata_.argtypes = [c_void_p, c_void_p] 
    752762    def putdata(self, data): 
    753763        """ 
     
    760770        shape,dtype = self.getinfo() 
    761771        data,pdata = self._pinput(data,dtype,shape) 
    762         status = self.lib.nxiputdata_(self.handle,pdata) 
     772        status = nxlib.nxiputdata_(self.handle,pdata) 
    763773        if status == ERROR: 
    764774            raise ValueError, "Could not write data: %s"%(self._loc()) 
    765775 
    766     lib.nxiputslab_.restype = c_int 
    767     lib.nxiputslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
     776    nxlib.nxiputslab_.restype = c_int 
     777    nxlib.nxiputslab_.argtypes = [c_void_p, c_void_p, c_int_p, c_int_p] 
    768778    def putslab(self, data, slab_offset, slab_shape): 
    769779        """ 
     
    782792        slab_shape = numpy.array(slab_shape,'i') 
    783793        #print "slab",offset,size,data 
    784         status = self.lib.nxiputslab_(self.handle,pdata, 
     794        status = nxlib.nxiputslab_(self.handle,pdata, 
    785795                                      slab_offset.ctypes.data_as(c_int_p), 
    786796                                      slab_shape.ctypes.data_as(c_int_p)) 
     
    791801 
    792802    # ==== Attributes ==== 
    793     lib.nxiinitattrdir_.restype = c_int 
    794     lib.nxiinitattrdir_.argtypes = [c_void_p] 
     803    nxlib.nxiinitattrdir_.restype = c_int 
     804    nxlib.nxiinitattrdir_.argtypes = [c_void_p] 
    795805    def initattrdir(self): 
    796806        """ 
     
    801811        Corresponds to NXinitattrdir(handle) 
    802812        """ 
    803         status = self.lib.nxiinitattrdir_(self.handle) 
     813        status = nxlib.nxiinitattrdir_(self.handle) 
    804814        if status == ERROR: 
    805815            raise RuntimeError, \ 
    806816                "Could not reset attribute list: %s"%(self._loc()) 
    807817 
    808     lib.nxigetattrinfo_.restype = c_int 
    809     lib.nxigetattrinfo_.argtypes = [c_void_p, c_int_p] 
     818    nxlib.nxigetattrinfo_.restype = c_int 
     819    nxlib.nxigetattrinfo_.argtypes = [c_void_p, c_int_p] 
    810820    def getattrinfo(self): 
    811821        """ 
     
    819829        """ 
    820830        n = c_int(0) 
    821         status = self.lib.nxigetattrinfo_(self.handle,_ref(n)) 
     831        status = nxlib.nxigetattrinfo_(self.handle,_ref(n)) 
    822832        if status == ERROR: 
    823833            raise RuntimeError, "Could not get attr info: %s"%(self._loc()) 
     
    825835        return n.value 
    826836 
    827     lib.nxigetnextattr_.restype = c_int 
    828     lib.nxigetnextattr_.argtypes = [c_void_p, c_char_p, c_int_p, c_int_p] 
     837    nxlib.nxigetnextattr_.restype = c_int 
     838    nxlib.nxigetnextattr_.argtypes = [c_void_p, c_char_p, c_int_p, c_int_p] 
    829839    def getnextattr(self): 
    830840        """ 
     
    847857        length = c_int(0) 
    848858        storage = c_int(0) 
    849         status = self.lib.nxigetnextattr_(self.handle,name,_ref(length),_ref(storage)) 
     859        status = nxlib.nxigetnextattr_(self.handle,name,_ref(length),_ref(storage)) 
    850860        if status == ERROR or status == EOD: 
    851861            raise RuntimeError, "Could not get next attr: %s"%(self._loc()) 
     
    856866    # TODO: Resolve discrepency between NeXus API documentation and 
    857867    # TODO: apparent behaviour for getattr/putattr length. 
    858     lib.nxigetattr_.restype = c_int 
    859     lib.nxigetattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int_p, c_int_p] 
     868    nxlib.nxigetattr_.restype = c_int 
     869    nxlib.nxigetattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int_p, c_int_p] 
    860870    def getattr(self, name, length, dtype): 
    861871        """ 
     
    870880        #print "retrieving",name,length,dtype,size 
    871881        size = c_int(size) 
    872         status = self.lib.nxigetattr_(self.handle,name,pdata,_ref(size),_ref(storage)) 
     882        status = nxlib.nxigetattr_(self.handle,name,pdata,_ref(size),_ref(storage)) 
    873883        if status == ERROR: 
    874884            raise ValueError, "Could not read attr %s: %s" % (name,self._loc()) 
     
    876886        return datafn() 
    877887 
    878     lib.nxiputattr_.restype = c_int 
    879     lib.nxiputattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int, c_int] 
     888    nxlib.nxiputattr_.restype = c_int 
     889    nxlib.nxiputattr_.argtypes = [c_void_p, c_char_p, c_void_p, c_int, c_int] 
    880890    def putattr(self, name, value, dtype = None): 
    881891        """ 
     
    883893        or a scalar. 
    884894 
    885         Raises ValueError if the attribute could not be saved. 
     895        Raises TypeError if the value type is incorrect. 
     896        Raises RuntimeError if the attribute could not be saved. 
    886897 
    887898        Corresponds to NXputattr(handle,name,data,length,storage) 
     
    921932        # Perform the call 
    922933        storage = c_int(_nxtype_code[dtype]) 
    923         status = self.lib.nxiputattr_(self.handle,name,data,length,storage) 
    924         if status == ERROR: 
    925             raise ValueError, "Could not write attr %s: %s"%(name,self._loc()) 
     934        status = nxlib.nxiputattr_(self.handle,name,data,length,storage) 
     935        if status == ERROR: 
     936            raise RuntimeError, "Could not write attr %s: %s"%(name,self._loc()) 
    926937 
    927938    def attrs(self): 
     
    946957 
    947958    # ==== Linking ==== 
    948     lib.nxigetgroupid_.restype = c_int 
    949     lib.nxigetgroupid_.argtypes = [c_void_p, c_NXlink_p] 
     959    nxlib.nxigetgroupid_.restype = c_int 
     960    nxlib.nxigetgroupid_.argtypes = [c_void_p, c_NXlink_p] 
    950961    def getgroupID(self): 
    951962        """ 
     
    957968        """ 
    958969        ID = _NXlink() 
    959         status = self.lib.nxigetgroupid_(self.handle,_ref(ID)) 
     970        status = nxlib.nxigetgroupid_(self.handle,_ref(ID)) 
    960971        if status == ERROR: 
    961972            raise RuntimeError, "Could not link to group: %s"%(self._loc()) 
    962973        return ID 
    963974 
    964     lib.nxigetdataid_.restype = c_int 
    965     lib.nxigetdataid_.argtypes = [c_void_p, c_NXlink_p] 
     975    nxlib.nxigetdataid_.restype = c_int 
     976    nxlib.nxigetdataid_.argtypes = [c_void_p, c_NXlink_p] 
    966977    def getdataID(self): 
    967978        """ 
     
    973984        """ 
    974985        ID = _NXlink() 
    975         status = self.lib.nxigetdataid_(self.handle,_ref(ID)) 
     986        status = nxlib.nxigetdataid_(self.handle,_ref(ID)) 
    976987        if status == ERROR: 
    977988            raise RuntimeError, "Could not link to data: %s"%(self._loc()) 
    978989        return ID 
    979990 
    980     lib.nximakelink_.restype = c_int 
    981     lib.nximakelink_.argtypes = [c_void_p, c_NXlink_p] 
     991    nxlib.nximakelink_.restype = c_int 
     992    nxlib.nximakelink_.argtypes = [c_void_p, c_NXlink_p] 
    982993    def makelink(self, ID): 
    983994        """ 
     
    9891000        Corresponds to NXmakelink(handle, &ID) 
    9901001        """ 
    991         status = self.lib.nximakelink_(self.handle,_ref(ID)) 
     1002        status = nxlib.nximakelink_(self.handle,_ref(ID)) 
    9921003        if status == ERROR: 
    9931004            raise RuntimeError, "Could not make link: %s"%(self._loc()) 
    9941005 
    995     lib.nximakenamedlink_.restype = c_int 
    996     lib.nximakenamedlink_.argtypes = [c_void_p, c_char_p, c_NXlink_p] 
     1006    nxlib.nximakenamedlink_.restype = c_int 
     1007    nxlib.nximakenamedlink_.argtypes = [c_void_p, c_char_p, c_NXlink_p] 
    9971008    def makenamedlink(self,name,ID): 
    9981009        """ 
     
    10041015        Corresponds to NXmakenamedlink(handle,name,&ID) 
    10051016        """ 
    1006         status = self.lib.nximakenamedlink_(self.handle,name,_ref(ID)) 
     1017        status = nxlib.nximakenamedlink_(self.handle,name,_ref(ID)) 
    10071018        if status == ERROR: 
    10081019            raise RuntimeError, "Could not make link %s: %s"%(name,self._loc()) 
    10091020 
    1010     lib.nxisameid_.restype = c_int 
    1011     lib.nxisameid_.argtypes = [c_void_p, c_NXlink_p, c_NXlink_p] 
     1021    nxlib.nxisameid_.restype = c_int 
     1022    nxlib.nxisameid_.argtypes = [c_void_p, c_NXlink_p, c_NXlink_p] 
    10121023    def sameID(self, ID1, ID2): 
    10131024        """ 
     
    10181029        Corresponds to NXsameID(handle,&ID1,&ID2) 
    10191030        """ 
    1020         status = self.lib.nxisameid_(self.handle, _ref(ID1), _ref(ID2)) 
     1031        status = nxlib.nxisameid_(self.handle, _ref(ID1), _ref(ID2)) 
    10211032        return status == OK 
    10221033 
    1023     lib.nxiopensourcegroup_.restype = c_int 
    1024     lib.nxiopensourcegroup_.argtyps = [c_void_p] 
     1034    nxlib.nxiopensourcegroup_.restype = c_int 
     1035    nxlib.nxiopensourcegroup_.argtyps = [c_void_p] 
    10251036    def opensourcegroup(self): 
    10261037        """ 
     
    10311042        perhaps the existence of a 'target' attribute in the current item. 
    10321043 
    1033         Raises RuntimeError 
     1044        Raises RuntimeError. 
    10341045 
    10351046        Corresponds to NXopensourcegroup(handle) 
    10361047        """ 
    1037         status = self.lib.nxiopensourcegroup_(self.handle) 
     1048        status = nxlib.nxiopensourcegroup_(self.handle) 
    10381049        if status == ERROR: 
    10391050            raise RuntimeError, "Could not open source group: %s"%(self._loc()) 
     
    10671078 
    10681079    # ==== External linking ==== 
    1069     lib.nxiinquirefile_.restype = c_int 
    1070     lib.nxiinquirefile_.argtypes = [c_void_p, c_char_p, c_int] 
     1080    nxlib.nxiinquirefile_.restype = c_int 
     1081    nxlib.nxiinquirefile_.argtypes = [c_void_p, c_char_p, c_int] 
    10711082    def inquirefile(self, maxnamelen=MAXPATHLEN): 
    10721083        """ 
     
    10801091        """ 
    10811092        filename = ctypes.create_string_buffer(maxnamelen) 
    1082         status = self.lib.nxiinquirefile_(self.handle,filename,maxnamelen) 
     1093        status = nxlib.nxiinquirefile_(self.handle,filename,maxnamelen) 
    10831094        if status == ERROR: 
    10841095            raise RuntimeError,\ 
     
    10861097        return filename.value 
    10871098 
    1088     lib.nxilinkexternal_.restype = c_int 
    1089     lib.nxilinkexternal_.argtyps = [c_void_p, c_char_p, 
     1099    nxlib.nxilinkexternal_.restype = c_int 
     1100    nxlib.nxilinkexternal_.argtyps = [c_void_p, c_char_p, 
    10901101                                       c_char_p, c_char_p] 
    10911102    def linkexternal(self, name, nxclass, url): 
     
    10941105        otherwise return None. 
    10951106 
     1107        Raises RuntimeError if link fails. 
     1108 
    10961109        Corresponds to NXisexternalgroup(&handle,name,nxclass,file,len) 
    10971110        """ 
    1098         status = self.lib.nxilinkexternal_(self.handle,name,nxclass,url) 
     1111        status = nxlib.nxilinkexternal_(self.handle,name,nxclass,url) 
    10991112        if status == ERROR: 
    11001113            raise RuntimeError,\ 
     
    11031116 
    11041117 
    1105     lib.nxiisexternalgroup_.restype = c_int 
    1106     lib.nxiisexternalgroup_.argtyps = [c_void_p, c_char_p, 
     1118    nxlib.nxiisexternalgroup_.restype = c_int 
     1119    nxlib.nxiisexternalgroup_.argtyps = [c_void_p, c_char_p, 
    11071120                                       c_char_p, c_char_p, c_int] 
    11081121    def isexternalgroup(self, name, nxclass, maxnamelen=MAXPATHLEN): 
     
    11141127        """ 
    11151128        url = ctypes.create_string_buffer(maxnamelen) 
    1116         status = self.lib.nxiisexternalgroup_(self.handle,name,nxclass, 
     1129        status = nxlib.nxiisexternalgroup_(self.handle,name,nxclass, 
    11171130                                              url,maxnamelen) 
    11181131        if status == ERROR: 
Note: See TracChangeset for help on using the changeset viewer.