🐛 Fix virtual printer & settings
This commit is contained in:
1 parent
306d4f2942
commit
875fb72fec
4 files changed
+24
-19
No files matched your search
@@ -14,14 +14,17 @@ from octoprint.settings import SubSettings
|
||||
from octoprint.util import CountedEvent, to_unicode
|
||||
from octoprint.util.listener import ListenerAware
|
||||
|
||||
SETTINGS_PATH = ["connection", "protocols"]
|
||||
|
||||
|
||||
_registry = {}
|
||||
|
||||
|
||||
def register_protocols(settings, path):
|
||||
def register_protocols(settings):
|
||||
from .reprap import ReprapGcodeProtocol
|
||||
|
||||
# stock protocols
|
||||
register_protocol(ReprapGcodeProtocol, settings, path)
|
||||
register_protocol(ReprapGcodeProtocol, settings, SETTINGS_PATH)
|
||||
|
||||
# more protocols provided by plugins
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -31,7 +34,7 @@ def register_protocols(settings, path):
|
||||
protocols = hook()
|
||||
for protocol in protocols:
|
||||
try:
|
||||
register_protocol(protocol, settings, path)
|
||||
register_protocol(protocol, settings, SETTINGS_PATH)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Error while registering protocol class {} for plugin {}".format(
|
||||
@@ -566,8 +569,10 @@ class ProtocolSettings(SubSettings):
|
||||
SubSettings.__init__(
|
||||
self,
|
||||
settings,
|
||||
["comm", "protocol", protocol.key],
|
||||
defaults=protocol.get_settings_defaults(),
|
||||
SETTINGS_PATH
|
||||
+ [
|
||||
protocol.key,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -10,10 +10,13 @@ from octoprint.plugin import plugin_manager
|
||||
from octoprint.settings import SubSettings
|
||||
from octoprint.util.listener import ListenerAware
|
||||
|
||||
SETTINGS_PATH = ["connection", "transports"]
|
||||
|
||||
|
||||
_registry = {}
|
||||
|
||||
|
||||
def register_transports(settings, path):
|
||||
def register_transports(settings):
|
||||
from .serialtransport import SerialTransport, SerialUrlTransport
|
||||
from .sockettransport import SerialOverTcpTransport, TcpTransport
|
||||
|
||||
@@ -24,7 +27,7 @@ def register_transports(settings, path):
|
||||
TcpTransport,
|
||||
SerialOverTcpTransport,
|
||||
):
|
||||
register_transport(transport, settings, path)
|
||||
register_transport(transport, settings, SETTINGS_PATH)
|
||||
|
||||
# more transports provided by plugins
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -34,7 +37,7 @@ def register_transports(settings, path):
|
||||
transports = hook()
|
||||
for transport in transports:
|
||||
try:
|
||||
register_transport(transport, settings, path)
|
||||
register_transport(transport, settings, SETTINGS_PATH)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Error while registering transport class {} for plugin {}".format(
|
||||
@@ -229,12 +232,7 @@ class TransportState:
|
||||
class TransportSettings(SubSettings):
|
||||
def __init__(self, settings, transport):
|
||||
self.transport = transport.key
|
||||
SubSettings.__init__(
|
||||
self,
|
||||
settings,
|
||||
["comm", "transport", transport.key],
|
||||
defaults=transport.get_settings_defaults(),
|
||||
)
|
||||
SubSettings.__init__(self, settings, SETTINGS_PATH + [transport.key])
|
||||
|
||||
|
||||
class TransportNotConnectedError(Exception):
|
||||
|
||||
@@ -10,7 +10,9 @@ class VirtualSerialTransport(SerialTransport):
|
||||
name = "Virtual Connection"
|
||||
key = "virtual"
|
||||
|
||||
settings = {}
|
||||
settings = []
|
||||
|
||||
pluginSettings = None
|
||||
datafolder = None
|
||||
|
||||
@classmethod
|
||||
@@ -18,7 +20,7 @@ class VirtualSerialTransport(SerialTransport):
|
||||
return type(
|
||||
f"{cls.__name__}WithSettingsAndData",
|
||||
(cls,),
|
||||
{"settings": settings, "datafolder": datafolder},
|
||||
{"pluginSettings": settings, "datafolder": datafolder},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -28,7 +30,7 @@ class VirtualSerialTransport(SerialTransport):
|
||||
def create_connection(self, *args, **kwargs):
|
||||
from . import virtual
|
||||
|
||||
self._serial = virtual.VirtualPrinter(self.settings, self.datafolder)
|
||||
self._serial = virtual.VirtualPrinter(self.pluginSettings, self.datafolder)
|
||||
|
||||
|
||||
class VirtualPrinterPlugin(
|
||||
|
||||
@@ -601,12 +601,12 @@ class Server:
|
||||
# register available transports
|
||||
from octoprint.comm.transport import register_transports
|
||||
|
||||
register_transports(self._settings, ["connection", "transports"])
|
||||
register_transports(self._settings)
|
||||
|
||||
# register available protocols
|
||||
from octoprint.comm.protocol import register_protocols
|
||||
|
||||
register_protocols(self._settings, ["connection", "protocols"])
|
||||
register_protocols(self._settings)
|
||||
|
||||
# log environment data now
|
||||
self._environment_detector.log_detected_environment()
|
||||
|
||||
Reference in new issue
Block a user