mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 03:07:53 -06:00
Added ability for backend plugins to determine their usability
Modified BackendPlugin.py and StartSliceJob.py to allow plugins to decide when they should be used. The 'usePlugin' method was added to enable a plugin to return a boolean indicating if it should be used or not, e.q.: start up and connect to the services. Contributes to CURA-11031
This commit is contained in:
parent
3555073ee4
commit
45510d04ed
2 changed files with 8 additions and 0 deletions
|
@ -22,6 +22,10 @@ class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
|
||||||
self._process = None
|
self._process = None
|
||||||
self._is_running = False
|
self._is_running = False
|
||||||
self._supported_slots: List[int] = []
|
self._supported_slots: List[int] = []
|
||||||
|
self._use_plugin = True
|
||||||
|
|
||||||
|
def usePlugin(self) -> bool:
|
||||||
|
return self._use_plugin
|
||||||
|
|
||||||
def getSupportedSlots(self) -> List[int]:
|
def getSupportedSlots(self) -> List[int]:
|
||||||
return self._supported_slots
|
return self._supported_slots
|
||||||
|
@ -55,6 +59,8 @@ class BackendPlugin(AdditionalSettingDefinitionsAppender, PluginObject):
|
||||||
|
|
||||||
:return: True if the plugin process started successfully, False otherwise.
|
:return: True if the plugin process started successfully, False otherwise.
|
||||||
"""
|
"""
|
||||||
|
if not self.usePlugin():
|
||||||
|
return False
|
||||||
try:
|
try:
|
||||||
# STDIN needs to be None because we provide no input, but communicate via a local socket instead.
|
# STDIN needs to be None because we provide no input, but communicate via a local socket instead.
|
||||||
# The NUL device sometimes doesn't exist on some computers.
|
# The NUL device sometimes doesn't exist on some computers.
|
||||||
|
|
|
@ -303,6 +303,8 @@ class StartSliceJob(Job):
|
||||||
self._buildExtruderMessage(extruder_stack)
|
self._buildExtruderMessage(extruder_stack)
|
||||||
|
|
||||||
for plugin in CuraApplication.getInstance().getBackendPlugins():
|
for plugin in CuraApplication.getInstance().getBackendPlugins():
|
||||||
|
if not plugin.usePlugin():
|
||||||
|
continue
|
||||||
for slot in plugin.getSupportedSlots():
|
for slot in plugin.getSupportedSlots():
|
||||||
# Right now we just send the message for every slot that we support. A single plugin can support
|
# Right now we just send the message for every slot that we support. A single plugin can support
|
||||||
# multiple slots
|
# multiple slots
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue