<div dir="ltr"><div>I've run into a strange problem and can't locate the source of the issue. I'm running a python/mapscript function with apache2 and django via wsgi on Ubuntu 12.04, mapserver 6.2. When I run the script using plain python as the www-data user (the same user as the wsgi daemon) the script works perfectly fine. When I run it under the wsgi process (through the browser) it fails with the error:<br>
<pre class="">msDrawMap(): Image handling error. Failed to draw layer named 'imagery_2010'.
msDrawRasterLayerLow(): Unable to access file. Corrupt, empty or missing file '/mnt/test/imagery/test.ecw' for layer 'imagery_2010'.</pre>At first I thought it was a simple permissions issue (reading the ecw off a mount point etc). I verified with inotifywait that the file is being opened by the wsgi script. I have compiled gdal with ECW support and have checked that the wsgi process is running off the same mapscript python lib. Also, the same wsgi script will run without error if I change the raster to a non-ecw file, so it seems that it just doesn't like the ecw under wsgi.<br>
<br></div><div>gdalinfo reads the ecw just fine as well. It is only under the wsgi process where it has problems. I'm stumped... Thanks for your help!<br></div><div><br></div><div>Here is my map file:<br><br></div><div>
MAP<br><br>  CONFIG "MS_ERRORFILE" "/tmp/ms_output.txt"<br>  DEBUG 5<br>  CONFIG "PROJ_LIB" "/usr/share/proj/"<br><br>  PROJECTION<br>    "init=epsg:900913"<br>  END<br>  FONTSET "/test/fontset.txt"<br>
  WEB<br>    METADATA<br>      "wms_title"           "WMS"<br>      "wms_onlineresource"  "<a href="http://localhost:81/cgi-bin/mapserv?map=/test/mapserver-config/plan.map">http://localhost:81/cgi-bin/mapserv?map=/test/mapserver-config/plan.map</a>"<br>
      "ows_enable_request"   "*"<br>      "wms_srs"             "epsg:900913"<br><br>    END<br>  END<br><br>  OUTPUTFORMAT<br>    NAME png<br>    DRIVER "AGG/PNG"<br>    MIMETYPE "image/png"<br>
    IMAGEMODE RGB<br>    EXTENSION "png"<br>  END<br><br>  LAYER<br>    NAME "imagery_2010"<br>    TYPE RASTER<br>    STATUS ON<br>    DATA "/mnt/test/imagery/test.ecw"<br><br>    PROJECTION<br>
      "init=epsg:2230"<br>    END<br>    PROCESSING "NODATA=255"<br>    PROCESSING "RESAMPLE=AVERAGE"<br>  END<br></div><div>END<br></div><div><br></div><div>Here is the python script:<br><br>
import mapscript<br><br>extent = [-13037387.706571, 3898141.5912883, -13036963.719929, 3898380.4570017]<br>filename = '/tmp/test.pdf'<br>raster = '/tmp/test.png'<br>mapfile = '/test/mapserver-config/plan.map'<br>
map_obj =  mapscript.mapObj(mapfile)<br>map_obj.width = 800<br>map_obj.height = 600<br>map_obj.extent = mapscript.rectObj(*extent)<br>image = map_obj.draw()<br>image.save(raster)<br></div></div>