[gdal-dev] GDAL_API_PROXY and deregistering drivers (python/win32) [SEC=UNCLASSIFIED]

Pinner, Luke Luke.Pinner at environment.gov.au
Thu May 23 17:16:12 PDT 2013



 -----Original Message-----
> From: Even Rouault [mailto:even.rouault at mines-paris.org]
>
> On which OS did you run the above test ? On Linux (and provided that
> GDAL_API_PROXY_SERVER is not set to YES or gdalserver) , I get JP2OpenJPEG on
> both cases. However on Windows, I would get the same result as you.
>

Yes, it was Windows and no GDAL_API_PROXY_SERVER set.

> Not sure to have completely followed you on this.
> My understanding is that you would do :
> - open the file in API_PROXY mode
> - if that works (ds != None and possibly attempting to read 1 pixel since
> crashes also sometimes occur in I/O operations), use the dataset, or if you
> want to avoid client/server roundtrips, open it again in standard mode (so
> with JP2ECW)
> - if that fails, deregister JP2ECW and open it as usual in standard mode (with
> JP2OpenJPEG) and re-register JP2ECW just after having opened the file, for the
> next files
>
> I'm confident that you can do that with the current state of code.
>

Yes, it was an I/O operation that caused the crash. I've also had previous problems with the JP2MrSID driver with other datasets so was hoping to do something generic like the following snippet. The idea was to gracefully handle JP2s that might crash more than one driver and therefore the entire gdal process if opened/used in standard mode as you suggest.  Admittedly it's a bit of a corner case...

drivers=filter(None,[gdal.GetDriverByName(d) for d in ['JP2ECW','JP2KAK','JP2MrSID']])
for d in drivers+[None]:
    try:
        ds=gdal.Open('API_PROXY:'+f)  #Some jp2s crash on open
        result = do_some_operation(ds) #Some crash on I/O
        break
    except:
        if d:d.Deregister()#skip crashing driver

gdal.AllRegister() #Reset drivers

However, setting GDAL_SKIP seems to work so I'll use that instead.

drivers=filter(None,[gdal.GetDriverByName(d) for d in ['JP2ECW','JP2KAK','JP2MrSID']])
drivers=[d.ShortName for d in drivers]+[''] #Filter the list to only installed drivers
for d in drivers:
    try:
        ds=gdal.Open('API_PROXY:'+f) #Some jp2s crash on open
        result = do_some_operation(ds) #Some crash on I/O
        break
    except:
        os.environ['GDAL_SKIP']=d #skip crashing driver or reset env

Luke

If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments.

Please consider the environment before printing this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130524/7f307789/attachment.html>


More information about the gdal-dev mailing list