mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Catch URLError from firewall and give practical advice
This commit is contained in:
@@ -32,12 +32,12 @@ import os
|
|||||||
import wx
|
import wx
|
||||||
|
|
||||||
if sys.version_info >= (3,):
|
if sys.version_info >= (3,):
|
||||||
from urllib.error import HTTPError
|
from urllib.error import (HTTPError, URLError)
|
||||||
import urllib.request as urllib2
|
import urllib.request as urllib2
|
||||||
import urllib.parse as urlparse
|
import urllib.parse as urlparse
|
||||||
else:
|
else:
|
||||||
import urllib2
|
import urllib2
|
||||||
from urllib2 import HTTPError
|
from urllib2 import (HTTPError, URLError)
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
def get_docs_demo_url(demo=False):
|
def get_docs_demo_url(demo=False):
|
||||||
@@ -100,7 +100,15 @@ def download_file(url, dest=None, force=False):
|
|||||||
try:
|
try:
|
||||||
url_res = urllib2.urlopen(url)
|
url_res = urllib2.urlopen(url)
|
||||||
keep_going = True
|
keep_going = True
|
||||||
except HTTPError as err:
|
except (HTTPError, URLError) as err:
|
||||||
|
msg = '\n'.join([
|
||||||
|
"\n\nERROR in Web Access! - you may be behind a firewall",
|
||||||
|
"You may be able to bybass this by using a browser to download:",
|
||||||
|
"\n\t%s\n\nand copying to:\n\n\t%s" % (url, filename),
|
||||||
|
])
|
||||||
|
print(msg, '\n')
|
||||||
|
wx.MessageBox(msg, caption='WDOWNLOAD ERROR!',
|
||||||
|
style=wx.OK|wx.CENTRE|wx.ICON_ERROR)
|
||||||
return "Error: %s" % err
|
return "Error: %s" % err
|
||||||
|
|
||||||
with open(filename, 'wb') as outfile:
|
with open(filename, 'wb') as outfile:
|
||||||
|
|||||||
Reference in New Issue
Block a user