Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cura/ProfileReader.py9
-rw-r--r--cura/Settings/CuraContainerRegistry.py3
-rw-r--r--plugins/GCodeProfileReader/GCodeProfileReader.py7
3 files changed, 17 insertions, 2 deletions
diff --git a/cura/ProfileReader.py b/cura/ProfileReader.py
index d4600ed99f..460fce823e 100644
--- a/cura/ProfileReader.py
+++ b/cura/ProfileReader.py
@@ -3,6 +3,13 @@
from UM.PluginObject import PluginObject
+
+# Exception when there is no profile to import from a given files.
+# Note that this should not be treated as an exception but as an information instead.
+class NoProfileException(Exception):
+ pass
+
+
## A type of plug-ins that reads profiles from a file.
#
# The profile is then stored as instance container of the type user profile.
@@ -14,4 +21,4 @@ class ProfileReader(PluginObject):
#
# \return \type{Profile|Profile[]} The profile that was obtained from the file or a list of Profiles.
def read(self, file_name):
- raise NotImplementedError("Profile reader plug-in was not correctly implemented. The read function was not implemented.") \ No newline at end of file
+ raise NotImplementedError("Profile reader plug-in was not correctly implemented. The read function was not implemented.")
diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py
index e79cfa5335..4b576a4207 100644
--- a/cura/Settings/CuraContainerRegistry.py
+++ b/cura/Settings/CuraContainerRegistry.py
@@ -29,6 +29,7 @@ from .ExtruderManager import ExtruderManager
from cura.CuraApplication import CuraApplication
from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch
+from cura.ProfileReader import NoProfileException
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
@@ -185,6 +186,8 @@ class CuraContainerRegistry(ContainerRegistry):
profile_reader = plugin_registry.getPluginObject(plugin_id)
try:
profile_or_list = profile_reader.read(file_name) # Try to open the file with the profile reader.
+ except NoProfileException:
+ return { "status": "ok", "message": catalog.i18nc("@info:status Don't translate the XML tags <filename> or <message>!", "No custom profile to import in file <filename>{0}</filename>", file_name)}
except Exception as e:
# Note that this will fail quickly. That is, if any profile reader throws an exception, it will stop reading. It will only continue reading if the reader returned None.
Logger.log("e", "Failed to import profile from %s: %s while using profile reader. Got exception %s", file_name,profile_reader.getPluginId(), str(e))
diff --git a/plugins/GCodeProfileReader/GCodeProfileReader.py b/plugins/GCodeProfileReader/GCodeProfileReader.py
index 2a10e01d43..d6bda85a48 100644
--- a/plugins/GCodeProfileReader/GCodeProfileReader.py
+++ b/plugins/GCodeProfileReader/GCodeProfileReader.py
@@ -9,7 +9,7 @@ from UM.Logger import Logger
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
-from cura.ProfileReader import ProfileReader
+from cura.ProfileReader import ProfileReader, NoProfileException
## A class that reads profile data from g-code files.
#
@@ -66,6 +66,11 @@ class GCodeProfileReader(ProfileReader):
return None
serialized = unescapeGcodeComment(serialized)
+ serialized = serialized.strip()
+
+ if not serialized:
+ Logger.log("i", "No custom profile to import from this g-code: %s", file_name)
+ raise NoProfileException()
# serialized data can be invalid JSON
try: