[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Python crashes when opening an OPeNDAP dataset on Windows from a directory without write access

Does this really crash Python? Wow. I would hope it would just raise an exception. I would hope the DAP system would use $TMP (unix) or %TEMP% (Windows), which are guaranteed writable folders, instead of the current directory, but apparently not. However, if these temp files have the possibility of being quite large (not out of the realm of possibility!) I can understand not wanting to fillup system $TMP. Maybe that's why it's the way it is.

It's encouraging that this turns out to be a simple write access issue instead of some deep arcane .dll conflict with ArcGIS.

Typically in ArcGIS geoprocessing, we have a scratch workspace available that is used to write temporary files. This could be handled in ArcGIS by simply having our script tool os.chdir to arcpy.scratchWorkspace (or if that is a geodatabase, the folder above it) and maybe even checking to be sure it's writable, before we call netCDF4.Dataset(). Or always start ArcMap from a writeable folder.

Curtis Price ~ http://profile.usgs.gov/cprice

From: Rich Signell <address@hidden>
To: address@hidden
Cc: address@hidden, Curtis V Price <address@hidden>
Date: 06/25/2012 03:11 PM
Subject: Python crashes when opening an OPeNDAP dataset on Windows from a directory without write access
Sent by: address@hidden

If you try to use NetCDF4-python (which wraps the Unidata netCDF C
library) to open an OPeNDAP dataset on Windows from a directory
without write access, Python crashes.   If you would like to try
crashing your python (unless you have write permission to c:\windows),
here's an example:

import os
import netCDF4

The NetCDF4-Python guys say they can't do anything about this, because
the basic problem is on the Unidata side.  According to Christoph
Gohlke, NetCDF wants to write a temporary file when accessing OPeNDAP
files, and apparently it wants to write in the current directory.
And I guess if it can't write, Python crashes.

There is mention of a temporary file here:
but it's not clear that wants to write to the current directory.

This came up because we were using NetCDF4-Python from the Python
Command Window in ArcGIS, and the default directory for the command
window was (c:\windows\system32) which of course is not typically
writable by an ordinary user.

Can we fix this somehow?
We aren't going to win many converts to OPeNDAP if they can crash
ArcGIS by opening a remote dataset.

I'm cc'ing the Enthought Python gang and Curtis Price, our Python-GIS
guru, so they are aware of the problem.

Dr. Richard P. Signell   (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.