6081: Crash after double-click on .gpkg file

svn: r22645
This commit is contained in:
Doug Blank 2013-07-03 13:06:45 +00:00
parent d7b558997d
commit b51e544926

View File

@ -317,23 +317,25 @@ class CLIDbManager(object):
or (None, None) if no import was performed. or (None, None) if no import was performed.
""" """
pmgr = BasePluginManager.get_instance() pmgr = BasePluginManager.get_instance()
# Allow URL names here; make temp file if necessary # check to see if it isn't a filename directly:
url = urlparse.urlparse(filename) if not os.path.isfile(filename):
if url.scheme != "": # Allow URL names here; make temp file if necessary
if url.scheme == "file": url = urlparse.urlparse(filename)
filename = urllib2.url2pathname(filename[7:]) if url.scheme != "":
else: if url.scheme == "file":
url_fp = urllib2.urlopen(filename) # open URL filename = urllib2.url2pathname(filename[7:])
# make a temp local file: else:
ext = os.path.splitext(url.path)[1] url_fp = urllib2.urlopen(filename) # open URL
fd, filename = tempfile.mkstemp(suffix=ext) # make a temp local file:
temp_fp = os.fdopen(fd, "w") ext = os.path.splitext(url.path)[1]
# read from URL: fd, filename = tempfile.mkstemp(suffix=ext)
data = url_fp.read() temp_fp = os.fdopen(fd, "w")
# write locally: # read from URL:
temp_fp.write(data) data = url_fp.read()
url_fp.close() # write locally:
temp_fp.close() temp_fp.write(data)
url_fp.close()
temp_fp.close()
(name, ext) = os.path.splitext(os.path.basename(filename)) (name, ext) = os.path.splitext(os.path.basename(filename))
format = ext[1:].lower() format = ext[1:].lower()