Skip to content

Commit

Permalink
fixed a bug related to issue #41
Browse files Browse the repository at this point in the history
related to issue #41
  • Loading branch information
Jwely committed Jul 8, 2015
1 parent 1d61d18 commit 8792449
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dnppy_install/download/download_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ def download_url(url, outname, username = None, password = None):
os.makedirs(head)

if "http" in url[:4]:
writefile = open(outname, 'wb+')
connection = urllib.urlopen(url)
page = connection.read()

# escapes in the event of a 404 not found
if "404 Not Found" in page:
return

writefile = open(outname, 'wb+')
writefile.write(page)
writefile.close()
del connection
Expand All @@ -45,5 +49,10 @@ def download_url(url, outname, username = None, password = None):
else:
print("Unknown url protocol type, must be http or ftp")

return

if __name__ == "__main__":

return
url = "http://water.weather.gov/precip/p_download_new/2002/01/05/nws_precip_conus_20020105.nc"
outpath = r"C:\Users\jwely\Desktop\troubleshooting\test.nc"
download_url(url, outpath)

0 comments on commit 8792449

Please sign in to comment.