def __repr__(self): r = _smi.smiRenderNode(self.node, _smi.SMI_RENDER_ALL) if r == ffi.NULL: return "<uninitialized {0} object at {1}>".format(self.__class__.__name__, hex(id(self))) r = ffi.gc(r, _smi.free) module = _smi.smiGetNodeModule(self.node) if module == ffi.NULL: raise SMIException("unable to get module for {0}".format(self.node.name)) return "<{0} {1} from '{2}'>".format(self.__class__.__name__, ffi.string(r), ffi.string(module.name))
def __repr__(self): r = _smi.smiRenderNode(self.node, _smi.SMI_RENDER_ALL) if r == ffi.NULL: return "<uninitialized {0} object at {1}>".format( self.__class__.__name__, hex(id(self))) r = ffi.gc(r, _smi.free) module = _smi.smiGetNodeModule(self.node) if module == ffi.NULL: raise SMIException("unable to get module for {0}".format( self.node.name)) return "<{0} {1} from '{2}'>".format(self.__class__.__name__, ffi.string(r), ffi.string(module.name))
def path(path=None): """Set or get a search path to libsmi. When no path is provided, return the current path, unmodified. Otherwise, set the path to the specified value. :param path: The string to be used to change the search path or `None` """ if path is None: # Get the path path = _smi.smiGetPath() if path == ffi.NULL: raise SMIException("unable to get current libsmi path") path = ffi.gc(path, _smi.free) result = ffi.string(path) return result.decode("utf8") # Set the path if not isinstance(path, bytes): path = path.encode("utf8") if _smi.smiSetPath(path) < 0: raise SMIException("unable to set the path {0}".format(path))