CURA-1223: 3MFReader: Doing selftest and fail on broken files

This commit adds a selftest before the "result" gets returned.
It should break on this/these functions and popup a message about using
the online repair tool.
I compared the content of both files for a long time, googled about the
format, but wasn't able to find a proper fix.
More routines will likely need to be added here, but with those I have
it is working so far very well.

Sadly it is not possible to override the default message, so two
messages will appear. Additionally, the URL of the link is not
clickable/executable from the UX. Just acting like normal text.

Contributes to CURA-1223
This commit is contained in:
Thomas Karl Pietrowski 2016-07-26 20:21:00 +02:00
parent b3f0c257e4
commit d96ce760f8

View File

@ -9,9 +9,13 @@ from UM.Math.Vector import Vector
from UM.Scene.SceneNode import SceneNode
from UM.Scene.GroupDecorator import GroupDecorator
from UM.Math.Quaternion import Quaternion
from UM.Job import Job
from UM.Message import Message
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
import math
import zipfile
@ -116,4 +120,11 @@ class ThreeMFReader(MeshReader):
except Exception as e:
Logger.log("e", "exception occured in 3mf reader: %s", e)
try: # Selftest - There might be more functions that should fail
result.getBoundingBox()
except:
message = Message(catalog.i18nc("@info:status", "Your 3MF file seems to be broken. Please visit https://modelrepair.azurewebsites.net/ and try to repair your model!"), lifetime = 0)
message.show()
return None
return result