Skip to content
Permalink
Browse files

AddonManager: Misc fixes from forum testers

  • Loading branch information...
yorikvanhavre committed Jun 15, 2019
1 parent 0620cae commit caef4b6c68a24a4c003dde560a7d39787a111b84
@@ -400,15 +400,13 @@ def show_progress_bar(self, state):
"shows or hides the progress bar"

if state == True:
self.dialog.listWorkbenches.setEnabled(False)
self.dialog.listMacros.setEnabled(False)
self.dialog.tabWidget.setEnabled(False)
self.dialog.buttonInstall.setEnabled(False)
self.dialog.buttonUninstall.setEnabled(False)
self.dialog.progressBar.show()
else:
self.dialog.progressBar.hide()
self.dialog.listWorkbenches.setEnabled(True)
self.dialog.listMacros.setEnabled(True)
self.dialog.tabWidget.setEnabled(True)
if not (self.firsttime and self.firstmacro):
self.dialog.buttonInstall.setEnabled(True)
self.dialog.buttonUninstall.setEnabled(True)
@@ -97,6 +97,17 @@ def urlopen(url):
return u


def getserver(url):

"""returns the server part of an url"""

if sys.version_info.major < 3:
from urlparse import urlparse
else:
from urllib.parse import urlparse
return '{uri.scheme}://{uri.netloc}/'.format(uri=urlparse(url))


def update_macro_details(old_macro, new_macro):

"""Update a macro with information from another one
@@ -35,6 +35,7 @@
from addonmanager_utilities import urlopen
from addonmanager_utilities import translate
from addonmanager_utilities import symlink
from addonmanager_utilities import getserver

MACROS_BLACKLIST = ["BOLTS","WorkFeatures","how to install","PartsLibrary","FCGear"]
OBSOLETE = ["assembly2","drawing_dimensioning","cura_engine"] # These addons will print an additional message informing the user
@@ -382,12 +383,12 @@ def run(self):

self.info_label.emit( message )
self.progressbar_show.emit(False)
l = self.loadImages( message )
l = self.loadImages( message, url )
if l:
self.info_label.emit( l )
self.stop = True

def loadImages(self,message):
def loadImages(self,message,url):

"checks if the given page contains images and downloads them"

@@ -402,6 +403,11 @@ def loadImages(self,message):
if not os.path.exists(store):
os.makedirs(store)
for path in imagepaths:
if "?" in path:
# remove everything after the ?
path = path.split("?")[0]
if not path.startswith("http"):
path = getserver(url) + path
name = path.split("/")[-1]
if name and path.startswith("http"):
storename = os.path.join(store,name)
@@ -426,7 +432,7 @@ def loadImages(self,message):
pix = pix.fromImage(img.scaled(300,300,QtCore.Qt.KeepAspectRatio,QtCore.Qt.FastTransformation))
pix.save(storename, "jpeg",100)

message = message.replace(path,"file://"+storename.replace("\\","/"))
message = message.replace(path,"file:///"+storename.replace("\\","/"))
return message
return None

0 comments on commit caef4b6

Please sign in to comment.
You can’t perform that action at this time.