From ab1b344410600b7d694abf6bb4ff2b71769978c5 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 9 Jun 2017 11:05:17 -0300 Subject: [PATCH] AddonManager: Further older ssl/urllib2 version support --- src/Mod/AddonManager/AddonManager.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Mod/AddonManager/AddonManager.py b/src/Mod/AddonManager/AddonManager.py index 4f73d45a13..8f17ae7bdf 100644 --- a/src/Mod/AddonManager/AddonManager.py +++ b/src/Mod/AddonManager/AddonManager.py @@ -353,7 +353,10 @@ class UpdateWorker(QtCore.QThread): def run(self): "populates the list of addons" self.progressbar_show.emit(True) - u = urllib2.urlopen("https://github.com/FreeCAD/FreeCAD-addons",context=ctx) + if ctx: + u = urllib2.urlopen("https://github.com/FreeCAD/FreeCAD-addons",context=ctx) + else: + u = urllib2.urlopen("https://github.com/FreeCAD/FreeCAD-addons") p = u.read() if sys.version_info.major >= 3 and isinstance(p, bytes): p = p.decode("utf-8") @@ -397,7 +400,10 @@ class InfoWorker(QtCore.QThread): i = 0 for repo in self.repos: url = repo[1] - u = urllib2.urlopen(url,context=ctx) + if ctx: + u = urllib2.urlopen(url,context=ctx) + else: + u = urllib2.urlopen(url) p = u.read() if sys.version_info.major >= 3 and isinstance(p, bytes): p = p.decode("utf-8") @@ -468,7 +474,10 @@ class MacroWorker(QtCore.QThread): self.info_label.emit("Downloading list of macros...") self.progressbar_show.emit(True) macropath = FreeCAD.ParamGet('User parameter:BaseApp/Preferences/Macro').GetString("MacroPath",os.path.join(FreeCAD.ConfigGet("UserAppData"),"Macro")) - u = urllib2.urlopen("https://www.freecadweb.org/wiki/Macros_recipes",context=ctx) + if ctx: + u = urllib2.urlopen("https://www.freecadweb.org/wiki/Macros_recipes",context=ctx) + else: + u = urllib2.urlopen("https://www.freecadweb.org/wiki/Macros_recipes") p = u.read() if sys.version_info.major >= 3 and isinstance(p, bytes): p = p.decode("utf-8") @@ -510,7 +519,10 @@ class ShowWorker(QtCore.QThread): else: url = self.repos[self.idx][1] self.info_label.emit(translate("AddonsInstaller", "Retrieving info from ") + str(url)) - u = urllib2.urlopen(url,context=ctx) + if ctx: + u = urllib2.urlopen(url,context=ctx) + else: + u = urllib2.urlopen(url) p = u.read() if sys.version_info.major >= 3 and isinstance(p, bytes): p = p.decode("utf-8") @@ -554,7 +566,10 @@ class ShowMacroWorker(QtCore.QThread): mac = mac.replace("+","%2B") url = "https://www.freecadweb.org/wiki/Macro_"+mac self.info_label.emit("Retrieving info from " + str(url)) - u = urllib2.urlopen(url,context=ctx) + if ctx: + u = urllib2.urlopen(url,context=ctx) + else: + u = urllib2.urlopen(url) p = u.read() if sys.version_info.major >= 3 and isinstance(p, bytes): p = p.decode("utf-8")