Refactor plugin start process in BackendPlugin

This commit simplifies the process of starting plugins in BackendPlugin.py. The changes include removal of unnecessary code for setting LD_LIBRARY_PATH and converting the assigned environment to a dictionary. This leads to cleaner, more maintainable code.

Contribute to CURA-11356
This commit is contained in:
Jelle Spijker 2024-02-26 18:17:54 +01:00
parent f9ad274e28
commit db6157f6f8
No known key found for this signature in database
GPG Key ID: 0E9129B3096F4E72

View File

@ -90,15 +90,12 @@ class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
"stdin": None,
"stdout": f, # Redirect output to file
"stderr": subprocess.STDOUT, # Combine stderr and stdout
"env": os.environ
"env": dict(os.environ)
}
run_prep_cmd = ""
if Platform.isWindows():
popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW
else:
run_prep_cmd = f"LD_LIBRARY_PATH={os.environ['LD_LIBRARY_PATH']}:$LD_LIBRARY_PATH "
Logger.info(f"Starting plugin with: {popen_kwargs}")
self._process = subprocess.Popen(f"{run_prep_cmd}{self._validatePluginCommand()}", **popen_kwargs)
self._process = subprocess.Popen(self._validatePluginCommand(), **popen_kwargs)
self._is_running = True
return True
except PermissionError: