🐛 Fix merge & migration errors
At least the virtual printer is working again \o/
This commit is contained in:
1 parent
65706d4171
commit
6a9415b39f
12 files changed
+83
-78
No files matched your search
@@ -41,7 +41,7 @@ def run_server(
|
||||
from octoprint.logging.handlers import PluginTimingsLogHandler
|
||||
|
||||
logger = logging.getLogger("octoprint.startup")
|
||||
PluginTimingsLogHandler.arm_rollover()
|
||||
PluginTimingsLogHandler.arm_rollover(logger)
|
||||
|
||||
logger.info(get_divider_line("*"))
|
||||
logger.info("Starting OctoPrint {}".format(__display_version__))
|
||||
|
||||
@@ -4,6 +4,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from abc import ABCMeta
|
||||
|
||||
from future.utils import with_metaclass
|
||||
@@ -14,7 +15,6 @@ from octoprint.comm.protocol import (
|
||||
ProtocolListener,
|
||||
ProtocolState,
|
||||
)
|
||||
from octoprint.util import monotonic_time
|
||||
from octoprint.util.listener import ListenerAware
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class Printjob(with_metaclass(ABCMeta, ProtocolListener, ListenerAware)):
|
||||
|
||||
@property
|
||||
def elapsed(self):
|
||||
return monotonic_time() - self._start if self._start is not None else None
|
||||
return time.monotonic() - self._start if self._start is not None else None
|
||||
|
||||
@property
|
||||
def clean_elapsed(self):
|
||||
@@ -105,7 +105,7 @@ class Printjob(with_metaclass(ABCMeta, ProtocolListener, ListenerAware)):
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
self._last_result = LastResult()
|
||||
self._start = monotonic_time()
|
||||
self._start = time.monotonic()
|
||||
self._user = user
|
||||
self._protocol = protocol
|
||||
self._protocol.register_listener(self)
|
||||
|
||||
@@ -68,7 +68,7 @@ from octoprint.comm.util.parameters import (
|
||||
from octoprint.events import Events
|
||||
from octoprint.util import ResettableTimer, TypeAlreadyInQueue
|
||||
from octoprint.util import dummy_gettext as gettext
|
||||
from octoprint.util import monotonic_time, protectedkeydict, to_bytes, to_unicode
|
||||
from octoprint.util import protectedkeydict, to_bytes, to_unicode
|
||||
|
||||
GCODE_TO_EVENT = {
|
||||
# pause for user input
|
||||
@@ -1355,10 +1355,10 @@ class ReprapGcodeProtocol(
|
||||
|
||||
def join(self, timeout=None):
|
||||
if timeout is not None:
|
||||
stop = monotonic_time() + timeout
|
||||
stop = time.monotonic() + timeout
|
||||
while (
|
||||
self._command_queue.unfinished_tasks or self._send_queue.unfinished_tasks
|
||||
) and monotonic_time() < stop:
|
||||
) and time.monotonic() < stop:
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
self._command_queue.join()
|
||||
@@ -1457,11 +1457,11 @@ class ReprapGcodeProtocol(
|
||||
if not error:
|
||||
try:
|
||||
self.send_script("beforePrinterDisconnected")
|
||||
stop = monotonic_time() + 10.0 # TODO make somehow configurable
|
||||
stop = time.monotonic() + 10.0 # TODO make somehow configurable
|
||||
while (
|
||||
self._command_queue.unfinished_tasks
|
||||
or self._send_queue.unfinished_tasks
|
||||
) and monotonic_time() < stop:
|
||||
) and time.monotonic() < stop:
|
||||
time.sleep(0.1)
|
||||
except UnknownScript:
|
||||
pass
|
||||
@@ -1680,7 +1680,7 @@ class ReprapGcodeProtocol(
|
||||
if len(line):
|
||||
if (
|
||||
self._internal_flags["dwelling_until"]
|
||||
and monotonic_time() > self._internal_flags["dwelling_until"]
|
||||
and time.monotonic() > self._internal_flags["dwelling_until"]
|
||||
):
|
||||
self._internal_flags["dwelling_until"] = False
|
||||
|
||||
@@ -1937,7 +1937,7 @@ class ReprapGcodeProtocol(
|
||||
#
|
||||
# this it to prevent the log from getting flooded for extremely bad communication issues
|
||||
if self._log_resends:
|
||||
now = monotonic_time()
|
||||
now = time.monotonic()
|
||||
new_rate_window = (
|
||||
self._log_resends_rate_start is None
|
||||
or self._log_resends_rate_start + self._log_resends_rate_frame < now
|
||||
@@ -2139,7 +2139,7 @@ class ReprapGcodeProtocol(
|
||||
if heatup_detected:
|
||||
self._logger.debug("Externally triggered heatup detected")
|
||||
self._internal_flags["heating"] = True
|
||||
self._internal_flags["heatup_start"] = monotonic_time()
|
||||
self._internal_flags["heatup_start"] = time.monotonic()
|
||||
|
||||
shared_nozzle = self._printer_profile["extruder"]["sharedNozzle"]
|
||||
current_tool_key = "T{}".format(self._internal_flags["current_tool"])
|
||||
@@ -2348,7 +2348,7 @@ class ReprapGcodeProtocol(
|
||||
if self._internal_flags["heating_start"]:
|
||||
self._internal_flags["heating_lost"] = self._internal_flags[
|
||||
"heating_lost"
|
||||
] + (monotonic_time() - self._internal_flags["heating_start"])
|
||||
] + (time.monotonic() - self._internal_flags["heating_start"])
|
||||
self._internal_flags["heating_start"] = None
|
||||
self._internal_flags["heating"] = False
|
||||
|
||||
@@ -2693,7 +2693,7 @@ class ReprapGcodeProtocol(
|
||||
break
|
||||
|
||||
# sleep if we are dwelling
|
||||
now = monotonic_time()
|
||||
now = time.monotonic()
|
||||
if (
|
||||
self.flavor.block_while_dwelling
|
||||
and self._internal_flags["dwelling_until"]
|
||||
@@ -3186,25 +3186,25 @@ class ReprapGcodeProtocol(
|
||||
)
|
||||
|
||||
def _gcode_M109_sent(self, command):
|
||||
self._internal_flags["heatup_start"] = monotonic_time()
|
||||
self._internal_flags["heatup_start"] = time.monotonic()
|
||||
self._internal_flags["long_running_command"] = True
|
||||
self._internal_flags["heating"] = True
|
||||
self._gcode_M104_sent(command, wait=True, support_r=True)
|
||||
|
||||
def _gcode_M190_sent(self, command):
|
||||
self._internal_flags["heatup_start"] = monotonic_time()
|
||||
self._internal_flags["heatup_start"] = time.monotonic()
|
||||
self._internal_flags["long_running_command"] = True
|
||||
self._internal_flags["heating"] = True
|
||||
self._gcode_M140_sent(command, wait=True, support_r=True)
|
||||
|
||||
def _gcode_M191_sent(self, command):
|
||||
self._internal_flags["heatup_start"] = monotonic_time()
|
||||
self._internal_flags["heatup_start"] = time.monotonic()
|
||||
self._internal_flags["long_running_command"] = True
|
||||
self._internal_flags["heating"] = True
|
||||
self._gcode_M141_sent(command, wait=True, support_r=True)
|
||||
|
||||
def _gcode_M116_sent(self, command):
|
||||
self._internal_flags["heatup_start"] = monotonic_time()
|
||||
self._internal_flags["heatup_start"] = time.monotonic()
|
||||
self._internal_flags["long_running_command"] = True
|
||||
self._internal_flags["heating"] = True
|
||||
|
||||
@@ -3301,7 +3301,7 @@ class ReprapGcodeProtocol(
|
||||
)
|
||||
+ timeout
|
||||
)
|
||||
self._internal_flags["dwelling_until"] = monotonic_time() + timeout
|
||||
self._internal_flags["dwelling_until"] = time.monotonic() + timeout
|
||||
|
||||
##~~ atcommand handlers
|
||||
|
||||
@@ -3400,14 +3400,14 @@ class ReprapGcodeProtocol(
|
||||
|
||||
def _get_timeout(self, timeout_type):
|
||||
if timeout_type in self.timeouts:
|
||||
return monotonic_time() + self.timeouts[timeout_type]
|
||||
return time.monotonic() + self.timeouts[timeout_type]
|
||||
else:
|
||||
return monotonic_time()
|
||||
return time.monotonic()
|
||||
|
||||
def _get_max_timeout(self, *offsets):
|
||||
if len(offsets) == 0:
|
||||
offsets = (0.0,)
|
||||
return monotonic_time() + max(offsets)
|
||||
return time.monotonic() + max(offsets)
|
||||
|
||||
def _to_logfile_with_terminal(self, message=None, level=logging.INFO):
|
||||
log = "Last lines in terminal:\n" + "\n".join(
|
||||
|
||||
@@ -3,6 +3,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
|
||||
from future.utils import with_metaclass
|
||||
|
||||
@@ -12,7 +13,7 @@ from octoprint.comm.protocol.reprap.util import (
|
||||
regex_int_pattern,
|
||||
regex_positive_float_pattern,
|
||||
)
|
||||
from octoprint.util import chunks, monotonic_time
|
||||
from octoprint.util import chunks
|
||||
|
||||
_flavor_registry = {}
|
||||
|
||||
@@ -132,7 +133,7 @@ class GenericFlavor(with_metaclass(FlavorMeta, object)):
|
||||
|
||||
@classmethod
|
||||
def with_overrides(cls, overrides):
|
||||
return type(b"{}WithOverrides".format(cls.__name__), (cls,), overrides)
|
||||
return type("{}WithOverrides".format(cls.__name__), (cls,), overrides)
|
||||
|
||||
@classmethod
|
||||
def overridable(cls):
|
||||
@@ -163,7 +164,7 @@ class GenericFlavor(with_metaclass(FlavorMeta, object)):
|
||||
|
||||
@classmethod
|
||||
def comm_timeout(cls, line, lower_line, state, flags):
|
||||
now = monotonic_time()
|
||||
now = time.monotonic()
|
||||
matches = (
|
||||
(line == "" and now > flags["timeout"])
|
||||
or (
|
||||
|
||||
@@ -3,7 +3,7 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
|
||||
import re
|
||||
|
||||
from octoprint.comm.protocol.reprap.flavors import GenericFlavor
|
||||
from octoprint.comm.protocol.reprap.flavors.generic import GenericFlavor
|
||||
from octoprint.comm.protocol.reprap.util import regex_positive_float_pattern
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ __copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms
|
||||
|
||||
import copy
|
||||
import logging
|
||||
import time
|
||||
|
||||
from octoprint.comm.util.parameters import get_param_dict
|
||||
from octoprint.plugin import plugin_manager
|
||||
from octoprint.settings import SubSettings
|
||||
from octoprint.util import monotonic_time
|
||||
from octoprint.util.listener import ListenerAware
|
||||
|
||||
_registry = {}
|
||||
@@ -244,7 +244,7 @@ class SeparatorAwareTransportWrapper(TransportWrapper):
|
||||
self._buffered = bytearray()
|
||||
|
||||
def read(self, size=None, timeout=None):
|
||||
start = monotonic_time()
|
||||
start = time.monotonic()
|
||||
termlen = len(self.terminator)
|
||||
data = self._buffered
|
||||
|
||||
@@ -266,7 +266,7 @@ class SeparatorAwareTransportWrapper(TransportWrapper):
|
||||
return received
|
||||
|
||||
# check if timeout expired
|
||||
if timeout and monotonic_time() > start + timeout:
|
||||
if timeout and time.monotonic() > start + timeout:
|
||||
break
|
||||
|
||||
# if we arrive here we so far couldn't read a full line, wait for more data
|
||||
|
||||
@@ -15,7 +15,7 @@ from octoprint.util import get_fully_qualified_classname as fqcn
|
||||
|
||||
from .analysis import AnalysisQueue, QueueEntry # noqa: F401
|
||||
from .destinations import FileDestinations # noqa: F401
|
||||
from .storage import LocalFileStorage # noqa: F401
|
||||
from .storage.local import LocalFileStorage # noqa: F401
|
||||
from .util import AbstractFileWrapper, DiskFileWrapper, StreamWrapper # noqa: F401
|
||||
|
||||
ContentTypeMapping = namedtuple("ContentTypeMapping", "extensions, content_type")
|
||||
|
||||
@@ -10,6 +10,17 @@ class VirtualSerialTransport(SerialTransport):
|
||||
name = "Virtual Connection"
|
||||
key = "virtual"
|
||||
|
||||
settings = {}
|
||||
datafolder = None
|
||||
|
||||
@classmethod
|
||||
def with_settings_and_data(cls, settings, datafolder):
|
||||
return type(
|
||||
"{}WithSettingsAndData".format(cls.__name__),
|
||||
(cls,),
|
||||
{"settings": settings, "datafolder": datafolder},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_connection_options(cls):
|
||||
return []
|
||||
@@ -17,7 +28,7 @@ class VirtualSerialTransport(SerialTransport):
|
||||
def create_connection(self, *args, **kwargs):
|
||||
from . import virtual
|
||||
|
||||
self._serial = virtual.VirtualPrinter()
|
||||
self._serial = virtual.VirtualPrinter(self.settings, self.datafolder)
|
||||
|
||||
|
||||
class VirtualPrinterPlugin(
|
||||
@@ -102,7 +113,11 @@ class VirtualPrinterPlugin(
|
||||
self._settings.global_remove(["devel", "virtualPrinter"])
|
||||
|
||||
def register_transport_hook(self, *args, **kwargs):
|
||||
return [VirtualSerialTransport]
|
||||
return [
|
||||
VirtualSerialTransport.with_settings_and_data(
|
||||
self._settings, self.get_plugin_data_folder()
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
__plugin_name__ = "Virtual Printer"
|
||||
|
||||
@@ -17,13 +17,7 @@ from typing import Any
|
||||
from serial import SerialTimeoutException
|
||||
|
||||
from octoprint.plugin import plugin_manager
|
||||
from octoprint.util import (
|
||||
RepeatedTimer,
|
||||
get_dos_filename,
|
||||
monotonic_time,
|
||||
to_bytes,
|
||||
to_unicode,
|
||||
)
|
||||
from octoprint.util import RepeatedTimer, get_dos_filename, to_bytes, to_unicode
|
||||
|
||||
|
||||
# noinspection PyBroadException
|
||||
@@ -141,7 +135,7 @@ class VirtualPrinter:
|
||||
|
||||
self._virtual_eeprom = (
|
||||
VirtualEEPROM(self._plugin_data_folder)
|
||||
if self._settings.get_boolean(["enable_eeprom"])
|
||||
if self._settings.get_boolean(["enable_eeprom"]) and self._plugin_data_folder
|
||||
else None
|
||||
)
|
||||
self._support_M503 = self._settings.get_boolean(["support_M503"])
|
||||
@@ -2086,7 +2080,7 @@ class Outgoing(object):
|
||||
|
||||
def read(self, size=1, timeout=0):
|
||||
# type: (int, int) -> bytes
|
||||
start = monotonic_time()
|
||||
start = time.monotonic()
|
||||
|
||||
result = bytearray()
|
||||
while len(result) < size:
|
||||
@@ -2097,8 +2091,8 @@ class Outgoing(object):
|
||||
if not len(self._outgoing):
|
||||
self._event.clear()
|
||||
return bytes(result)
|
||||
self._event.wait(start + timeout - monotonic_time())
|
||||
if start + timeout < monotonic_time():
|
||||
self._event.wait(start + timeout - time.monotonic())
|
||||
if start + timeout < time.monotonic():
|
||||
break
|
||||
|
||||
return b""
|
||||
|
||||
@@ -20,7 +20,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
import re
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
from octoprint.comm.scripts import UnknownScript # noqa: F401,F403
|
||||
from octoprint.filemanager import FileDestinations
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import deprecated, natural_key
|
||||
|
||||
@@ -406,8 +406,8 @@ class Printer(
|
||||
|
||||
from octoprint.logging.handlers import CommunicationLogHandler
|
||||
|
||||
CommunicationLogHandler.on_open_connection(u"CONNECTION")
|
||||
CommunicationLogHandler.on_open_connection(u"COMMDEBUG")
|
||||
CommunicationLogHandler.arm_rollover(u"CONNECTION")
|
||||
CommunicationLogHandler.arm_rollover(u"COMMDEBUG")
|
||||
|
||||
if not logging.getLogger("CONNECTION").isEnabledFor(logging.DEBUG):
|
||||
# is protocol.log is not enabled, log a line to explain to reduce "connection.log is empty" in tickets...
|
||||
@@ -995,10 +995,10 @@ class Printer(
|
||||
return "CLOSED_WITH_ERROR"
|
||||
|
||||
def get_error(self):
|
||||
if self._comm is None:
|
||||
if self._protocol is None:
|
||||
return ""
|
||||
else:
|
||||
return self._comm.getErrorString()
|
||||
return self._protocol.error
|
||||
|
||||
def get_current_data(self, *args, **kwargs):
|
||||
return util.thaw_frozendict(self._state_monitor.get_current_data())
|
||||
@@ -1423,13 +1423,15 @@ class Printer(
|
||||
)
|
||||
|
||||
def _update_resend_data_callback(self):
|
||||
if not self._comm:
|
||||
return self._dict(count=0, transmitted=0, ratio=0)
|
||||
return self._dict(
|
||||
count=self._comm.received_resends,
|
||||
transmitted=self._comm.transmitted_lines,
|
||||
ratio=int(self._comm.resend_ratio * 100),
|
||||
)
|
||||
# if not self._comm:
|
||||
# return self._dict(count=0, transmitted=0, ratio=0)
|
||||
# return self._dict(
|
||||
# count=self._comm.received_resends,
|
||||
# transmitted=self._comm.transmitted_lines,
|
||||
# ratio=int(self._comm.resend_ratio * 100),
|
||||
# )
|
||||
# TODO implement me
|
||||
return self._dict(count=0, transmitted=0, ratio=0)
|
||||
|
||||
def _add_temperature_data(self, temperatures=None):
|
||||
if temperatures is None:
|
||||
|
||||
@@ -408,12 +408,6 @@ class Server:
|
||||
)
|
||||
|
||||
storage_managers = self._collect_initial_storage_managers()
|
||||
storage_managers[
|
||||
octoprint.filemanager.FileDestinations.LOCAL
|
||||
] = octoprint.filemanager.storage.LocalFileStorage(
|
||||
self._settings.getBaseFolder("uploads")
|
||||
)
|
||||
|
||||
fileManager = octoprint.filemanager.FileManager(
|
||||
analysisQueue,
|
||||
slicingManager,
|
||||
@@ -560,16 +554,6 @@ class Server:
|
||||
userManager = octoprint.access.users.FilebasedUserManager(groupManager)
|
||||
components.update({"user_manager": userManager})
|
||||
|
||||
# register available transports
|
||||
from octoprint.comm.transport import register_transports
|
||||
|
||||
register_transports()
|
||||
|
||||
# register available protocols
|
||||
from octoprint.comm.protocol import register_protocols
|
||||
|
||||
register_protocols()
|
||||
|
||||
# create printer instance
|
||||
printer_factories = pluginManager.get_hooks("octoprint.printer.factory")
|
||||
for name, factory in printer_factories.items():
|
||||
@@ -616,6 +600,16 @@ class Server:
|
||||
|
||||
pluginManager.log_all_plugins()
|
||||
|
||||
# register available transports
|
||||
from octoprint.comm.transport import register_transports
|
||||
|
||||
register_transports()
|
||||
|
||||
# register available protocols
|
||||
from octoprint.comm.protocol import register_protocols
|
||||
|
||||
register_protocols()
|
||||
|
||||
# log environment data now
|
||||
self._environment_detector.log_detected_environment()
|
||||
|
||||
@@ -1328,13 +1322,12 @@ class Server:
|
||||
from octoprint.filemanager.storage.local import LocalFileStorage
|
||||
from octoprint.filemanager.storage.sdcard import PrinterSDStorage
|
||||
|
||||
storage_managers = {}
|
||||
storage_managers[octoprint.filemanager.FileDestinations.LOCAL] = LocalFileStorage(
|
||||
self._settings.getBaseFolder("uploads")
|
||||
)
|
||||
storage_managers[
|
||||
octoprint.filemanager.FileDestinations.SDCARD
|
||||
] = PrinterSDStorage()
|
||||
storage_managers = {
|
||||
octoprint.filemanager.FileDestinations.LOCAL: LocalFileStorage(
|
||||
self._settings.getBaseFolder("uploads")
|
||||
),
|
||||
octoprint.filemanager.FileDestinations.SDCARD: PrinterSDStorage(),
|
||||
}
|
||||
return storage_managers
|
||||
|
||||
def _setup_heartbeat_logging(self):
|
||||
|
||||
Reference in new issue
Block a user