[GRASS-dev] RE: [GRASS-user] Question with Python-SWIG example
[SEC=UNCLASSIFIED]
Martin Landa
landa.martin at gmail.com
Mon May 24 09:11:08 EDT 2010
Hi,
2010/5/24 Glynn Clements <glynn at gclements.plus.com>:
> G_find_raster2 is (or should be) defined in grass.py as:
>
> # /usr/local/src/grass/7.0/dist.i686-pc-linux-gnu/include/grass/gisdefs.h: 220
> if hasattr(_libs['grass_gis'], 'G_find_raster2'):
> G_find_raster2 = _libs['grass_gis'].G_find_raster2
> G_find_raster2.restype = ReturnString
> G_find_raster2.argtypes = [String, String]
I have ...
lib/python/ctypes/grass.py:if hasattr(_libs['grass_gis'], 'G_find_raster2'):
lib/python/ctypes/grass.py: G_find_raster2 =
_libs['grass_gis'].G_find_raster2
lib/python/ctypes/grass.py: G_find_raster2.restype = String
lib/python/ctypes/grass.py: G_find_raster2.argtypes = [String, String]
lib/python/ctypes/grass.py: G_find_raster2.errcheck = ReturnString
> The only imports in grass.py are:
>
> from ctypes_preamble import *
> from ctypes_preamble import _variadic_function
> from ctypes_loader import *
>
> so it shouldn't be possible for it to pick up some other definition
> for "String".
>
> It's annoying that the error message doesn't indicate which class's
> __init__ method is involved, or the traceback.
>
> Some other things to check:
>
> > from grass.lib import grass
> > grass.String
> <class 'ctypes.c_char_p'>
<class 'ctypes.c_char_p'>
> > grass.ReturnString
> <class 'ctypes.c_char_p'>
<class 'ctypes.c_char_p'>
> > grass.G_find_raster2
> <_FuncPtr object at 0x827eecc>
<_FuncPtr object at 0xb7038b24>
> > grass.G_find_raster2.__class__
> <class 'ctypes._FuncPtr'>
<class 'ctypes._FuncPtr'>
> > grass.G_find_raster2.argtypes
> [<class 'ctypes.c_char_p'>, <class 'ctypes.c_char_p'>]
[<class 'ctypes.c_char_p'>, <class 'ctypes.c_char_p'>]
> > grass.G_find_raster2.restype
> <class 'ctypes.c_char_p'>
<class 'ctypes.c_char_p'>
> > grass.G_find_raster2._restype_
> <class 'ctypes.c_long'>
<class 'ctypes.c_long'>
> > grass.G_find_raster2._objects
> {'0': <CDLL '/usr/local/src/grass/svn/dist.i686-pc-linux-gnu/lib/libgrass_gis.so', handle 8193e88 at 824f32c>}
>
{'0': <CDLL '/usr/local/src/grass_trunk/dist.i686-pc-linux-gnu/lib/libgrass_gis.so',
handle 9b01180 at b711f06c>}
Martin
--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa
More information about the grass-dev
mailing list