diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 910705df42..3b589c28d2 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -13,7 +13,6 @@ from UM.Resources import Resources from UM.Settings.Validator import ValidatorState #To find if a setting is in an error state. We can't slice then. from UM.Platform import Platform - import cura.Settings from cura.OneAtATimeIterator import OneAtATimeIterator @@ -33,7 +32,6 @@ import Arcus from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") - class CuraEngineBackend(Backend): ## Starts the back-end plug-in. # @@ -44,11 +42,28 @@ class CuraEngineBackend(Backend): # Find out where the engine is located, and how it is called. # This depends on how Cura is packaged and which OS we are running on. - default_engine_location = os.path.join(Application.getInstallPrefix(), "bin", "CuraEngine") + executable_name = "CuraEngine" + default_engine_location = None + if os.path.exists(os.path.join(Application.getInstallPrefix(), "bin", executable_name)): + default_engine_location = os.path.join(Application.getInstallPrefix(), "bin", executable_name) if hasattr(sys, "frozen"): - default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine") + default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), executable_name) if Platform.isWindows(): default_engine_location += ".exe" + if Platform.isLinux() and not default_engine_location: + if not os.getenv("PATH"): + raise OSError("There is something wrong with your Linux installation.") + for pathdir in os.getenv("PATH").split(os.pathsep): + execpath = os.path.join(pathdir, executable_name) + if os.path.exists(execpath): + default_engine_location = execpath + break + + if not default_engine_location: + raise EnvironmentError("Could not find CuraEngine") + + Logger.log("i", "Found CuraEngine at: %s" %(default_engine_location)) + default_engine_location = os.path.abspath(default_engine_location) Preferences.getInstance().addPreference("backend/location", default_engine_location)