mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Fix import changes
These broke the importing & exporting of profiles
This commit is contained in:
parent
e32c67ccd3
commit
ab28cb4615
1 changed files with 11 additions and 10 deletions
|
@ -9,9 +9,10 @@ from UM.FlameProfiler import pyqtSlot
|
||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
import UM.SaveFile
|
|
||||||
import UM.Platform
|
from UM.Platform import Platform
|
||||||
import UM.MimeTypeDatabase
|
from UM.SaveFile import SaveFile
|
||||||
|
from UM.MimeTypeDatabase import MimeTypeDatabase
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
@ -325,7 +326,7 @@ class ContainerManager(QObject):
|
||||||
mime_type = None
|
mime_type = None
|
||||||
if not file_type in self._container_name_filters:
|
if not file_type in self._container_name_filters:
|
||||||
try:
|
try:
|
||||||
mime_type = UM.MimeTypeDatabase.getMimeTypeForFile(file_url)
|
mime_type = MimeTypeDatabase.getMimeTypeForFile(file_url)
|
||||||
except MimeTypeNotFoundError:
|
except MimeTypeNotFoundError:
|
||||||
return { "status": "error", "message": "Unknown File Type" }
|
return { "status": "error", "message": "Unknown File Type" }
|
||||||
else:
|
else:
|
||||||
|
@ -336,7 +337,7 @@ class ContainerManager(QObject):
|
||||||
return { "status": "error", "message": "Container not found"}
|
return { "status": "error", "message": "Container not found"}
|
||||||
container = containers[0]
|
container = containers[0]
|
||||||
|
|
||||||
if UM.Platform.isOSX() and "." in file_url:
|
if Platform.isOSX() and "." in file_url:
|
||||||
file_url = file_url[:file_url.rfind(".")]
|
file_url = file_url[:file_url.rfind(".")]
|
||||||
|
|
||||||
for suffix in mime_type.suffixes:
|
for suffix in mime_type.suffixes:
|
||||||
|
@ -345,7 +346,7 @@ class ContainerManager(QObject):
|
||||||
else:
|
else:
|
||||||
file_url += "." + mime_type.preferredSuffix
|
file_url += "." + mime_type.preferredSuffix
|
||||||
|
|
||||||
if not UM.Platform.isWindows():
|
if not Platform.isWindows():
|
||||||
if os.path.exists(file_url):
|
if os.path.exists(file_url):
|
||||||
result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"),
|
result = QMessageBox.question(None, catalog.i18nc("@title:window", "File Already Exists"),
|
||||||
catalog.i18nc("@label", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_url))
|
catalog.i18nc("@label", "The file <filename>{0}</filename> already exists. Are you sure you want to overwrite it?").format(file_url))
|
||||||
|
@ -360,7 +361,7 @@ class ContainerManager(QObject):
|
||||||
if contents is None:
|
if contents is None:
|
||||||
return {"status": "error", "message": "Serialization returned None. Unable to write to file"}
|
return {"status": "error", "message": "Serialization returned None. Unable to write to file"}
|
||||||
|
|
||||||
with UM.SaveFile(file_url, "w") as f:
|
with SaveFile(file_url, "w") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
return { "status": "success", "message": "Succesfully exported container", "path": file_url}
|
return { "status": "success", "message": "Succesfully exported container", "path": file_url}
|
||||||
|
@ -383,7 +384,7 @@ class ContainerManager(QObject):
|
||||||
return { "status": "error", "message": "Invalid path" }
|
return { "status": "error", "message": "Invalid path" }
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mime_type = UM.MimeTypeDatabase.getMimeTypeForFile(file_url)
|
mime_type = MimeTypeDatabase.getMimeTypeForFile(file_url)
|
||||||
except MimeTypeNotFoundError:
|
except MimeTypeNotFoundError:
|
||||||
return { "status": "error", "message": "Could not determine mime type of file" }
|
return { "status": "error", "message": "Could not determine mime type of file" }
|
||||||
|
|
||||||
|
@ -742,7 +743,7 @@ class ContainerManager(QObject):
|
||||||
}
|
}
|
||||||
|
|
||||||
suffix = mime_type.preferredSuffix
|
suffix = mime_type.preferredSuffix
|
||||||
if UM.Platform.isOSX() and "." in suffix:
|
if Platform.isOSX() and "." in suffix:
|
||||||
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
||||||
suffix = suffix[suffix.index(".") + 1:]
|
suffix = suffix[suffix.index(".") + 1:]
|
||||||
|
|
||||||
|
@ -751,7 +752,7 @@ class ContainerManager(QObject):
|
||||||
if suffix == mime_type.preferredSuffix:
|
if suffix == mime_type.preferredSuffix:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if UM.Platform.isOSX() and "." in suffix:
|
if Platform.isOSX() and "." in suffix:
|
||||||
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
||||||
suffix = suffix[suffix.index("."):]
|
suffix = suffix[suffix.index("."):]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue