[gdal-dev] GDAL Python bindings disables setting a non-zero exit code
Stefano Iacovella
stefano.iacovella at gmail.com
Thu Sep 27 01:51:08 PDT 2012
2012/9/27 Luke Pinner <pinner.luke at gmail.com>
> Thanks Jason, it's definitely GDAL. The order doesn't matter and I've
> checked ERRORLEVEL v. %ERRORLEVEL% (see below). I don't think it's
> related to the batch file which is just a minimal test script. The
> issue occurs with every Windows python script I've written that
> imports gdal - i.e sys.exit(anything >0) will always set an exit code
> of 0 if gdal is imported. Running python from the command prompt does
> the same thing.
>
> set pycmd=python -c "from osgeo import gdal;import sys;sys.exit(1)"
> echo %pycmd%
> %pycmd%
> if ERRORLEVEL 1 (
> echo ERROR LEVEL is 1 or greater
> ) ELSE (
> echo ERROR LEVEL is incorrect
> )
> echo ERROR LEVEL=%ERRORLEVEL%
>
>
> Interestingly, one of the users of my code who originally reported the
> issue to me found that that ERRORLEVEL is set correctly in Windows XP.
>
Yes Luke I made another check exluding MetaGETA imports, the software using
GDAL python bindings, an it really seems related to GDAl, at least the GDAL
release shipped with MetaGETA.
On my workstation, a Windows XP 32 bit SP3 this is the output:
Microsoft Windows XP [Versione 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
D:\Appl\MetaGETA>python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(15)
D:\Appl\MetaGETA>echo %ERRORLEVEL%
15
D:\Appl\MetaGETA>python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from osgeo import ogr
>>> sys.exit(15)
D:\Appl\MetaGETA>echo %ERRORLEVEL%
15
On a Windows 2008 R2 64 bit it doesn't work
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
E:\Appl\MetaGETA>python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(15)
E:\Appl\MetaGETA>echo %ERRORLEVEL%
15
E:\Appl\MetaGETA>python
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from osgeo import ogr
>>> sys.exit(15)
E:\Appl\MetaGETA>echo %ERRORLEVEL%
0
> I'll file a ticket in TRAC.
>
>
---------------------------------------------------
41.95581N 12.52854E
http://www.linkedin.com/in/stefanoiacovella
http://twitter.com/#!/Iacovellas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120927/8f14aa95/attachment.html>
More information about the gdal-dev
mailing list