mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Scanning for CuraEngine and stop if it was not found
So far I ran 2 or 3 times into the problem that my engine was not up to date. The bad thing here is that there is always an updated version from my PPA on the PC. So first this commit gives the possibility to look for CuraEngine in the $PATH directories. Before I had to copy it always manually, eg. via "cp $(which CuraEngine) bin/CuraEngine" in my workbench. Second, people can get into the situation that CuraEngine is missing at all. So before making Cura loop and try to use an executable that does not exist, better raise an Exception here. An additional info message tells about the location being used. Does not contribute to any JIRA issue (I think), but makes my life easier.
This commit is contained in:
parent
96ac27d1c3
commit
34e8b4635b
@ -39,16 +39,35 @@ class CuraEngineBackend(Backend):
|
||||
#
|
||||
# This registers all the signal listeners and prepares for communication
|
||||
# with the back-end in general.
|
||||
|
||||
executableName = "CuraEngine"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# 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")
|
||||
default_engine_location = None
|
||||
if os.path.exists(os.path.join(Application.getInstallPrefix(), "bin", "CuraEngine")):
|
||||
default_engine_location = os.path.join(Application.getInstallPrefix(), "bin", "CuraEngine")
|
||||
if hasattr(sys, "frozen"):
|
||||
default_engine_location = os.path.join(os.path.dirname(os.path.abspath(sys.executable)), "CuraEngine")
|
||||
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, self.executableName)
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user