Opened 12 years ago

Closed 9 years ago

#4830 closed defect (wontfix)

GDAL Python bindings disables setting a non-zero exit code on Windows 7

Reported by: lpinner Owned by: hobu
Priority: normal Milestone:
Component: PythonBindings Version: 1.10.0
Severity: normal Keywords:
Cc: stefano.iacovella@…, antonio, tamas

Description

Importing the gdal bindings in python seems to disable setting a non-zero exit code. Running the following batch file demonstrates the issue:

@echo off
set pycmd=python -c "from osgeo import gdal;import sys;sys.exit(1)"
echo %pycmd%
%pycmd%
echo ERRORLEVEL=%ERRORLEVEL%
echo.
set  pycmd=python -c "import sys;sys.exit(1)"
echo %pycmd%
%pycmd%
echo ERRORLEVEL=%ERRORLEVEL%
echo.
pause

This prints out:

python -c "from osgeo import gdal;import sys;sys.exit(1)"
ERRORLEVEL=0

python -c "import sys;sys.exit(1)"
ERRORLEVEL=1

Tested on Windows 7 Pro and Server 2008 R2 64bit with GDAL 1.9.1 MSVC2008 (Win32) with 32bit python 2.6.5 and GDAL 1.9.1 MSVC2008 (Win64) with 64bit python 2.6.6.

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.

Change History (10)

comment:1 by Even Rouault, 12 years ago

Summary: GDAL Python bindings disables setting a non-zero exit codeGDAL Python bindings disables setting a non-zero exit code on Windows 7

I can confirm that it works fine in Windows XP. Didn't test on W7.

comment:2 by iacovellas, 12 years ago

Cc: stefano.iacovella@… added

I tested it both on Windows xp and on Windows 2008 R2 64 bit.

On 2008 it fails as following

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

comment:3 by Kyle Shannon, 12 years ago

Doesn't seem to be a problem on my Windows 7:

c:\Python26\ArcGIS10.0\python -c "from osgeo import gdal;import sys;sys.exit(1)"
ERRORLEVEL=1

c:\Python26\ArcGIS10.0\python -c "import sys;sys.exit(1)"
ERRORLEVEL=1

Windows 7, python 2.6.5, gdal 1.9.1, 32-bit python

comment:4 by antonio, 12 years ago

Cc: antonio added

comment:5 by lpinner, 12 years ago

Hmmm, the OSGeo4W version of gdal 1.9.1 doesn't show this problem (on Win 7 Pro), only Tamas' GISInternals builds, curious...

comment:6 by Even Rouault, 12 years ago

Cc: tamas added

comment:7 by lpinner, 11 years ago

Related to #5128 and #5073. Disabling the ECW driver plugin fixes setting a non-zero exit code.

@echo off
set  pycmd=python -c "import sys;sys.exit(1)"
echo %pycmd%
%pycmd%
echo ERRORLEVEL=%ERRORLEVEL%
echo.
set pycmd=python -c "from osgeo import gdal;import sys;sys.exit(1)"
echo %pycmd%
%pycmd%
echo ERRORLEVEL=%ERRORLEVEL%
echo.
move %GDAL_DRIVER_PATH%\gdal_ECW_JP2ECW.dll %GDAL_DRIVER_PATH%.disabled\gdal_ECW_JP2ECW.dll
set pycmd=python -c "from osgeo import gdal;import sys;sys.exit(1)"
echo %pycmd%
%pycmd%
echo ERRORLEVEL=%ERRORLEVEL%
echo.
pause

comment:8 by lpinner, 11 years ago

Version: 1.9.11.10.0

comment:9 by lpinner, 11 years ago

Using an ECW driver plugin built against the latest ECW/JP2 SDK (v.5) fixes setting a non-zero exit code.

Stefano, the latest version of MetaGETA ships with an ECW/JP2 SDK (v.5) ECW driver plugin.

comment:10 by Jukka Rahkonen, 9 years ago

Resolution: wontfix
Status: newclosed

This is not the only case where the ECW SDK 3.x is making troubles with exit codes. Closing as won't fix. Nice that the problem disappeared with SDK version 5 even some users would probably like to continue with 3.x because of less limiting license.

Note: See TracTickets for help on using tickets.