Addon Manager: Clean up report window output
This commit is contained in:
@@ -83,7 +83,7 @@ class CommandAddonManager:
|
||||
"install_worker",
|
||||
"update_metadata_cache_worker",
|
||||
"update_all_worker",
|
||||
"update_check_single_worker"
|
||||
"update_check_single_worker",
|
||||
]
|
||||
|
||||
lock = threading.Lock()
|
||||
@@ -217,7 +217,9 @@ class CommandAddonManager:
|
||||
# set nice icons to everything, by theme with fallback to FreeCAD icons
|
||||
self.dialog.setWindowIcon(QtGui.QIcon(":/icons/AddonManager.svg"))
|
||||
self.dialog.buttonUpdateAll.setIcon(QtGui.QIcon(":/icons/button_valid.svg"))
|
||||
self.dialog.buttonCheckForUpdates.setIcon(QtGui.QIcon(":/icons/view-refresh.svg"))
|
||||
self.dialog.buttonCheckForUpdates.setIcon(
|
||||
QtGui.QIcon(":/icons/view-refresh.svg")
|
||||
)
|
||||
self.dialog.buttonClose.setIcon(
|
||||
QtGui.QIcon.fromTheme("close", QtGui.QIcon(":/icons/process-stop.svg"))
|
||||
)
|
||||
@@ -234,7 +236,9 @@ class CommandAddonManager:
|
||||
# connect slots
|
||||
self.dialog.rejected.connect(self.reject)
|
||||
self.dialog.buttonUpdateAll.clicked.connect(self.update_all)
|
||||
self.dialog.buttonCheckForUpdates.clicked.connect(self.manually_check_for_updates)
|
||||
self.dialog.buttonCheckForUpdates.clicked.connect(
|
||||
self.manually_check_for_updates
|
||||
)
|
||||
self.dialog.buttonClose.clicked.connect(self.dialog.reject)
|
||||
self.dialog.buttonUpdateCache.clicked.connect(self.on_buttonUpdateCache_clicked)
|
||||
self.dialog.buttonShowDetails.clicked.connect(self.toggle_details)
|
||||
@@ -325,35 +329,28 @@ class CommandAddonManager:
|
||||
self.write_package_cache()
|
||||
self.write_macro_cache()
|
||||
|
||||
# all threads have finished
|
||||
if oktoclose:
|
||||
if self.restart_required:
|
||||
# display restart dialog
|
||||
m = QtWidgets.QMessageBox()
|
||||
m.setWindowTitle(translate("AddonsInstaller", "Addon manager"))
|
||||
m.setWindowIcon(QtGui.QIcon(":/icons/AddonManager.svg"))
|
||||
m.setText(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"You must restart FreeCAD for changes to take " "effect.",
|
||||
)
|
||||
if self.restart_required:
|
||||
# display restart dialog
|
||||
m = QtWidgets.QMessageBox()
|
||||
m.setWindowTitle(translate("AddonsInstaller", "Addon manager"))
|
||||
m.setWindowIcon(QtGui.QIcon(":/icons/AddonManager.svg"))
|
||||
m.setText(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"You must restart FreeCAD for changes to take effect.",
|
||||
)
|
||||
m.setIcon(m.Warning)
|
||||
m.setStandardButtons(m.Ok | m.Cancel)
|
||||
m.setDefaultButton(m.Cancel)
|
||||
okBtn = m.button(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
cancelBtn = m.button(QtWidgets.QMessageBox.StandardButton.Cancel)
|
||||
okBtn.setText(translate("AddonsInstaller", "Restart now"))
|
||||
cancelBtn.setText(translate("AddonsInstaller", "Restart later"))
|
||||
ret = m.exec_()
|
||||
if ret == m.Ok:
|
||||
# restart FreeCAD after a delay to give time to this dialog to close
|
||||
QtCore.QTimer.singleShot(1000, utils.restart_freecad)
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"Could not terminate sub-threads in Addon Manager.\n"
|
||||
)
|
||||
self.cleanup_workers()
|
||||
m.setIcon(m.Warning)
|
||||
m.setStandardButtons(m.Ok | m.Cancel)
|
||||
m.setDefaultButton(m.Cancel)
|
||||
okBtn = m.button(QtWidgets.QMessageBox.StandardButton.Ok)
|
||||
cancelBtn = m.button(QtWidgets.QMessageBox.StandardButton.Cancel)
|
||||
okBtn.setText(translate("AddonsInstaller", "Restart now"))
|
||||
cancelBtn.setText(translate("AddonsInstaller", "Restart later"))
|
||||
ret = m.exec_()
|
||||
if ret == m.Ok:
|
||||
# restart FreeCAD after a delay to give time to this dialog to close
|
||||
QtCore.QTimer.singleShot(1000, utils.restart_freecad)
|
||||
|
||||
def startup(self) -> None:
|
||||
"""Downloads the available packages listings and populates the table
|
||||
@@ -475,14 +472,18 @@ class CommandAddonManager:
|
||||
self.macro_worker.status_message_signal.connect(self.show_information)
|
||||
self.macro_worker.progress_made.connect(self.update_progress_bar)
|
||||
self.macro_worker.add_macro_signal.connect(self.add_addon_repo)
|
||||
self.macro_worker.finished.connect(self.do_next_startup_phase) # Link to step 3
|
||||
self.macro_worker.finished.connect(
|
||||
self.do_next_startup_phase
|
||||
) # Link to step 3
|
||||
self.macro_worker.start()
|
||||
else:
|
||||
self.macro_worker = LoadMacrosFromCacheWorker(
|
||||
self.get_cache_file_name("macro_cache.json")
|
||||
)
|
||||
self.macro_worker.add_macro_signal.connect(self.add_addon_repo)
|
||||
self.macro_worker.finished.connect(self.do_next_startup_phase) # Link to step 3
|
||||
self.macro_worker.finished.connect(
|
||||
self.do_next_startup_phase
|
||||
) # Link to step 3
|
||||
self.macro_worker.start()
|
||||
|
||||
def cache_macro(self, macro: AddonManagerRepo):
|
||||
@@ -719,20 +720,27 @@ class CommandAddonManager:
|
||||
self.install(repo)
|
||||
|
||||
def check_for_update(self, repo: AddonManagerRepo) -> None:
|
||||
""" Check a single repo for available updates asynchronously """
|
||||
"""Check a single repo for available updates asynchronously"""
|
||||
|
||||
if hasattr(self, "update_check_single_worker") and self.update_check_single_worker:
|
||||
if (
|
||||
hasattr(self, "update_check_single_worker")
|
||||
and self.update_check_single_worker
|
||||
):
|
||||
if self.update_check_single_worker.isRunning():
|
||||
self.update_check_single_worker.requestInterrupt()
|
||||
self.update_check_single_worker.wait()
|
||||
|
||||
self.update_check_single_worker = CheckSingleWorker(repo.name)
|
||||
self.update_check_single_worker.updateAvailable.connect(
|
||||
lambda update_available : self.mark_repo_update_available(repo, update_available)
|
||||
lambda update_available: self.mark_repo_update_available(
|
||||
repo, update_available
|
||||
)
|
||||
)
|
||||
self.update_check_single_worker.start()
|
||||
|
||||
def mark_repo_update_available(self, repo:AddonManagerRepo, available:bool) -> None:
|
||||
def mark_repo_update_available(
|
||||
self, repo: AddonManagerRepo, available: bool
|
||||
) -> None:
|
||||
if available:
|
||||
repo.update_status = AddonManagerRepo.UpdateStatus.UPDATE_AVAILABLE
|
||||
else:
|
||||
|
||||
@@ -130,7 +130,10 @@ class AddonManagerRepo:
|
||||
if instance.repo_type == AddonManagerRepo.RepoType.PACKAGE:
|
||||
# There must be a cached metadata file, too
|
||||
cached_package_xml_file = os.path.join(
|
||||
FreeCAD.getUserCachePath(), "AddonManager", "PackageMetadata", instance.name
|
||||
FreeCAD.getUserCachePath(),
|
||||
"AddonManager",
|
||||
"PackageMetadata",
|
||||
instance.name,
|
||||
)
|
||||
if os.path.isfile(cached_package_xml_file):
|
||||
instance.load_metadata_file(cached_package_xml_file)
|
||||
@@ -149,12 +152,12 @@ class AddonManagerRepo:
|
||||
"cached_icon_filename": self.get_cached_icon_filename(),
|
||||
}
|
||||
|
||||
def load_metadata_file (self, file:str) -> None:
|
||||
def load_metadata_file(self, file: str) -> None:
|
||||
if os.path.isfile(file):
|
||||
metadata = FreeCAD.Metadata(file)
|
||||
self.set_metadata(metadata)
|
||||
|
||||
def set_metadata (self, metadata:FreeCAD.Metadata) -> None:
|
||||
def set_metadata(self, metadata: FreeCAD.Metadata) -> None:
|
||||
self.metadata = metadata
|
||||
self.display_name = metadata.Name
|
||||
self.repo_type = AddonManagerRepo.RepoType.PACKAGE
|
||||
@@ -175,7 +178,9 @@ class AddonManagerRepo:
|
||||
elif self.repo_type == AddonManagerRepo.RepoType.PACKAGE:
|
||||
content = self.metadata.Content
|
||||
if not content:
|
||||
FreeCAD.Console.PrintWarning(f"Package {self.display_name} does not list any content items in its package.xml metadata file. Try refreshing the cache.\n")
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Package {self.display_name} does not list any content items in its package.xml metadata file.\n"
|
||||
)
|
||||
return False
|
||||
return "workbench" in content
|
||||
else:
|
||||
|
||||
@@ -130,9 +130,11 @@ class Macro(object):
|
||||
u = urlopen(url)
|
||||
if u is None:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"AddonManager: Debug: connection is lost (proxy setting changed?)",
|
||||
url,
|
||||
"\n",
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
f"Could not connect to {url} - check connection and proxy settings",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return
|
||||
p = u.read()
|
||||
@@ -148,7 +150,11 @@ class Macro(object):
|
||||
u2 = urlopen(rawcodeurl)
|
||||
if u2 is None:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"AddonManager: Debug: unable to open URL", rawcodeurl, "\n"
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"Unable to open macro code URL {rawcodeurl}",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return
|
||||
# code = u2.read()
|
||||
@@ -252,7 +258,7 @@ class Macro(object):
|
||||
if len(warnings) > 0:
|
||||
return False, warnings
|
||||
|
||||
FreeCAD.Console.PrintMessage(f"Macro {self.name} was installed successfully.\n")
|
||||
FreeCAD.Console.PrintLog(f"Macro {self.name} was installed successfully.\n")
|
||||
return True, []
|
||||
|
||||
def remove(self) -> bool:
|
||||
@@ -280,7 +286,11 @@ class Macro(object):
|
||||
remove_directory_if_empty(os.path.dirname(dst_file))
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
f"Failed to remove macro file '{dst_file}': it might not exist, or its permissions changed\n"
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
f"Failed to remove macro file '{dst_file}': it might not exist, or its permissions changed",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ from PySide2.QtCore import QObject
|
||||
import addonmanager_utilities as utils
|
||||
from AddonManagerRepo import AddonManagerRepo
|
||||
|
||||
translate = FreeCAD.Qt.translate
|
||||
|
||||
|
||||
class MetadataDownloadWorker(QObject):
|
||||
"""A worker for downloading package.xml and associated icon(s)
|
||||
@@ -48,8 +50,8 @@ class MetadataDownloadWorker(QObject):
|
||||
|
||||
updated = QtCore.Signal(AddonManagerRepo)
|
||||
|
||||
def __init__(self, parent, repo:AddonManagerRepo, index:Dict[str,str]):
|
||||
""" repo is an AddonManagerRepo object, and index is a dictionary of SHA1 hashes of the package.xml files in the cache """
|
||||
def __init__(self, parent, repo: AddonManagerRepo, index: Dict[str, str]):
|
||||
"""repo is an AddonManagerRepo object, and index is a dictionary of SHA1 hashes of the package.xml files in the cache"""
|
||||
|
||||
super().__init__(parent)
|
||||
self.repo = repo
|
||||
@@ -60,7 +62,7 @@ class MetadataDownloadWorker(QObject):
|
||||
self.last_sha1 = ""
|
||||
self.url = self.repo.metadata_url
|
||||
|
||||
def start_fetch(self, network_manager:QtNetwork.QNetworkAccessManager):
|
||||
def start_fetch(self, network_manager: QtNetwork.QNetworkAccessManager):
|
||||
"""Asynchronously begin the network access. Intended as a set-and-forget black box for downloading metadata."""
|
||||
|
||||
self.request = QtNetwork.QNetworkRequest(QtCore.QUrl(self.url))
|
||||
@@ -82,19 +84,19 @@ class MetadataDownloadWorker(QObject):
|
||||
# For now just blindly follow all redirects
|
||||
self.fetch_task.redirectAllowed.emit()
|
||||
|
||||
def on_ssl_error(self, reply:str, errors:List[str]):
|
||||
FreeCAD.Console.PrintWarning(f"Error with encrypted connection:\n")
|
||||
def on_ssl_error(self, reply: str, errors: List[str]):
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate("AddonsInstaller", "Error with encrypted connection") + "\n:"
|
||||
)
|
||||
FreeCAD.Console.PrintWarning(reply)
|
||||
for error in errors:
|
||||
FreeCAD.Console.PrintWarning(error)
|
||||
|
||||
def resolve_fetch(self):
|
||||
""" Called when the data fetch completed, either with an error, or if it found the metadata file """
|
||||
"""Called when the data fetch completed, either with an error, or if it found the metadata file"""
|
||||
|
||||
if self.fetch_task.error() == QtNetwork.QNetworkReply.NetworkError.NoError:
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Found a metadata file for {self.repo.name}\n"
|
||||
)
|
||||
FreeCAD.Console.PrintLog(f"Found a metadata file for {self.repo.name}\n")
|
||||
self.repo.repo_type = AddonManagerRepo.RepoType.PACKAGE
|
||||
new_xml = self.fetch_task.readAll()
|
||||
hasher = hashlib.sha1()
|
||||
@@ -131,8 +133,9 @@ class MetadataDownloadWorker(QObject):
|
||||
):
|
||||
pass
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate("AddonsInstaller", "Failed to connect to") + f" {self.url}:\n {self.fetch_task.error()}\n"
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate("AddonsInstaller", "Failed to connect to URL")
|
||||
+ f":\n{self.url}\n {self.fetch_task.error()}\n"
|
||||
)
|
||||
|
||||
def update_local_copy(self, new_xml):
|
||||
@@ -154,7 +157,7 @@ class MetadataDownloadWorker(QObject):
|
||||
|
||||
if not icon:
|
||||
# If there is no icon set for the entire package, see if there are
|
||||
# any workbenches, which are required to have icons, and grab the first
|
||||
# any workbenches, which are required to have icons, and grab the first
|
||||
# one we find:
|
||||
content = self.repo.metadata.Content
|
||||
if "workbench" in content:
|
||||
|
||||
@@ -125,7 +125,9 @@ def urlopen(url: str):
|
||||
u = urllib.request.urlopen(req, timeout=timeout)
|
||||
|
||||
except URLError as e:
|
||||
FreeCAD.Console.PrintError(f"Error loading {url}:\n {e.reason}\n")
|
||||
FreeCAD.Console.PrintError(
|
||||
translate("AddonsInstaller", f"Error loading {url}") + ":\n {e.reason}\n"
|
||||
)
|
||||
return None
|
||||
except Exception:
|
||||
return None
|
||||
@@ -148,7 +150,7 @@ def update_macro_details(old_macro, new_macro):
|
||||
"""
|
||||
|
||||
if old_macro.on_git and new_macro.on_git:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
'The macro "{}" is present twice in github, please report'.format(
|
||||
old_macro.name
|
||||
)
|
||||
@@ -200,7 +202,7 @@ def get_zip_url(repo):
|
||||
reponame = baseurl.strip("/").split("/")[-1]
|
||||
return f"{repo.url}/-/archive/{repo.branch}/{repo.name}-{repo.branch}.zip"
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
"Debug: addonmanager_utilities.get_zip_url: Unknown git host:",
|
||||
parsedUrl.netloc,
|
||||
)
|
||||
@@ -251,7 +253,7 @@ def get_desc_regex(repo):
|
||||
or parsedUrl.netloc == "salsa.debian.org"
|
||||
):
|
||||
return r'<meta.*?content="(.*?)".*?og:description.*?>'
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
"Debug: addonmanager_utilities.get_desc_regex: Unknown git host:", repo.url
|
||||
)
|
||||
return None
|
||||
|
||||
@@ -127,7 +127,13 @@ class UpdateWorker(QtCore.QThread):
|
||||
if "py2only" in j and "Mod" in j["py2only"]:
|
||||
py2only = j["py2only"]["Mod"]
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning("Debug: addon_flags.json not found\n")
|
||||
message = translate(
|
||||
"AddonsInstaller",
|
||||
"Failed to connect to GitHub. Check your connection and proxy settings.",
|
||||
)
|
||||
FreeCAD.Console.PrintError(message + "\n")
|
||||
self.status_message.emit(message)
|
||||
return
|
||||
|
||||
basedir = FreeCAD.getUserAppDataDir()
|
||||
moddir = basedir + os.sep + "Mod"
|
||||
@@ -167,7 +173,7 @@ class UpdateWorker(QtCore.QThread):
|
||||
else:
|
||||
state = AddonManagerRepo.UpdateStatus.NOT_INSTALLED
|
||||
repo = AddonManagerRepo(name, addon["url"], state, addon["branch"])
|
||||
md_file = os.path.join(addondir,"package.xml")
|
||||
md_file = os.path.join(addondir, "package.xml")
|
||||
if os.path.isfile(md_file):
|
||||
repo.load_metadata_file(md_file)
|
||||
repo.installed_version = repo.metadata.Version
|
||||
@@ -212,7 +218,7 @@ class UpdateWorker(QtCore.QThread):
|
||||
else:
|
||||
state = AddonManagerRepo.UpdateStatus.NOT_INSTALLED
|
||||
repo = AddonManagerRepo(name, url, state, branch)
|
||||
md_file = os.path.join(addondir,"package.xml")
|
||||
md_file = os.path.join(addondir, "package.xml")
|
||||
if os.path.isfile(md_file):
|
||||
repo.load_metadata_file(md_file)
|
||||
repo.installed_version = repo.metadata.Version
|
||||
@@ -255,10 +261,12 @@ class LoadPackagesFromCacheWorker(QtCore.QThread):
|
||||
try:
|
||||
repo.load_metadata_file(repo_metadata_cache_path)
|
||||
repo.installed_version = repo.metadata.Version
|
||||
repo.updated_timestamp = os.path.getmtime(repo_metadata_cache_path)
|
||||
repo.updated_timestamp = os.path.getmtime(
|
||||
repo_metadata_cache_path
|
||||
)
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate("AddonsInstaller","Failed loading") + f"{repo_metadata_cache_path}\n"
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Failed loading {repo_metadata_cache_path}\n"
|
||||
)
|
||||
pass
|
||||
self.addon_repo.emit(repo)
|
||||
@@ -326,6 +334,7 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
self.done.emit()
|
||||
|
||||
def check_workbench(self, wb):
|
||||
gitpython_warning = False
|
||||
if not have_git or NOGIT:
|
||||
return
|
||||
clonedir = self.moddir + os.sep + wb.name
|
||||
@@ -344,8 +353,7 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"Outdated GitPython detected, "
|
||||
"consider upgrading with pip.",
|
||||
"Outdated GitPython detected, consider upgrading with pip.",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
@@ -362,10 +370,9 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"AddonManager: "
|
||||
+ translate(
|
||||
"AddonsInstaller", "Unable to fetch git updates for workbench"
|
||||
"AddonsInstaller",
|
||||
f"Unable to fetch git updates for workbench {wb.name}",
|
||||
)
|
||||
+ " "
|
||||
+ wb.name
|
||||
)
|
||||
else:
|
||||
try:
|
||||
@@ -380,8 +387,7 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
self.update_status.emit(wb)
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"AddonManager - " + wb.name + " git status"
|
||||
" fatal: this operation must be run in a work tree \n"
|
||||
translate("AddonsInstaller", "git pull failed for {wb.name}")
|
||||
)
|
||||
|
||||
def check_package(self, package: AddonManagerRepo) -> None:
|
||||
@@ -415,8 +421,11 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
self.update_status.emit(package)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate("AddonsInstaller", "Failed to read metadata from")
|
||||
+ f" {installed_metadata_file}"
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
f"Failed to read metadata from {installed_metadata_file}",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
def check_macro(self, macro_wrapper: AddonManagerRepo) -> None:
|
||||
@@ -434,7 +443,11 @@ class CheckWorkbenchesForUpdatesWorker(QtCore.QThread):
|
||||
macro_wrapper.macro.fill_details_from_wiki(url)
|
||||
except Exception:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
f"Failed to fetch code for macro '{macro_wrapper.macro.name}'\n"
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
f"Failed to fetch code for macro '{macro_wrapper.macro.name}'",
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
return
|
||||
|
||||
@@ -523,16 +536,12 @@ class FillMacroListWorker(QtCore.QThread):
|
||||
"""
|
||||
|
||||
if not have_git or NOGIT:
|
||||
self.status_message_signal.emit(
|
||||
"GitPython not installed! Cannot retrieve macros from Git"
|
||||
)
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"GitPython not installed! Cannot retrieve macros from git",
|
||||
)
|
||||
+ "\n"
|
||||
message = translate(
|
||||
"AddonsInstaller",
|
||||
"Failed to execute Git Python command: check installation of GitPython and/or git",
|
||||
)
|
||||
self.status_message_signal.emit(message)
|
||||
FreeCAD.Console.PrintWarning(message + "\n")
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -546,11 +555,9 @@ class FillMacroListWorker(QtCore.QThread):
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"An error occurred fetching macros from GitHub:\n"
|
||||
f"{e}"
|
||||
"AddonsInstaller", "An error occurred fetching macros from GitHub"
|
||||
)
|
||||
+ "\n"
|
||||
+ f":\n{e}\n"
|
||||
)
|
||||
n_files = 0
|
||||
for _, _, filenames in os.walk(self.repo_dir):
|
||||
@@ -649,12 +656,10 @@ class ShowWorker(QtCore.QThread):
|
||||
# extract readme from html via regex
|
||||
readmeurl = utils.get_readme_html_url(self.repo)
|
||||
if not readmeurl:
|
||||
FreeCAD.Console.PrintWarning(f"Debug: README not found for {url}\n")
|
||||
FreeCAD.Console.PrintLog(f"README not found for {url}\n")
|
||||
u = utils.urlopen(readmeurl)
|
||||
if not u:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
f"Debug: README not found at {readmeurl}\n"
|
||||
)
|
||||
FreeCAD.Console.PrintLog(f"Debug: README not found at {readmeurl}\n")
|
||||
u = utils.urlopen(readmeurl)
|
||||
if u:
|
||||
p = u.read()
|
||||
@@ -665,14 +670,12 @@ class ShowWorker(QtCore.QThread):
|
||||
if readme:
|
||||
desc = readme[0]
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
f"Debug: README not found at {readmeurl}\n"
|
||||
)
|
||||
FreeCAD.Console.PrintLog(f"Debug: README not found at {readmeurl}\n")
|
||||
else:
|
||||
# convert raw markdown using lib
|
||||
readmeurl = utils.get_readme_url(self.repo)
|
||||
if not readmeurl:
|
||||
FreeCAD.Console.PrintWarning(f"Debug: README not found for {url}\n")
|
||||
FreeCAD.Console.PrintLog(f"Debug: README not found for {url}\n")
|
||||
u = utils.urlopen(readmeurl)
|
||||
if u:
|
||||
p = u.read()
|
||||
@@ -695,7 +698,7 @@ class ShowWorker(QtCore.QThread):
|
||||
message += "<br/></div><hr/><pre>" + desc + "</pre>"
|
||||
desc = message
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning("Debug: README not found at {readmeurl}\n")
|
||||
FreeCAD.Console.PrintLog("Debug: README not found at {readmeurl}\n")
|
||||
if desc == "":
|
||||
# fall back to the description text
|
||||
u = utils.urlopen(url)
|
||||
@@ -966,7 +969,7 @@ class InstallWorkbenchWorker(QtCore.QThread):
|
||||
return
|
||||
|
||||
if not have_git or NOGIT:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"GitPython not found. Using ZIP file download instead.",
|
||||
@@ -1000,7 +1003,7 @@ class InstallWorkbenchWorker(QtCore.QThread):
|
||||
def run_git(self, clonedir: str) -> None:
|
||||
|
||||
if NOGIT or not have_git:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"No Git Python installed, skipping git operations",
|
||||
@@ -1020,7 +1023,7 @@ class InstallWorkbenchWorker(QtCore.QThread):
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"User requested updating a Python 2 workbench on "
|
||||
"You are installing a Python 2 workbench on "
|
||||
"a system running Python 3 - ",
|
||||
)
|
||||
+ str(self.repo.name)
|
||||
@@ -1036,7 +1039,7 @@ class InstallWorkbenchWorker(QtCore.QThread):
|
||||
with bare_repo.config_writer() as cw:
|
||||
cw.set("core", "bare", False)
|
||||
except AttributeError:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
FreeCAD.Console.PrintLog(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"Outdated GitPython detected, consider " "upgrading with pip.",
|
||||
@@ -1082,8 +1085,8 @@ class InstallWorkbenchWorker(QtCore.QThread):
|
||||
FreeCAD.Console.PrintWarning(
|
||||
translate(
|
||||
"AddonsInstaller",
|
||||
"User requested installing a Python 2 "
|
||||
"workbench on a system running Python 3 - ",
|
||||
"You are installing a Python 2 workbench on "
|
||||
"a system running Python 3 - ",
|
||||
)
|
||||
+ str(self.repo.name)
|
||||
+ "\n"
|
||||
@@ -1429,7 +1432,7 @@ class UpdateMetadataCacheWorker(QtCore.QThread):
|
||||
break
|
||||
|
||||
if aborted:
|
||||
FreeCAD.Console.PrintMessage("Metadata update cancelled\n")
|
||||
FreeCAD.Console.PrintLog("Metadata update cancelled\n")
|
||||
return
|
||||
|
||||
# Update and serialize the updated index, overwriting whatever was
|
||||
@@ -1573,7 +1576,9 @@ class UpdateSingleWorker(QtCore.QThread):
|
||||
install_succeeded, errors = repo.macro.install(cache_path)
|
||||
|
||||
if install_succeeded:
|
||||
install_succeeded, errors = repo.macro.install(FreeCAD.getUserMacroDir(True))
|
||||
install_succeeded, errors = repo.macro.install(
|
||||
FreeCAD.getUserMacroDir(True)
|
||||
)
|
||||
|
||||
if install_succeeded:
|
||||
self.success.emit(repo)
|
||||
|
||||
@@ -62,7 +62,9 @@ class PackageDetails(QWidget):
|
||||
self.ui.buttonInstall.clicked.connect(lambda: self.install.emit(self.repo))
|
||||
self.ui.buttonUninstall.clicked.connect(lambda: self.uninstall.emit(self.repo))
|
||||
self.ui.buttonUpdate.clicked.connect(lambda: self.update.emit(self.repo))
|
||||
self.ui.buttonCheckForUpdate.clicked.connect(lambda: self.check_for_update.emit(self.repo))
|
||||
self.ui.buttonCheckForUpdate.clicked.connect(
|
||||
lambda: self.check_for_update.emit(self.repo)
|
||||
)
|
||||
|
||||
def show_repo(self, repo: AddonManagerRepo, reload: bool = False) -> None:
|
||||
|
||||
@@ -151,7 +153,7 @@ class PackageDetails(QWidget):
|
||||
+ "."
|
||||
)
|
||||
elif repo.update_status == AddonManagerRepo.UpdateStatus.UNCHECKED:
|
||||
|
||||
|
||||
pref = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Addons")
|
||||
autocheck = pref.GetBool("AutoCheck", False)
|
||||
if autocheck:
|
||||
@@ -160,10 +162,10 @@ class PackageDetails(QWidget):
|
||||
)
|
||||
else:
|
||||
installed_version_string += (
|
||||
translate("AddonsInstaller", "Automatic update checks disabled") + "."
|
||||
translate("AddonsInstaller", "Automatic update checks disabled")
|
||||
+ "."
|
||||
)
|
||||
|
||||
|
||||
basedir = FreeCAD.getUserAppDataDir()
|
||||
moddir = os.path.join(basedir, "Mod", repo.name)
|
||||
installed_version_string += (
|
||||
@@ -230,15 +232,15 @@ class PackageDetails(QWidget):
|
||||
or force
|
||||
):
|
||||
if force:
|
||||
FreeCAD.Console.PrintMessage(
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Forced README cache update for {self.repo.name}\n"
|
||||
)
|
||||
elif download_interrupted:
|
||||
FreeCAD.Console.PrintMessage(
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Restarting interrupted README download for {self.repo.name}\n"
|
||||
)
|
||||
else:
|
||||
FreeCAD.Console.PrintMessage(
|
||||
FreeCAD.Console.PrintLog(
|
||||
f"Cache expired, downloading README for {self.repo.name} again\n"
|
||||
)
|
||||
os.remove(readme_cache_file)
|
||||
|
||||
@@ -42,6 +42,7 @@ class ListDisplayStyle(IntEnum):
|
||||
COMPACT = 0
|
||||
EXPANDED = 1
|
||||
|
||||
|
||||
class StatusFilter(IntEnum):
|
||||
ANY = 0
|
||||
INSTALLED = 1
|
||||
@@ -129,7 +130,9 @@ class PackageList(QWidget):
|
||||
"""filter name and description by the regex specified by text_filter"""
|
||||
|
||||
if text_filter:
|
||||
if hasattr(self.item_filter, "setFilterRegularExpression"): # Added in Qt 5.12
|
||||
if hasattr(
|
||||
self.item_filter, "setFilterRegularExpression"
|
||||
): # Added in Qt 5.12
|
||||
test_regex = QRegularExpression(text_filter)
|
||||
else:
|
||||
test_regex = QRegExp(text_filter)
|
||||
@@ -148,7 +151,7 @@ class PackageList(QWidget):
|
||||
self.ui.labelFilterValidity.show()
|
||||
else:
|
||||
self.ui.labelFilterValidity.hide()
|
||||
if hasattr(self.item_filter, "setFilterRegularExpression"): # Added in Qt 5.12
|
||||
if hasattr(self.item_filter, "setFilterRegularExpression"): # Added in Qt 5.12
|
||||
self.item_filter.setFilterRegularExpression(text_filter)
|
||||
else:
|
||||
self.item_filter.setFilterRegExp(text_filter)
|
||||
@@ -433,9 +436,7 @@ class PackageListItemDelegate(QStyledItemDelegate):
|
||||
|
||||
return result
|
||||
|
||||
def paint(
|
||||
self, painter: QPainter, option: QStyleOptionViewItem, _: QModelIndex
|
||||
):
|
||||
def paint(self, painter: QPainter, option: QStyleOptionViewItem, _: QModelIndex):
|
||||
painter.save()
|
||||
self.widget.resize(option.rect.size())
|
||||
painter.translate(option.rect.topLeft())
|
||||
@@ -449,7 +450,7 @@ class PackageListFilter(QSortFilterProxyModel):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.package_type = 0 # Default to showing everything
|
||||
self.status = 0 # Default to showing any
|
||||
self.status = 0 # Default to showing any
|
||||
self.setSortCaseSensitivity(Qt.CaseInsensitive)
|
||||
|
||||
def setPackageFilter(
|
||||
@@ -495,7 +496,7 @@ class PackageListFilter(QSortFilterProxyModel):
|
||||
|
||||
name = data.display_name
|
||||
desc = data.description
|
||||
if hasattr(self, "filterRegularExpression"): # Added in Qt 5.12
|
||||
if hasattr(self, "filterRegularExpression"): # Added in Qt 5.12
|
||||
re = self.filterRegularExpression()
|
||||
if re.isValid():
|
||||
re.setPatternOptions(QRegularExpression.CaseInsensitiveOption)
|
||||
@@ -634,13 +635,16 @@ class Ui_PackageList(object):
|
||||
StatusFilter.ANY, QCoreApplication.translate("AddonsInstaller", "Any", None)
|
||||
)
|
||||
self.comboStatus.setItemText(
|
||||
StatusFilter.INSTALLED, QCoreApplication.translate("AddonsInstaller", "Installed", None)
|
||||
StatusFilter.INSTALLED,
|
||||
QCoreApplication.translate("AddonsInstaller", "Installed", None),
|
||||
)
|
||||
self.comboStatus.setItemText(
|
||||
StatusFilter.NOT_INSTALLED, QCoreApplication.translate("AddonsInstaller", "Not installed", None)
|
||||
StatusFilter.NOT_INSTALLED,
|
||||
QCoreApplication.translate("AddonsInstaller", "Not installed", None),
|
||||
)
|
||||
self.comboStatus.setItemText(
|
||||
StatusFilter.UPDATE_AVAILABLE, QCoreApplication.translate("AddonsInstaller", "Update available", None)
|
||||
StatusFilter.UPDATE_AVAILABLE,
|
||||
QCoreApplication.translate("AddonsInstaller", "Update available", None),
|
||||
)
|
||||
self.lineEditFilter.setPlaceholderText(
|
||||
QCoreApplication.translate("AddonsInstaller", "Filter", None)
|
||||
|
||||
Reference in New Issue
Block a user