Skip to content

Commit

Permalink
AddonManager: Misc fixes from forum testers
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 15, 2019
1 parent 0620cae commit caef4b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/Mod/AddonManager/AddonManager.py
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/Mod/AddonManager/addonmanager_utilities.py
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/Mod/AddonManager/addonmanager_workers.py
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit caef4b6

Please sign in to comment.