[gdal-dev] Error handlers in Python bindings

Fabian Schindler fabian.schindler at eox.at
Wed Jul 11 03:15:50 PDT 2012


Hey folks,

I'd like to know how I could set a custom error handling function in the 
GDAL Python bindings?

Currently I was able to turn off error messages like so:

 >>> gdal.PushErrorHandler("CPLQuietErrorHandler")

What I want is something like this:

 >>> def f(error):
...    logger.error(error)
...
 >>> gdal.PushErrorHandler(f)

But I get the following error:

Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib/python2.6/dist-packages/osgeo/gdal.py", line 312, in 
PushErrorHandler
     return _gdal.PushErrorHandler(*args)
NotImplementedError: Wrong number of arguments for overloaded function 
'PushErrorHandler'.
   Possible C/C++ prototypes are:
     PushErrorHandler(char const *)
     CPLPushErrorHandler(CPLErrorHandler)

If possible, I'd like a solution that works with 1.8.

Thanks,
Fabian


More information about the gdal-dev mailing list