mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Better info on no profiles to import for gcode
CIRA-4946 If a gcode is sliced with default profiles, there won't be any custom profiles to import from that gcode. In that case, we show a info message telling the user about this instead of showing an error message.
This commit is contained in:
parent
c41af83b41
commit
a81981a27a
3 changed files with 17 additions and 2 deletions
|
@ -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.")
|
||||
raise NotImplementedError("Profile reader plug-in was not correctly implemented. The read function was not implemented.")
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue