Problem with urllib2.urlopen() opening a local file

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Oct 26 23:38:53 EDT 2009


En Sat, 24 Oct 2009 20:10:21 -0300, deja user <greatcanyon at yahoo.com>  
escribió:

> I want to use urlopen() to open either a http://... file or a local
> file File:C:/...  I don't have problems opening and reading the file
> either way.  But when I run the script on a server (ArcGIS server),
> the request won't complete if it was trying to open a local file.
> Even though I call close() in either case, something seemed to be
> preventing the script to complete if urlopen is trying to open a local
> file.  I wonder if there is anything else I should do in the code to
> kill the file descriptor, or if it is a known issue that something is
> leaking
>
> When running the script standalone, this is not an issue.

I don't know about the ArcGIS server, but leaking a file descriptor  
usually is not a reason to not finish a request. I'd look into the server  
log files for any errors. The server might be configured to not allow  
open() of arbitrary files, by example. This seems more an ArcGIS question  
than a Python one.

Just to be sure, "local file" in this context means "local to the server",  
ok? An url like "file://c:/path/..." (note the differences with yours) is  
only meaningful if the server is running Windows, ok?

-- 
Gabriel Genellina




More information about the Python-list mailing list