This piece of code works fine in a Python editor, but when I create a simple Python Toolbox with no input paramaters, messages, or anything, and just try to execute, I get error message "Permission Denied". I think it has something to do with the default folder Python is trying to save the file to, but I have toyed around with the directory in urllib, and can't figure it out.
import arcpy
import os
import sys
import urllib
import zipfile
outDir= r'C:\Users\Cyndi\Desktop\Scratch\Download3'
arcpy.env.overwriteOutput = True
arcpy.env.workspace = arcpy.env.scratchWorkspace = outDir
uCatch = 'http://beta.hydroshare.org/django_irods/download/?path=363523b1c0fc4232b8671504b8eb2451/NHD_Catchments.zip'
urllib.urlretrieve(uCatch, "NHD_Catchments.zip")
oCatch = open('NHD_Catchments.zip','rb')
zCatch = zipfile.ZipFile(oCatch)
zCatch.extractall(outDir)
Error Message:
Traceback (most recent call last):
File "<string>", line 53, in execute
IOError: [Errno 13] Permission denied: 'NHD_Catchments.zip'
Failed to execute (Tool).