mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 00:04:27 +08:00
Merge branch 'feature_material_marketplace' of https://github.com/Ultimaker/Cura into feature_material_marketplace
This commit is contained in:
commit
6e9f7174b6
@ -4,7 +4,6 @@
|
||||
from typing import Optional
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
import tempfile
|
||||
@ -37,8 +36,6 @@ class CuraPackageManager(QObject):
|
||||
self._to_remove_package_set = set() # a set of packages that need to be removed at the next start
|
||||
self._to_install_package_dict = {} # a dict of packages that need to be installed at the next start
|
||||
|
||||
self._semantic_version_regex = re.compile(r"^[0-9]+(.[0-9]+)+$")
|
||||
|
||||
installedPackagesChanged = pyqtSignal() # Emitted whenever the installed packages collection have been changed.
|
||||
|
||||
def initialize(self):
|
||||
@ -84,14 +81,6 @@ class CuraPackageManager(QObject):
|
||||
self._to_install_package_dict.clear()
|
||||
self._saveManagementData()
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isPackageFile(self, file_name: str):
|
||||
# TODO: remove this
|
||||
extension = os.path.splitext(file_name)[1].strip(".")
|
||||
if extension.lower() in ("curapackage",):
|
||||
return True
|
||||
return False
|
||||
|
||||
# Checks the given package is installed. If so, return a dictionary that contains the package's information.
|
||||
def getInstalledPackageInfo(self, package_id: str) -> Optional[dict]:
|
||||
if package_id in self._to_remove_package_set:
|
||||
@ -133,8 +122,16 @@ class CuraPackageManager(QObject):
|
||||
if to_install_package:
|
||||
Logger.log("i", "Package [%s] version [%s] is scheduled to be installed.",
|
||||
package_id, package_info["package_version"])
|
||||
# Copy the file to cache dir so we don't need to rely on the original file to be present
|
||||
package_cache_dir = os.path.join(os.path.abspath(Resources.getCacheStoragePath()), "cura_packages")
|
||||
if not os.path.exists(package_cache_dir):
|
||||
os.makedirs(package_cache_dir, exist_ok=True)
|
||||
|
||||
target_file_path = os.path.join(package_cache_dir, package_id + ".curapackage")
|
||||
shutil.copy2(filename, target_file_path)
|
||||
|
||||
self._to_install_package_dict[package_id] = {"package_info": package_info,
|
||||
"filename": filename}
|
||||
"filename": target_file_path}
|
||||
has_changes = True
|
||||
|
||||
self._saveManagementData()
|
||||
@ -186,6 +183,10 @@ class CuraPackageManager(QObject):
|
||||
|
||||
package_id = package_info["package_id"]
|
||||
|
||||
if not os.path.exists(filename):
|
||||
Logger.log("w", "Package [%s] file '%s' is missing, cannot install this package", package_id, filename)
|
||||
return
|
||||
|
||||
Logger.log("i", "Installing package [%s] from file [%s]", package_id, filename)
|
||||
|
||||
# If it's installed, remove it first and then install
|
||||
@ -218,6 +219,9 @@ class CuraPackageManager(QObject):
|
||||
|
||||
archive.close()
|
||||
|
||||
# Remove the file
|
||||
os.remove(filename)
|
||||
|
||||
def __installPackageFiles(self, package_id: str, src_dir: str, dst_dir: str, need_to_rename_files: bool = True) -> None:
|
||||
shutil.move(src_dir, dst_dir)
|
||||
|
||||
|
@ -463,7 +463,7 @@ class Toolbox(QObject, Extension):
|
||||
self.openLicenseDialog(package_info["package_id"], license_content, file_path)
|
||||
return
|
||||
|
||||
self._package_manager.installPlugin(file_path)
|
||||
self.installPlugin(file_path)
|
||||
return
|
||||
|
||||
|
||||
|
@ -345,10 +345,6 @@ UM.MainWindow
|
||||
pluginInstallDialog.open();
|
||||
return;
|
||||
}
|
||||
else if (CuraApplication.getCuraPackageManager().isPackageFile(drop.urls[0]))
|
||||
{
|
||||
CuraApplication.getCuraPackageManager().install(drop.urls[0]);
|
||||
}
|
||||
}
|
||||
|
||||
openDialog.handleOpenFileUrls(drop.urls);
|
||||
|
Loading…
x
Reference in New Issue
Block a user