[Ironpython-users] System.Net.WebClient and urllib.urlretrieve fail to download a file

Djordje Spasic issworld2000 at yahoo.com
Wed Feb 15 05:27:23 EST 2017



On Wednesday, February 15, 2017 11:17 AM, Kuno Meyer <kuno.meyer at gmx.ch> wrote:
 
Hi
Since the download with System.Net.WebClient() also fails (which is standard .NET Framework code and is not related to IronPython), I propose to check your network connectivity and for interfering company firewalls. Are you able to download the file with a browser? Maybe you need some manual proxy configuration (even though, according to MSDN, WebClient uses by default the IE setup.)
Regards,
Kuno

Thank you for the reply Kuno!
Everything is fine on my PC, the other user who uses the code below has the issue. He tried to manually download the mentioned file, and succeeded without a problem (in Chrome).
If WebClient is using default IE setup, then does he need to try to download the file in Internet Explorer?
 

  

 On Wednesday, February 15, 2017 9:59 AM, Andrew Graham <andy at agraham.demon.co.uk> wrote:
 
 Your code obviously works given the correct environment in which to run. A major difference between XP and Windows 10 is the permissions system so the first thing I would try is to make sure that the application is runnning as Administrator on the Windows 10 system. RegardsAndrew Graham

Thank you for the reply Andrew! I will check with him to see if he runs the Rhino5 as an Administrator.
 
 From: Djordje Spasic via Ironpython-users Sent: Tuesday, February 14, 2017 11:49 PMTo: Discussion of IronPython Subject: [Ironpython-users] System.Net.WebClient and urllib.urlretrieve fail to download a file Hello,I have a small ironpython 2.7 function which downloads a particular .osm file from overpass-api.de website.
The function is working without a problem on my PC.

However, on PC of another person, it fails. That person is using Windows 10 x64 (not sure if this information is of any significance), while I am using Windows XP 32 bit (way too old, sorry for that).

Here is the function's code:

 import System import urllib   def downloadFile(downloadLink, downloadedFilePath):     try:         # try "secure http" download         client = System.Net.WebClient()         client.DownloadFile(downloadLink, downloadedFilePath)     except Exception, e:         print "e1: ", e         try:             # "secure http" failed, try "http" download:             filePath, infoHeader = urllib.urlretrieve(downloadLink, downloadedFilePath)         except Exception, e:             print "e2: ", e             # downloading of file failed             fileDownloaded_success = False             return fileDownloaded_success          fileDownloaded_success = True     return fileDownloaded_success     download = True  # switch if download == True:     downloadLink = "http://overpass-api.de/api/map?bbox=-74.0118232808,40.7028304899,-74.0094567192,40.7046315099"     downloadedFilePath = "c:/map.osm"     fileDownloaded_success = downloadFile(downloadLink, downloadedFilePath)     print "fileDownloaded_success: ", fileDownloaded_success


Mentioned person gets the following printed to his console, after running the code:

 e1: Unable to connect to the remote server
e2: [Errno socket error] getaddrinfo returns an empty list
fileDownloaded_success: False


He tried turning off both his Antivirus and Windows Firewall, and the upper two error messages did not go away. We can not use a newer version of IronPython, as 2.7 is what is shipped with Rhino5 application (we basically use IronPython 2.7 editor inside Rhino5 application). I would be grateful for any kind of reply, as I do not know what is the problem at his place. I did some googling with similar error message, but I do not know if this could be the same situation.
 Thank you in advance!!


_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
https://mail.python.org/mailman/listinfo/ironpython-users


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20170215/fc4aa05d/attachment.html>


More information about the Ironpython-users mailing list