diff --git a/src/Mod/BIM/ArchCommands.py b/src/Mod/BIM/ArchCommands.py index d06978bb22..4ee234cc2a 100644 --- a/src/Mod/BIM/ArchCommands.py +++ b/src/Mod/BIM/ArchCommands.py @@ -759,10 +759,7 @@ def download(url, force=False): """download(url,force=False): downloads a file from the given URL and saves it in the macro path. Returns the path to the saved file. If force is True, the file will be downloaded again evn if it already exists.""" - try: - from urllib.request import urlopen - except ImportError: - from urllib2 import urlopen + from urllib.request import urlopen import os name = url.split("/")[-1] diff --git a/src/Mod/BIM/bimcommands/BimTutorial.py b/src/Mod/BIM/bimcommands/BimTutorial.py index 6a8c5469a9..d7b90ba8d4 100644 --- a/src/Mod/BIM/bimcommands/BimTutorial.py +++ b/src/Mod/BIM/bimcommands/BimTutorial.py @@ -97,11 +97,7 @@ class BIM_Tutorial: import codecs import re import sys - - if sys.version_info.major < 3: - import urllib2 - else: - import urllib.request as urllib2 + from urllib.request import urlopen # initial loading @@ -111,7 +107,7 @@ class BIM_Tutorial: # load tutorial from wiki offlineloc = os.path.join(FreeCAD.getUserAppDataDir(), "BIM", "Tutorial", "Tutorial.html") try: - u = urllib2.urlopen(URL) + u = urlopen(URL) html = u.read() if sys.version_info.major >= 3: html = html.decode("utf8") @@ -183,7 +179,7 @@ class BIM_Tutorial: fullpath = "https://www.freecadweb.org/wiki" + path else: fullpath = path - u = urllib2.urlopen(fullpath) + u = urlopen(fullpath) imagedata = u.read() f = open(storename, "wb") f.write(imagedata)