diff --git a/.versioneer-lookup b/.versioneer-lookup index df5d07fab..f36ca988a 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -24,10 +24,10 @@ maintenance 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev fix/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev improve/.* 1.3.12 73df8c2407f04756261acfe62ac3d72877f8a97d pep440-dev -# staging/maintenance is currently the branch for preparation of 1.3.11rc3 +# staging/maintenance is currently the branch for preparation of 1.3.11rc4 # so is regressionfix/... -staging/maintenance 1.3.11rc3 18e7d2b72ad73c5d8e522cebbc001d0e8a3dff14 pep440-dev -regressionfix/.* 1.3.11rc3 18e7d2b72ad73c5d8e522cebbc001d0e8a3dff14 pep440-dev +staging/maintenance 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev +regressionfix/.* 1.3.11rc4 af3285854995fb5b910fd2ce869e26c02d57bbc2 pep440-dev # every other branch is a development branch and thus gets resolved to 1.4.0-dev for now .* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev diff --git a/CHANGELOG.md b/CHANGELOG.md index 518dd432c..957624ad4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # OctoPrint Changelog +## 1.3.11rc3 (2019-04-11) + +### Improvements + + * Define empty `UI_API_KEY` for backwards compatibility with third party plugins + * Add config flag `server.ignoredIncompleteStartup` to override incomplete startup detection + * Hardening against errors triggered during print time estimation + * Introduce setting to disable exclusive claim on serial port. There might be issues with this out there in the field, so having the option to disable it is a good thing. + * Error Tracking: Further restriction of what gets tracked + +### Bug fixes + + * [#3105](https://github.com/foosel/OctoPrint/issues/3105) (regression) - Virtual printer: Fix an encoding issue + * [#3108](https://github.com/foosel/OctoPrint/issues/3108) (regression) - Fix bug in port detection + * [#3111](https://github.com/foosel/OctoPrint/issues/3111) (regression) - Refresh port list after disconnect to detect vanishing ports + * [#3115](https://github.com/foosel/OctoPrint/issues/3115) (regression) - Fix extra newlines in `serial.log` and empty lines on terminal + * [#3116](https://github.com/foosel/OctoPrint/issues/3116) - Fix potential division by zero + * Fix wrong textual representation of `STARTING` state + * Fix some potential encoding errors in the comm layer + * Fix for the file list in the UI not getting refreshed after an SD list refresh from the printer. + +### Unreproduced issues + +The following issues were reported in RC1 or RC2 but so far have been unreproduced and further data to analyse them is still missing. If you encounter any of them please report back with a [fully filled out issue template](https://github.com/foosel/OctoPrint/blob/master/CONTRIBUTING.md#what-should-i-include-in-a-bug-report): + + * ["Print completes but temp data appears to be 'stuck' at last known value for bed and hotend."](https://github.com/foosel/OctoPrint/issues/3087#issuecomment-478369220) + +### Special thanks to all the contributors! + +Special thanks to everyone who contributed to this release candidate and provided full, analysable bug reports. + +### More information + + * [Commits](https://github.com/foosel/OctoPrint/compare/1.3.11rc2...1.3.11rc3) + ## 1.3.11rc2 (2019-04-04) ### Improvements diff --git a/SUPPORTERS.md b/SUPPORTERS.md index 6baff4b41..f752e4740 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -54,4 +54,4 @@ thanks to everyone who contributed! * Trent Shumay * Ulrich Kempken -and 1509 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)! \ No newline at end of file +and 1521 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)! \ No newline at end of file diff --git a/docs/configuration/config_yaml.rst b/docs/configuration/config_yaml.rst index 7ab22da07..83ea5495d 100644 --- a/docs/configuration/config_yaml.rst +++ b/docs/configuration/config_yaml.rst @@ -952,6 +952,13 @@ Use the following settings to configure the server: # reset the setting to false startOnceInSafeMode: false + # Signals to OctoPrint that the last startup was incomplete. OctoPrint will then startup + # in safe mode + incompleteStartup: false + + # Set this to true to make OctoPrint ignore incomplete startups. Helpful for development. + ignoreIncompleteStartup: false + # Secret key for encrypting cookies and such, randomly generated on first run secretKey: someSecretKey diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index 0776420b8..fc8c8f1d2 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -104,7 +104,10 @@ def init_platform(basedir, configfile, use_logging_file=True, logging_file=None, after_logging(**kwargs) settings_start_once_in_safemode = "settings" if settings.getBoolean(["server", "startOnceInSafeMode"]) else None - settings_incomplete_startup_safemode = "incomplete_startup" if settings.getBoolean(["server", "incompleteStartup"]) else None + settings_incomplete_startup_safemode = "incomplete_startup" \ + if settings.getBoolean(["server", "incompleteStartup"]) \ + and not settings.getBoolean(["server", "ignoreIncompleteStartup"]) \ + else None safe_mode = safe_mode or settings_start_once_in_safemode or settings_incomplete_startup_safemode kwargs["safe_mode"] = safe_mode if callable(after_safe_mode): diff --git a/src/octoprint/cli/plugins.py b/src/octoprint/cli/plugins.py index facfc80cb..c1a7938f9 100644 --- a/src/octoprint/cli/plugins.py +++ b/src/octoprint/cli/plugins.py @@ -92,7 +92,8 @@ class OctoPrintPluginCommands(click.MultiCommand): continue result[name + self.sep + command.name] = command except: - self._logger.exception("Error while retrieving cli commands for plugin {}".format(name)) + self._logger.exception("Error while retrieving cli commands for plugin {}".format(name), + extra=dict(plugin=name)) return result diff --git a/src/octoprint/environment.py b/src/octoprint/environment.py index 6b22a22ac..86e673121 100644 --- a/src/octoprint/environment.py +++ b/src/octoprint/environment.py @@ -125,7 +125,8 @@ class EnvironmentDetector(object): result[implementation._identifier] = additional except: self._logger.exception("Error while fetching additional " - "environment data from plugin {}".format(implementation._identifier)) + "environment data from plugin {}".format(implementation._identifier), + extra=dict(plugin=implementation._identifier)) return result diff --git a/src/octoprint/events.py b/src/octoprint/events.py index a5fe562ba..74374f7ec 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -186,8 +186,7 @@ class EventManager(object): octoprint.plugin.call_plugin(octoprint.plugin.types.EventHandlerPlugin, "on_event", - args=(event, payload), - initialized=True) + args=(event, payload)) self._logger.info("Event loop shut down") except: self._logger.exception("Ooops, the event bus worker loop crashed") diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index 24e8b1f90..2c7ff6161 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -78,7 +78,9 @@ def full_extension_tree(): continue result = octoprint.util.dict_merge(result, plugin_result, leaf_merger=leaf_merger) except: - logging.getLogger(__name__).exception("Exception while retrieving additional extension tree entries from SlicerPlugin {name}".format(name=plugin.key)) + logging.getLogger(__name__).exception("Exception while retrieving additional extension " + "tree entries from SlicerPlugin {name}".format(name=plugin._identifier), + extra=dict(plugin=plugin._identifier)) extension_tree_hooks = octoprint.plugin.plugin_manager().get_hooks("octoprint.filemanager.extension_tree") for name, hook in extension_tree_hooks.items(): @@ -88,7 +90,9 @@ def full_extension_tree(): continue result = octoprint.util.dict_merge(result, hook_result, leaf_merger=leaf_merger) except: - logging.getLogger(__name__).exception("Exception while retrieving additional extension tree entries from hook {name}".format(name=name)) + logging.getLogger(__name__).exception("Exception while retrieving additional extension " + "tree entries from hook {name}".format(name=name), + extra=dict(plugin=name)) return result @@ -429,7 +433,8 @@ class FileManager(object): try: plugin.on_slicing_progress(slicer, source_location, source_path, dest_location, dest_path, progress) except: - self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier) + self._logger.exception("Exception while sending slicing progress to plugin %s" % plugin._identifier, + extra=dict(plugin=plugin._identifier)) import threading thread = threading.Thread(target=call_plugins, args=(slicer, source_location, source_path, dest_location, dest_path, progress_int)) @@ -464,11 +469,11 @@ class FileManager(object): if printer_profile is None: printer_profile = self._printer_profile_manager.get_current_or_default() - for hook in self._preprocessor_hooks.values(): + for name, hook in self._preprocessor_hooks.items(): try: hook_file_object = hook(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite) except: - self._logger.exception("Error when calling preprocessor hook {}, ignoring".format(hook)) + self._logger.exception("Error when calling preprocessor hook for plugin {}, ignoring".format(name), extra=dict(plugin=name)) continue if hook_file_object is not None: diff --git a/src/octoprint/plugin/__init__.py b/src/octoprint/plugin/__init__.py index fceee2de2..500e1090a 100644 --- a/src/octoprint/plugin/__init__.py +++ b/src/octoprint/plugin/__init__.py @@ -196,8 +196,7 @@ def call_plugin(types, method, args=None, kwargs=None, callback=None, error_call error_callback (function): A callback to invoke after the call of an implementation resulted in an exception. Will be called with the three arguments ``name``, ``plugin`` and ``exc``. ``name`` will be the plugin identifier, ``plugin`` the plugin implementation instance itself and ``exc`` the caught exception. - initialized (boolean): Whether the plugin needs to be initialized (True) or not (False). Initialization status - is determined be presence of injected ``_identifier`` property. + initialized (boolean): Ignored. """ if not isinstance(types, (list, tuple)): @@ -211,7 +210,7 @@ def call_plugin(types, method, args=None, kwargs=None, callback=None, error_call plugins = plugin_manager().get_implementations(*types, sorting_context=sorting_context) for plugin in plugins: - if initialized and not hasattr(plugin, "_identifier"): + if not hasattr(plugin, "_identifier"): continue if hasattr(plugin, method): @@ -221,7 +220,7 @@ def call_plugin(types, method, args=None, kwargs=None, callback=None, error_call if callback: callback(plugin._identifier, plugin, result) except Exception as exc: - logger.exception("Error while calling plugin %s" % plugin._identifier) + logger.exception("Error while calling plugin %s" % plugin._identifier, extra=dict(plugin=plugin._identifier)) if error_callback: error_callback(plugin._identifier, plugin, exc) diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index bde73d442..15e9641c4 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -12,10 +12,8 @@ from octoprint.util.version import get_octoprint_version_string, is_released_oct from flask import jsonify from flask_babel import gettext -from serial import SerialException - -SENTRY_URL_SERVER = "https://4273b441bb654c4398de42ba86350963@sentry.io/1373987" -SENTRY_URL_COREUI = "https://f9bcd7185f73430bbe7c09ff69586b0f@sentry.io/1374096" +SENTRY_URL_SERVER = "https://d70b163409984dd6a716788092c3b3fd@sentry.io/1373987" +SENTRY_URL_COREUI = "https://190fb33f582a46768e24ec8a6db7522f@sentry.io/1374096" SETTINGS_DEFAULTS = dict(enabled=False, enabled_unreleased=False, @@ -23,10 +21,40 @@ SETTINGS_DEFAULTS = dict(enabled=False, url_server=SENTRY_URL_SERVER, url_coreui=SENTRY_URL_COREUI) +import serial +import requests.exceptions +import errno +import octoprint.util.avr_isp.ispBase +import tornado.websocket + IGNORED_EXCEPTIONS = [ - (SerialException, "octoprint.util.comm"), + # serial exceptions in octoprint.util.comm + (serial.SerialException, lambda exc, logger, plugin: logger == "octoprint.util.comm"), + + # isp errors during port auto detection in octoprint.util.comm + (octoprint.util.avr_isp.ispBase.IspError, lambda exc, logger, plugin: logger == "octoprint.util.comm"), + + # IOErrors of any kind due to a full file system + (IOError, lambda exc, logger, plugin: getattr(exc, "errno") and exc.errno in (getattr(errno, "ENOSPC"),)), + + # RequestExceptions of any kind + requests.exceptions.RequestException, + + # Tornado WebSocketErrors of any kind + tornado.websocket.WebSocketError ] +try: + # noinspection PyUnresolvedReferences + from octoprint.plugins.backup import InsufficientSpace + + # if the backup plugin is enabled, ignore InsufficientSpace errors from it as well + IGNORED_EXCEPTIONS.append(InsufficientSpace) + + del InsufficientSpace +except ImportError: + pass + class ErrorTrackingPlugin(octoprint.plugin.SettingsPlugin, octoprint.plugin.AssetPlugin, @@ -109,13 +137,19 @@ def _enable_errortracking(): handled = True logger = event.get("logger", "") + plugin = event.get("extra", dict()).get("plugin", None) for ignore in IGNORED_EXCEPTIONS: if isinstance(ignore, tuple): - ignored_exc, ignored_logger = ignore - if isinstance(hint["exc_info"][1], ignored_exc) and logger.startswith(ignored_logger): - # exception ignored for logger - return None + ignored_exc, matcher = ignore + else: + ignored_exc = ignore + matcher = lambda *args: True + + exc = hint["exc_info"][1] + if isinstance(exc, ignored_exc) and matcher(exc, logger, plugin): + # exception ignored for logger + return None elif isinstance(ignore, type): if isinstance(hint["exc_info"][1], ignore): @@ -139,6 +173,12 @@ def _enable_errortracking(): # we only want our active bundled plugins return None + if plugin is not None: + plugin_info = plugin_manager().get_plugin_info(plugin) + if plugin_info is None or not plugin_info.bundled: + # we only want our active bundled plugins + return None + return event sentry_sdk.init(url_server, diff --git a/src/octoprint/plugins/forcelogin/__init__.py b/src/octoprint/plugins/forcelogin/__init__.py index a9f510cca..03b0083ac 100644 --- a/src/octoprint/plugins/forcelogin/__init__.py +++ b/src/octoprint/plugins/forcelogin/__init__.py @@ -87,7 +87,8 @@ class ForceLoginPlugin(octoprint.plugin.UiPlugin, if isinstance(assets, (tuple, list)): additional_assets += assets except: - self._logger.exception("Error fetching theming CSS to include from plugin {}".format(name)) + self._logger.exception("Error fetching theming CSS to include from plugin {}".format(name), + extra=dict(plugin=name)) render_kwargs.update(dict(forcelogin_theming=additional_assets)) return make_response(render_template("forcelogin_index.jinja2", **render_kwargs)) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 8bdedc49a..5caa980b6 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -902,7 +902,8 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin, reconnect_hooks.extend(filter(lambda x: isinstance(x, basestring), result)) except: self._logger.exception("Error while retrieving additional hooks for which a " - "reconnect is required from plugin {name}".format(**locals())) + "reconnect is required from plugin {name}".format(**locals()), + extra=dict(plugin=name)) return reconnect_hooks diff --git a/src/octoprint/plugins/printer_safety_check/__init__.py b/src/octoprint/plugins/printer_safety_check/__init__.py index 2fb9d50e6..f496dbbe0 100644 --- a/src/octoprint/plugins/printer_safety_check/__init__.py +++ b/src/octoprint/plugins/printer_safety_check/__init__.py @@ -8,6 +8,7 @@ import octoprint.plugin from octoprint.events import Events from octoprint.server import user_permission +from octoprint.util import to_unicode from .checks.firmware_unsafe import FirmwareUnsafeChecks @@ -77,19 +78,24 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin, def on_gcode_received(self, comm_instance, line, *args, **kwargs): if self._scan_received: - self._run_checks("received", line) + self._run_checks("received", to_unicode(line, errors="replace")) return line ##~~ Firmware info hook handler def on_firmware_info_received(self, comm_instance, firmware_name, firmware_data): - self._run_checks("m115", firmware_name, firmware_data) + self._run_checks("m115", + to_unicode(firmware_name, errors="replace"), + dict((to_unicode(key, errors="replace"), to_unicode(value, errors="replace")) + for key, value in firmware_data.items())) self._scan_received = False ##~~ Firmware capability hook handler def on_firmware_cap_received(self, comm_instance, cap, enabled, all_caps): - self._run_checks("cap", cap, enabled) + self._run_checks("cap", + to_unicode(cap, errors="replace"), + enabled) ##~~ Helpers diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index e29ea3137..a28047001 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -119,7 +119,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin, try: hook_checks = hook() except: - self._logger.exception("Error while retrieving update information from plugin {name}".format(**locals())) + self._logger.exception("Error while retrieving update information " + "from plugin {name}".format(**locals()), + extra=dict(plugin=name)) else: for key, default_config in hook_checks.items(): if key in effective_configs or key == "octoprint": diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index be4af5a25..0b97bb147 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -18,7 +18,7 @@ from serial import SerialTimeoutException from octoprint.settings import settings from octoprint.plugin import plugin_manager -from octoprint.util import RepeatedTimer, monotonic_time, to_bytes +from octoprint.util import RepeatedTimer, monotonic_time, to_bytes, to_unicode class VirtualPrinter(object): command_regex = re.compile("^([GMTF])(\d+)") @@ -304,7 +304,7 @@ class VirtualPrinter(object): self._dont_answer = False continue - data = data.strip() + data = to_unicode(data.strip(), errors="replace") # strip checksum if "*" in data: @@ -1371,6 +1371,9 @@ class VirtualPrinter(object): pass def write(self, data): + data = to_bytes(data, errors="replace") + u_data = to_unicode(data, errors="replace") + if self._debug_awol: return len(data) @@ -1383,13 +1386,13 @@ class VirtualPrinter(object): return 0 if "M112" in data and self._supportM112: - self._seriallog.info(u"<<< {}".format(data.strip())) + self._seriallog.info(u"<<< {}".format(u_data)) self._kill() return len(data) try: written = self.incoming.put(data, timeout=self._write_timeout, partial=True) - self._seriallog.info(u"<<< {}".format(data.strip())) + self._seriallog.info(u"<<< {}".format(u_data)) return written except queue.Full: self._logger.info("Incoming queue is full, raising SerialTimeoutException") @@ -1424,7 +1427,7 @@ class VirtualPrinter(object): try: # fetch a line from the queue, wait no longer than timeout - line = self.outgoing.get(timeout=timeout) + line = to_unicode(self.outgoing.get(timeout=timeout), errors="replace") self._seriallog.info(u">>> {}".format(line.strip())) self.outgoing.task_done() return to_bytes(line, errors="replace") diff --git a/src/octoprint/printer/estimation.py b/src/octoprint/printer/estimation.py index 91bff26c6..537760a8f 100644 --- a/src/octoprint/printer/estimation.py +++ b/src/octoprint/printer/estimation.py @@ -37,6 +37,8 @@ class PrintTimeEstimator(object): if interval <= 0: interval = 1.0 rolling_window = 15 / interval + if rolling_window < 1: + rolling_window = 1 # we are happy when one rolling window has been stable countdown = rolling_window @@ -226,14 +228,14 @@ class TimeEstimationHelper(object): @property def average_total_rolling(self): - if not self._count or self._count < self._rolling_window: + if not self._count or self._count < self._rolling_window or not len(self._totals): return None else: return sum(self._totals) / len(self._totals) @property def average_distance(self): - if not self._count or self._count < self._rolling_window + 1: + if not self._count or self._count < self._rolling_window + 1 or not len(self._distances): return None else: return sum(self._distances) / len(self._distances) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 7d2ebcdf8..0854d399d 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -95,7 +95,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._logger.info("Using print time estimator provided by {}".format(name)) self._estimator_factory = estimator except: - self._logger.exception("Error while processing analysis queues from {}".format(name)) + self._logger.exception("Error while processing analysis queues from {}".format(name), + extra=dict(plugin=name)) #hook card upload self.sd_card_upload_hooks = plugin_manager().get_hooks("octoprint.printer.sdcardupload") @@ -229,7 +230,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): try: plugin.on_print_progress(storage, filename, progress) except: - self._logger.exception("Exception while sending print progress to plugin %s" % plugin._identifier) + self._logger.exception("Exception while sending print progress to plugin %s" % plugin._identifier, + extra=dict(plugin=plugin._identifier)) thread = threading.Thread(target=call_plugins, args=(storage, filename, progress)) thread.daemon = False @@ -721,7 +723,9 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if result is not None: return result except: - self._logger.exception("There was an error running the sd upload hook provided by plugin {}".format(name)) + self._logger.exception("There was an error running the sd upload " + "hook provided by plugin {}".format(name), + extra=dict(plugin=name)) else: # no plugin feels responsible, use the default implementation @@ -855,11 +859,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): statisticalTotalPrintTime = self._selectedFile["estimatedPrintTime"] statisticalTotalPrintTimeType = self._selectedFile.get("estimatedPrintTimeType", None) - printTimeLeft, printTimeLeftOrigin = estimator.estimate(progress, - printTime, - cleanedPrintTime, - statisticalTotalPrintTime, - statisticalTotalPrintTimeType) + try: + printTimeLeft, printTimeLeftOrigin = estimator.estimate(progress, + printTime, + cleanedPrintTime, + statisticalTotalPrintTime, + statisticalTotalPrintTimeType) + except Exception: + self._logger.exception("Error while estimating print time via {}".format(estimator)) return self._dict(completion=progress * 100 if progress is not None else None, filepos=filepos, @@ -1123,7 +1130,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): self._stateMonitor.set_state(self._dict(text=self.get_state_string(), flags=self._getStateFlags())) def on_comm_sd_files(self, files): - eventManager().fire(Events.UPDATED_FILES, {"type": "gcode"}) + eventManager().fire(Events.UPDATED_FILES, {"type": "printables"}) self._sdFilelistAvailable.set() def on_comm_file_selected(self, full_path, size, sd, user=None): diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 6b90ca4af..103873b1c 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -191,8 +191,9 @@ class Server(object): if self._settings is None: self._settings = settings() - self._settings.setBoolean(["server", "incompleteStartup"], True) - self._settings.save() + if not self._settings.getBoolean(["server", "ignoreIncompleteStartup"]): + self._settings.setBoolean(["server", "incompleteStartup"], True) + self._settings.save() if self._plugin_manager is None: self._plugin_manager = octoprint.plugin.plugin_manager() @@ -288,7 +289,8 @@ class Server(object): additional_factories = hook() analysis_queue_factories.update(**additional_factories) except: - self._logger.exception("Error while processing analysis queues from {}".format(name)) + self._logger.exception("Error while processing analysis queues from {}".format(name), + extra=dict(plugin=name)) analysisQueue = octoprint.filemanager.analysis.AnalysisQueue(analysis_queue_factories) slicingManager = octoprint.slicing.SlicingManager(self._settings.getBaseFolder("slicingProfiles"), printerProfileManager) @@ -345,7 +347,8 @@ class Server(object): self._logger.debug("Created user manager instance from factory {}".format(name)) break except: - self._logger.exception("Error while creating user manager instance from factory {}".format(name)) + self._logger.exception("Error while creating user manager instance from factory {}".format(name), + extra=dict(plugin=name)) else: name = self._settings.get(["accessControl", "userManager"]) try: @@ -368,7 +371,8 @@ class Server(object): self._logger.debug("Created printer instance from factory {}".format(name)) break except: - self._logger.exception("Error while creating printer instance from factory {}".format(name)) + self._logger.exception("Error while creating printer instance from factory {}".format(name), + extra=dict(plugin=name)) else: printer = Printer(fileManager, analysisQueue, printerProfileManager) components.update(dict(printer=printer)) @@ -457,7 +461,8 @@ class Server(object): constant, value = octoprint.events.Events.register_event(event, prefix="plugin_{}_".format(name)) self._logger.debug("Registered event {} of plugin {} as Events.{} = \"{}\"".format(event, name, constant, value)) except: - self._logger.exception("Error while retrieving custom event list from plugin {}".format(name)) + self._logger.exception("Error while retrieving custom event list from plugin {}".format(name), + extra=dict(plugin=name)) pluginManager.implementation_inject_factories=[octoprint_plugin_inject_factory, settings_plugin_inject_factory] @@ -468,7 +473,9 @@ class Server(object): try: settings_plugin_config_migration_and_cleanup(implementation._identifier, implementation) except: - self._logger.exception("Error while trying to migrate settings for plugin {}, ignoring it".format(implementation._identifier)) + self._logger.exception("Error while trying to migrate settings for " + "plugin {}, ignoring it".format(implementation._identifier), + extra=dict(plugin=plugin._identifier)) pluginManager.implementation_post_inits=[settings_plugin_config_migration_and_cleanup] @@ -540,7 +547,8 @@ class Server(object): try: access_validators_from_plugins.append(util.tornado.access_validation_factory(app, hook)) except: - self._logger.exception("Error while adding tornado access validator from plugin {}".format(plugin)) + self._logger.exception("Error while adding tornado access validator from plugin {}".format(plugin), + extra=dict(plugin=plugin)) admin_validators = [util.tornado.access_validation_factory(app, util.flask.admin_validator),] + access_validators_from_plugins user_validators = [util.tornado.access_validation_factory(app, util.flask.user_validator),] + access_validators_from_plugins @@ -606,7 +614,9 @@ class Server(object): try: result = hook(list(server_routes)) except: - self._logger.exception("There was an error while retrieving additional server routes from plugin hook {name}".format(**locals())) + self._logger.exception("There was an error while retrieving additional " + "server routes from plugin hook {name}".format(**locals()), + extra=dict(plugin=name)) else: if isinstance(result, (list, tuple)): for entry in result: @@ -649,7 +659,9 @@ class Server(object): try: result = hook(list(max_body_sizes)) except: - self._logger.exception("There was an error while retrieving additional upload sizes from plugin hook {name}".format(**locals())) + self._logger.exception("There was an error while retrieving additional " + "upload sizes from plugin hook {name}".format(**locals()), + extra=dict(plugin=name)) else: if isinstance(result, (list, tuple)): for entry in result: @@ -1179,7 +1191,9 @@ class Server(object): blueprint, prefix = self._prepare_blueprint_plugin(plugin) blueprints[prefix] = blueprint except: - self._logger.exception("Error while registering blueprint of plugin {}, ignoring it".format(plugin._identifier)) + self._logger.exception("Error while registering blueprint of " + "plugin {}, ignoring it".format(plugin._identifier), + extra=dict(plugin=plugin._identifier)) continue return blueprints @@ -1195,7 +1209,9 @@ class Server(object): blueprint, prefix = self._prepare_asset_plugin(plugin) blueprints[prefix] = blueprint except: - self._logger.exception("Error while registering assets of plugin {}, ignoring it".format(plugin._identifier)) + self._logger.exception("Error while registering assets of plugin " + "{}, ignoring it".format(plugin._identifier), + extra=dict(plugin=plugin._identifier)) continue return blueprints @@ -1243,7 +1259,8 @@ class Server(object): for h in result: blueprint.before_request(h) except: - self._logger.exception("Error processing before_request hooks from plugin {}".format(name)) + self._logger.exception("Error processing before_request hooks from plugin {}".format(name), + extra=dict(plugin=name)) for name, hook in after_hooks.items(): try: @@ -1252,7 +1269,8 @@ class Server(object): for h in result: blueprint.after_request(h) except: - self._logger.exception("Error processing after_request hooks from plugin {}".format(name)) + self._logger.exception("Error processing after_request hooks from plugin {}".format(name), + extra=dict(plugin=name)) def _setup_assets(self): global app diff --git a/src/octoprint/server/api/__init__.py b/src/octoprint/server/api/__init__.py index e67529d8b..dbcdaa6ef 100644 --- a/src/octoprint/server/api/__init__.py +++ b/src/octoprint/server/api/__init__.py @@ -60,15 +60,20 @@ def pluginData(name): if len(api_plugins) > 1: return make_response("More than one api provider registered for {name}, can't proceed".format(name=name), 500) - api_plugin = api_plugins[0] - if api_plugin.is_api_adminonly() and not current_user.is_admin(): - return make_response("Forbidden", 403) + try: + api_plugin = api_plugins[0] + if api_plugin.is_api_adminonly() and not current_user.is_admin(): + return make_response("Forbidden", 403) - response = api_plugin.on_api_get(request) + response = api_plugin.on_api_get(request) - if response is not None: - return response - return NO_CONTENT + if response is not None: + return response + return NO_CONTENT + except Exception: + logging.getLogger(__name__).exception("Error calling SimpleApiPlugin {}".format(name), + extra=dict(plugin=name)) + return abort(500) #~~ commands for plugins @@ -84,21 +89,26 @@ def pluginCommand(name): return make_response("More than one api provider registered for {name}, can't proceed".format(name=name), 500) api_plugin = api_plugins[0] - valid_commands = api_plugin.get_api_commands() - if valid_commands is None: - return make_response("Method not allowed", 405) + try: + valid_commands = api_plugin.get_api_commands() + if valid_commands is None: + return make_response("Method not allowed", 405) - if api_plugin.is_api_adminonly() and not current_user.is_admin(): - return make_response("Forbidden", 403) + if api_plugin.is_api_adminonly() and not current_user.is_admin(): + return make_response("Forbidden", 403) - command, data, response = get_json_command_from_request(request, valid_commands) - if response is not None: - return response + command, data, response = get_json_command_from_request(request, valid_commands) + if response is not None: + return response - response = api_plugin.on_api_command(command, data) - if response is not None: - return response - return NO_CONTENT + response = api_plugin.on_api_command(command, data) + if response is not None: + return response + return NO_CONTENT + except Exception: + logging.getLogger(__name__).exception("Error while excuting SimpleApiPlugin {}".format(name), + extra=dict(plugin=name)) + return abort(500) #~~ first run setup @@ -119,7 +129,9 @@ def wizardState(): version = implementation.get_wizard_version() ignored = octoprint.plugin.WizardPlugin.is_wizard_ignored(seen_wizards, implementation) except: - logging.getLogger(__name__).exception("There was an error fetching wizard details for {}, ignoring".format(name)) + logging.getLogger(__name__).exception("There was an error fetching wizard " + "details for {}, ignoring".format(name), + extra=dict(plugin=name)) else: result[name] = dict(required=required, details=details, version=version, ignored=ignored) @@ -154,7 +166,9 @@ def wizardFinish(): if name in handled: seen_wizards[name] = implementation.get_wizard_version() except: - logging.getLogger(__name__).exception("There was an error finishing the wizard for {}, ignoring".format(name)) + logging.getLogger(__name__).exception("There was an error finishing the " + "wizard for {}, ignoring".format(name), + extra=dict(plugin=name)) s().set(["server", "seenWizards"], seen_wizards) s().save() diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 70b73ef81..757f7a51f 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -130,6 +130,7 @@ def getSettings(): "serial": { "port": connectionOptions["portPreference"], "baudrate": connectionOptions["baudratePreference"], + "exclusive": s.getBoolean(["serial", "exclusive"]), "portOptions": connectionOptions["ports"], "baudrateOptions": connectionOptions["baudrates"], "autoconnect": s.getBoolean(["serial", "autoconnect"]), @@ -276,7 +277,8 @@ def _get_plugin_settings(): logger.warn("octoprint.plugin.SettingsPlugin.on_settings_load(self) instead.") except: logger.exception("Could not load settings for plugin {name} ({version})".format(version=plugin._plugin_version, - name=plugin._plugin_name)) + name=plugin._plugin_name), + extra=dict(plugin=plugin._identifier)) return data @@ -418,6 +420,7 @@ def _saveSettings(data): if "autoconnect" in data["serial"]: s.setBoolean(["serial", "autoconnect"], data["serial"]["autoconnect"]) if "port" in data["serial"]: s.set(["serial", "port"], data["serial"]["port"]) if "baudrate" in data["serial"]: s.setInt(["serial", "baudrate"], data["serial"]["baudrate"]) + if "exclusive" in data["serial"]: s.setBoolean(["serial", "exclusive"], data["serial"]["exclusive"]) if "timeoutConnection" in data["serial"]: s.setFloat(["serial", "timeout", "connection"], data["serial"]["timeoutConnection"], min=1.0) if "timeoutDetection" in data["serial"]: s.setFloat(["serial", "timeout", "detection"], data["serial"]["timeoutDetection"], min=1.0) if "timeoutCommunication" in data["serial"]: s.setFloat(["serial", "timeout", "communication"], data["serial"]["timeoutCommunication"], min=1.0) @@ -551,6 +554,8 @@ def _saveSettings(data): logger.warn("Please contact the plugin's author and ask to update the plugin to use a direct call like") logger.warn("octoprint.plugin.SettingsPlugin.on_settings_save(self, data) instead.") except: - logger.exception("Could not save settings for plugin {name} ({version})".format(version=plugin._plugin_version, name=plugin._plugin_name)) + logger.exception("Could not save settings for plugin {name} ({version})".format(version=plugin._plugin_version, + name=plugin._plugin_name), + extra=dict(plugin=plugin._identifier)) s.save(trigger_event=True) diff --git a/src/octoprint/server/apps/__init__.py b/src/octoprint/server/apps/__init__.py index 6cbe20c72..04d8edf87 100644 --- a/src/octoprint/server/apps/__init__.py +++ b/src/octoprint/server/apps/__init__.py @@ -107,7 +107,9 @@ def _get_registered_apps(): logger.warn("Plugin {} is still implementing the appkey hook that is deprecated since 1.3.11 and will be removed in 1.4.0. Switch it over to the Application Keys Plugin workflow.".format(name)) except: import logging - logging.getLogger(__name__).exception("Error while retrieving additional appkeys from plugin {name}".format(**locals())) + logging.getLogger(__name__).exception("Error while retrieving additional appkeys " + "from plugin {name}".format(**locals()), + extra=dict(plugin=name)) continue any_version_enabled = dict() diff --git a/src/octoprint/server/util/__init__.py b/src/octoprint/server/util/__init__.py index 970a98731..e2cea3630 100644 --- a/src/octoprint/server/util/__init__.py +++ b/src/octoprint/server/util/__init__.py @@ -193,7 +193,9 @@ def get_user_for_apikey(apikey): if user is not None: return user except: - logging.getLogger(__name__).exception("Error running api key validator for plugin {} and key {}".format(name, apikey)) + logging.getLogger(__name__).exception("Error running api key validator " + "for plugin {} and key {}".format(name, apikey), + extra=dict(plugin=name)) return None diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index 593d7872e..62f8905bf 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -1539,7 +1539,8 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"): all_assets = implementation.get_assets() basefolder = implementation.get_asset_folder() except: - logger.exception("Got an error while trying to collect assets from {}, ignoring assets from the plugin".format(name)) + logger.exception("Got an error while trying to collect assets from {}, ignoring assets from the plugin".format(name), + extra=dict(plugin=name)) continue def asset_exists(category, asset): diff --git a/src/octoprint/server/util/sockjs.py b/src/octoprint/server/util/sockjs.py index 8423f7ca2..2e6fe9a3b 100644 --- a/src/octoprint/server/util/sockjs.py +++ b/src/octoprint/server/util/sockjs.py @@ -268,7 +268,8 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection, o try: proceed = proceed and hook(self, self._user, type, payload) except: - self._logger.exception("Error processing emit hook handler from plugin {}".format(name)) + self._logger.exception("Error processing emit hook handler from plugin {}".format(name), + extra=dict(plugin=name)) if not proceed: return @@ -290,7 +291,8 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection, o try: proceed = proceed and hook(self, self._user) except: - self._logger.exception("Error processing register hook handler for plugin {}".format(name)) + self._logger.exception("Error processing register hook handler for plugin {}".format(name), + extra=dict(plugin=name)) if not proceed: return @@ -358,7 +360,8 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection, o try: hook(self, self._user) except: - self._logger.exception("Error processing authed hook handler for plugin {}".format(name)) + self._logger.exception("Error processing authed hook handler for plugin {}".format(name), + extra=dict(plugin=name)) def _on_logout(self): self._user = None @@ -367,5 +370,6 @@ class PrinterStateConnection(octoprint.vendor.sockjs.tornado.SockJSConnection, o try: hook(self, self._user) except: - self._logger.exception("Error processing authed hook handler for plugin {}".format(name)) + self._logger.exception("Error processing authed hook handler for plugin {}".format(name), + extra=dict(plugin=name)) diff --git a/src/octoprint/server/views.py b/src/octoprint/server/views.py index 0791997cf..b220e77ae 100644 --- a/src/octoprint/server/views.py +++ b/src/octoprint/server/views.py @@ -123,18 +123,22 @@ def in_cache(): ui_plugins = pluginManager.get_implementations(octoprint.plugin.UiPlugin, sorting_context="UiPlugin.on_ui_render") for plugin in ui_plugins: - if plugin.will_handle_ui(request): - ui = plugin._identifier - key = _cache_key(plugin._identifier, - url=url, - additional_key_data=plugin.get_ui_additional_key_data_for_cache) - unless = _preemptive_unless(url, additional_unless=plugin.get_ui_preemptive_caching_additional_unless) - data = _preemptive_data(plugin._identifier, - path=path, - base_url=base_url, - data=plugin.get_ui_data_for_preemptive_caching, - additional_request_data=plugin.get_ui_additional_request_data_for_preemptive_caching) - break + try: + if plugin.will_handle_ui(request): + ui = plugin._identifier + key = _cache_key(plugin._identifier, + url=url, + additional_key_data=plugin.get_ui_additional_key_data_for_cache) + unless = _preemptive_unless(url, additional_unless=plugin.get_ui_preemptive_caching_additional_unless) + data = _preemptive_data(plugin._identifier, + path=path, + base_url=base_url, + data=plugin.get_ui_data_for_preemptive_caching, + additional_request_data=plugin.get_ui_additional_request_data_for_preemptive_caching) + break + except Exception: + _logger.exception("Error while calling plugin {}, skipping it".format(plugin._identifier), + extra=dict(plugin=plugin._identifier)) else: ui = "_default" key = _cache_key("_default", url=url) @@ -403,13 +407,17 @@ def index(): # select view from plugins and fall back on default view if no plugin will handle it ui_plugins = pluginManager.get_implementations(octoprint.plugin.UiPlugin, sorting_context="UiPlugin.on_ui_render") for plugin in ui_plugins: - if plugin.will_handle_ui(request): - # plugin claims responsibility, let it render the UI - response = plugin_view(plugin) - if response is not None: - break - else: - _logger.warn("UiPlugin {} returned an empty response".format(plugin._identifier)) + try: + if plugin.will_handle_ui(request): + # plugin claims responsibility, let it render the UI + response = plugin_view(plugin) + if response is not None: + break + else: + _logger.warn("UiPlugin {} returned an empty response".format(plugin._identifier)) + except Exception: + _logger.exception("Error while calling plugin {}, skipping it".format(plugin._identifier), + extra=dict(plugin=plugin._identifier)) else: response = default_view() @@ -508,7 +516,9 @@ def fetch_template_data(refresh=False): try: result = hook(dict(template_sorting), dict(template_rules)) except: - _logger.exception("Error while retrieving custom template type definitions from plugin {name}".format(**locals())) + _logger.exception("Error while retrieving custom template type " + "definitions from plugin {name}".format(**locals()), + extra=dict(plugin=name)) else: if not isinstance(result, list): continue @@ -649,7 +659,8 @@ def fetch_template_data(refresh=False): wizard_required = implementation.is_wizard_required() wizard_ignored = octoprint.plugin.WizardPlugin.is_wizard_ignored(seen_wizards, implementation) except: - _logger.exception("Error while retrieving template data for plugin {}, ignoring it".format(name)) + _logger.exception("Error while retrieving template data for plugin {}, ignoring it".format(name), + extra=dict(plugin=name)) continue if not isinstance(vars, dict): diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index 22b6084f4..0faba904b 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -88,6 +88,7 @@ default_settings = { "serial": { "port": None, "baudrate": None, + "exclusive": True, "autoconnect": False, "log": False, "timeout": { @@ -158,6 +159,7 @@ default_settings = { "port": 5000, "firstRun": True, "startOnceInSafeMode": False, + "ignoreIncompleteStartup": False, "incompleteStartup": False, "seenWizards": {}, "secretKey": None, diff --git a/src/octoprint/slicing/__init__.py b/src/octoprint/slicing/__init__.py index f9e60b0a2..7f80432bd 100644 --- a/src/octoprint/slicing/__init__.py +++ b/src/octoprint/slicing/__init__.py @@ -139,7 +139,8 @@ class SlicingManager(object): try: slicers[plugin.get_slicer_properties()["type"]] = plugin except: - self._logger.exception("Error while getting properties from slicer {}, ignoring it".format(plugin._identifier)) + self._logger.exception("Error while getting properties from slicer {}, ignoring it".format(plugin._identifier), + extra=dict(plugin=plugin._identifier)) continue self._slicers = slicers diff --git a/src/octoprint/static/js/app/viewmodels/connection.js b/src/octoprint/static/js/app/viewmodels/connection.js index 63615747b..486464d67 100644 --- a/src/octoprint/static/js/app/viewmodels/connection.js +++ b/src/octoprint/static/js/app/viewmodels/connection.js @@ -177,6 +177,10 @@ $(function() { self.requestData(); }; + self.onEventDisconnected = function() { + self.requestData(); + }; + self.onStartup = function() { var connectionTab = $("#connection"); connectionTab.on("show", function() { diff --git a/src/octoprint/static/js/app/viewmodels/settings.js b/src/octoprint/static/js/app/viewmodels/settings.js index 2645c72f1..ac5bfc7fe 100644 --- a/src/octoprint/static/js/app/viewmodels/settings.js +++ b/src/octoprint/static/js/app/viewmodels/settings.js @@ -149,6 +149,7 @@ $(function() { self.serial_port = ko.observable(); self.serial_baudrate = ko.observable(); + self.serial_exclusive = ko.observable(); self.serial_portOptions = ko.observableArray([]); self.serial_baudrateOptions = ko.observableArray([]); self.serial_autoconnect = ko.observable(undefined); diff --git a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 index 6eac21d49..4165f5bc7 100644 --- a/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 +++ b/src/octoprint/templates/dialogs/settings/serialconnection.jinja2 @@ -8,7 +8,7 @@
-
+
{{ _('Connection') }}
@@ -43,8 +43,16 @@ {{ _('Use this to define additional serial port baud rates to list for connecting with, e.g. 123456. Comma separated.') }}
+
+
+ +
+
-
+
{{ _('Serial logging') }}
diff --git a/src/octoprint/templates/initscript.jinja2 b/src/octoprint/templates/initscript.jinja2 index 71ee636b1..9312de02e 100644 --- a/src/octoprint/templates/initscript.jinja2 +++ b/src/octoprint/templates/initscript.jinja2 @@ -25,6 +25,7 @@ // sockjs should define CLOSE_NORMAL for us, but they don't (from ws spec) var SOCKJS_CLOSE_NORMAL = 1000; + var UI_API_KEY = ""; // deprecated, only left for compatibility reasons var VERSION = "{{ version.number|e }}"; var DISPLAY_VERSION = "{{ version.display|e }}"; var BRANCH = "{{ version.branch|e }}"; diff --git a/src/octoprint/timelapse.py b/src/octoprint/timelapse.py index 9b61a9481..a6dfaf597 100644 --- a/src/octoprint/timelapse.py +++ b/src/octoprint/timelapse.py @@ -79,7 +79,9 @@ def valid_timelapse(path): continue extensions += result except: - logging.getLogger(__name__).exception("Exception while retrieving additional timelapse extensions from hook {name}".format(name=name)) + logging.getLogger(__name__).exception("Exception while retrieving additional timelapse " + "extensions from hook {name}".format(name=name), + extra=dict(plugin=name)) _extensions = list(set(extensions)) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 296f874a7..f0075e5cb 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -687,9 +687,9 @@ class MachineCom(object): if self.isSdFileSelected(): return "Starting print from SD" elif self.isStreaming(): - return "Sending file to SD" + return "Starting to send file to SD" else: - return "Printing" + return "Starting" elif state == self.STATE_PRINTING: if self.isSdFileSelected(): return "Printing from SD" @@ -999,7 +999,8 @@ class MachineCom(object): try: retval = hook(self, "gcode", scriptName) except: - self._logger.exception("Error while processing hook {name}.".format(**locals())) + self._logger.exception("Error while processing hook {name}.".format(**locals()), + extra=dict(plugin=name)) else: if retval is None: continue @@ -1520,7 +1521,8 @@ class MachineCom(object): if parsedTemps is None or not parsedTemps: return except: - self._logger.exception("Error while processing temperatures in {}, skipping".format(name)) + self._logger.exception("Error while processing temperatures in {}, skipping".format(name), + extra=dict(plugin=name)) if current_tool_key in parsedTemps.keys(): shared_nozzle = self._printerProfileManager.get_current_or_default()["extruder"]["sharedNozzle"] @@ -1660,11 +1662,13 @@ class MachineCom(object): self._log("Disconnecting on request of the printer...") self._callback.on_comm_force_disconnect() else: - for hook in self._printer_action_hooks: + for name, hook in self._printer_action_hooks.items(): try: - self._printer_action_hooks[hook](self, line, action_command) + hook(self, line, action_command) except: - self._logger.exception("Error while calling hook {} with action command {}".format(self._printer_action_hooks[hook], action_command)) + self._logger.exception("Error while calling hook from plugin " + "{} with action command {}".format(name, action_command), + extra=dict(plugin=name)) continue if self._state not in (self.STATE_CONNECTING, self.STATE_DETECT_BAUDRATE): @@ -1908,7 +1912,8 @@ class MachineCom(object): try: hook(self, firmware_name, copy.copy(data)) except: - self._logger.exception("Error processing firmware info hook {}:".format(name)) + self._logger.exception("Error processing firmware info hook {}:".format(name), + extra=dict(plugin=name)) ##~~ Firmware capability report triggered by M115 elif lower_line.startswith("cap:"): @@ -1932,7 +1937,8 @@ class MachineCom(object): try: hook(self, capability, enabled, copy.copy(self._firmware_capabilities)) except: - self._logger.exception("Error processing firmware capability hook {}:".format(name)) + self._logger.exception("Error processing firmware capability hook {}:".format(name), + extra=dict(plugin=name)) ##~~ invalid extruder elif 'invalid extruder' in lower_line: @@ -2553,7 +2559,7 @@ class MachineCom(object): self._log("Trying {}".format(p)) programmer.connect(p) serial_obj = programmer.leaveISP() - except: + except Exception as e: self._log("Could not connect to or enter programming mode on {}, might not be a printer or just not allow programming mode".format(p)) self._logger.info("Could not enter programming mode on {}: {}".format(p, e)) @@ -2585,10 +2591,12 @@ class MachineCom(object): "baudrate": baudrateList()[0] if baudrate == 0 else baudrate, "timeout": read_timeout, "write_timeout": 0, - "parity": serial.PARITY_ODD, - "exclusive": True + "parity": serial.PARITY_ODD } + if settings().getBoolean(["serial", "exclusive"]): + serial_port_args["exclusive"] = True + serial_obj = serial.Serial(**serial_port_args) serial_obj.close() @@ -2692,7 +2700,8 @@ class MachineCom(object): try: ret = hook(self, stripped_error) except: - self._logger.exception("Error while processing hook {name}:".format(**locals())) + self._logger.exception("Error while processing hook {name}:".format(**locals()), + extra=dict(plugin=name)) else: if ret: return line @@ -2739,18 +2748,19 @@ class MachineCom(object): self.close(is_error=True) return None - try: - ret = ret.decode('utf-8') - except UnicodeDecodeError: - ret = ret.decode('latin1') - - self._log(u"Recv: {}".format(ret)) + if ret != "": + try: + self._log("Recv: " + sanitize_ascii(ret)) + except ValueError as e: + self._log("WARN: While reading last line: %s" % e) + self._log("Recv: " + repr(ret)) for name, hook in self._received_message_hooks.items(): try: ret = hook(self, ret) except Exception: - self._logger.exception("Error while processing hook {name}:".format(**locals())) + self._logger.exception("Error while processing hook {name}:".format(**locals()), + extra=dict(plugin=name)) else: if ret is None: return "" @@ -3179,7 +3189,7 @@ class MachineCom(object): def _log_command_phase(self, phase, command, *args, **kwargs): if self._phaseLogger.isEnabledFor(logging.DEBUG): output_parts = [u"phase: {}".format(phase), - u"command: {}".format(command)] + u"command: {}".format(to_unicode(command, errors="replace"))] if kwargs.get("command_type"): output_parts.append(u"command_type: {}".format(kwargs["command_type"])) @@ -3190,7 +3200,7 @@ class MachineCom(object): if kwargs.get("tags"): output_parts.append(u"tags: [ {} ]".format(", ".join(sorted(kwargs["tags"])))) - self._phaseLogger.debug(" | ".join(output_parts)) + self._phaseLogger.debug(u" | ".join(output_parts)) def _process_command_phase(self, phase, command, command_type=None, gcode=None, subcode=None, tags=None): if gcode is None: @@ -3209,7 +3219,12 @@ class MachineCom(object): try: hook_results = hook(self, phase, command, command_type, gcode, subcode=subcode, tags=tags) except: - self._logger.exception("Error while processing hook {name} for phase {phase} and command {command}:".format(**locals())) + self._logger.exception(u"Error while processing hook {name} for phase " + u"{phase} and command {command}:".format(name=name, + phase=phase, + command=to_unicode(command, + errors="replace")), + extra=dict(plugin=name)) else: normalized = _normalize_command_handler_result(command, command_type, gcode, subcode, tags, hook_results, @@ -3219,7 +3234,14 @@ class MachineCom(object): # make sure we don't allow multi entry results in anything but the queuing phase if not phase in ("queuing",) and len(normalized) > 1: - self._logger.error("Error while processing hook {name} for phase {phase} and command {command}: Hook returned multi-entry result for phase {phase} and command {command}. That's not supported, if you need to do multi expansion of commands you need to do this in the queuing phase. Ignoring hook result and sending command as-is.".format(**locals())) + self._logger.error(u"Error while processing hook {name} for phase {phase} and command {command}: " + u"Hook returned multi-entry result for phase {phase} and command {command}. " + u"That's not supported, if you need to do multi expansion of commands you " + u"need to do this in the queuing phase. Ignoring hook result and sending " + u"command as-is.".format(name=name, + phase=phase, + command=to_unicode(command, errors="replace")), + extra=dict(plugin=name)) new_results.append((command, command_type, gcode, subcode, tags)) else: new_results += normalized @@ -3290,7 +3312,9 @@ class MachineCom(object): try: hook(self, phase, atcommand, parameters, tags=tags) except: - self._logger.exception("Error while processing hook {} for phase {} and command {}:".format(name, phase, atcommand)) + self._logger.exception(u"Error while processing hook {} for " + u"phase {} and command {}:".format(name, phase, to_unicode(atcommand, errors="replace")), + extra=dict(plugin=name)) # trigger built-in handler if available handler = getattr(self, "_atcommand_{}_{}".format(atcommand, phase), None) @@ -3298,7 +3322,8 @@ class MachineCom(object): try: handler(atcommand, parameters, tags=tags) except: - self._logger.exception("Error in handler for phase {} and command {}".format(phase, atcommand)) + self._logger.exception(u"Error in handler for phase {} and command {}".format(phase, + to_unicode(atcommand, errors="replace"))) ##~~ actual sending via serial diff --git a/translations/de/LC_MESSAGES/messages.po b/translations/de/LC_MESSAGES/messages.po index 851f551cb..2dd8b3fa0 100644 --- a/translations/de/LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: OctoPrint\n" "Report-Msgid-Bugs-To: i18n@octoprint.org\n" -"POT-Creation-Date: 2019-04-04 14:21+0200\n" +"POT-Creation-Date: 2019-04-10 12:34+0200\n" "PO-Revision-Date: 2019-03-26 14:25+0100\n" "Last-Translator: Gina Häußge \n" "Language: de\n" @@ -650,13 +650,13 @@ msgid "Server Commands" msgstr "Serverbefehle" #: src/octoprint/plugins/corewizard/subwizards.py:49 -#: src/octoprint/server/views.py:585 +#: src/octoprint/server/views.py:595 msgid "Webcam & Timelapse" msgstr "Webcam & Zeitraffer" #: src/octoprint/plugins/corewizard/subwizards.py:64 #: src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2:1 -#: src/octoprint/server/views.py:591 +#: src/octoprint/server/views.py:601 msgid "Access Control" msgstr "Zugangsbeschränkung" @@ -1205,7 +1205,7 @@ msgstr "" "Ohne dieses Plugin wird deine OctoPrint Instanz nicht mehr in deinem " "Netzwerk mittels Bonjour oder uPnP automatisch auffindbar sein." -#: src/octoprint/plugins/errortracking/__init__.py:39 +#: src/octoprint/plugins/errortracking/__init__.py:67 #: src/octoprint/plugins/errortracking/templates/errortracking_settings.jinja2:1 msgid "Error Tracking" msgstr "Fehlertracking" @@ -1333,7 +1333,7 @@ msgstr "" " noreferer\">Privacy Policy an.\n" "

\n" -#: src/octoprint/plugins/forcelogin/__init__.py:189 +#: src/octoprint/plugins/forcelogin/__init__.py:190 msgid "" "Without this plugin anonymous users will have read-only access to your " "OctoPrint instance. Only disable this if you are comfortable with this, " @@ -2170,25 +2170,25 @@ msgstr "Warnung!" msgid "Learn more..." msgstr "Mehr erfahren..." -#: src/octoprint/plugins/softwareupdate/__init__.py:519 +#: src/octoprint/plugins/softwareupdate/__init__.py:521 msgid "Python" msgstr "Python" -#: src/octoprint/plugins/softwareupdate/__init__.py:520 +#: src/octoprint/plugins/softwareupdate/__init__.py:522 msgid "pip" msgstr "pip" -#: src/octoprint/plugins/softwareupdate/__init__.py:521 +#: src/octoprint/plugins/softwareupdate/__init__.py:523 msgid "setuptools" msgstr "setuptools" -#: src/octoprint/plugins/softwareupdate/__init__.py:608 +#: src/octoprint/plugins/softwareupdate/__init__.py:610 #: src/octoprint/plugins/softwareupdate/templates/softwareupdate_wizard.jinja2:1 msgid "Software Update" msgstr "Software Update" -#: src/octoprint/plugins/softwareupdate/__init__.py:1048 -#: src/octoprint/server/views.py:589 +#: src/octoprint/plugins/softwareupdate/__init__.py:1050 +#: src/octoprint/server/views.py:599 #: src/octoprint/static/js/app/viewmodels/appearance.js:99 #: src/octoprint/static/js/app/viewmodels/appearance.js:104 #: src/octoprint/static/js/app/viewmodels/appearance.js:106 @@ -2198,7 +2198,7 @@ msgstr "Software Update" msgid "OctoPrint" msgstr "OctoPrint" -#: src/octoprint/plugins/softwareupdate/__init__.py:1212 +#: src/octoprint/plugins/softwareupdate/__init__.py:1214 msgid "" "Without this plugin OctoPrint will no longer be able to update itself or " "any of your installed plugins which might put your system at risk." @@ -2871,109 +2871,109 @@ msgstr "" "target=\"_blank\" rel=\"noopener noreferrer\">Privacy Policy auf " "tracking.octoprint.org.\n" -#: src/octoprint/server/views.py:499 +#: src/octoprint/server/views.py:507 msgid "Plugins" msgstr "Plugins" -#: src/octoprint/server/views.py:556 +#: src/octoprint/server/views.py:566 #: src/octoprint/templates/dialogs/settings/serialconnection.jinja2:12 msgid "Connection" msgstr "Verbindung" -#: src/octoprint/server/views.py:557 +#: src/octoprint/server/views.py:567 #: src/octoprint/templates/sidebar/state.jinja2:1 msgid "State" msgstr "Status" -#: src/octoprint/server/views.py:558 +#: src/octoprint/server/views.py:568 msgid "Files" msgstr "Dateien" -#: src/octoprint/server/views.py:564 +#: src/octoprint/server/views.py:574 msgid "Temperature" msgstr "Temperatur" -#: src/octoprint/server/views.py:565 +#: src/octoprint/server/views.py:575 msgid "Control" msgstr "Steuerung" -#: src/octoprint/server/views.py:566 +#: src/octoprint/server/views.py:576 msgid "GCode Viewer" msgstr "GCode Viewer" -#: src/octoprint/server/views.py:567 +#: src/octoprint/server/views.py:577 msgid "Terminal" msgstr "Terminal" -#: src/octoprint/server/views.py:568 +#: src/octoprint/server/views.py:578 #: src/octoprint/templates/sidebar/state.jinja2:8 msgid "Timelapse" msgstr "Zeitraffer" -#: src/octoprint/server/views.py:574 +#: src/octoprint/server/views.py:584 msgid "Printer" msgstr "Drucker" -#: src/octoprint/server/views.py:576 +#: src/octoprint/server/views.py:586 msgid "Serial Connection" msgstr "Serielle Verbindung" -#: src/octoprint/server/views.py:577 +#: src/octoprint/server/views.py:587 #: src/octoprint/templates/dialogs/settings/printerprofiles.jinja2:1 msgid "Printer Profiles" msgstr "Druckerprofile" -#: src/octoprint/server/views.py:578 +#: src/octoprint/server/views.py:588 msgid "Temperatures" msgstr "Temperaturen" -#: src/octoprint/server/views.py:579 +#: src/octoprint/server/views.py:589 msgid "Terminal Filters" msgstr "Terminalfilter" -#: src/octoprint/server/views.py:580 +#: src/octoprint/server/views.py:590 msgid "GCODE Scripts" msgstr "GCODE Scripts" -#: src/octoprint/server/views.py:582 src/octoprint/server/views.py:584 +#: src/octoprint/server/views.py:592 src/octoprint/server/views.py:594 msgid "Features" msgstr "Funktionen" -#: src/octoprint/server/views.py:586 +#: src/octoprint/server/views.py:596 msgid "GCODE Visualizer" msgstr "GCode Viewer" -#: src/octoprint/server/views.py:587 +#: src/octoprint/server/views.py:597 msgid "API" msgstr "API" -#: src/octoprint/server/views.py:592 +#: src/octoprint/server/views.py:602 #: src/octoprint/templates/dialogs/settings/folders.jinja2:2 #: src/octoprint/templates/sidebar/files_header.jinja2:10 msgid "Folders" msgstr "Verzeichnisse" -#: src/octoprint/server/views.py:593 +#: src/octoprint/server/views.py:603 msgid "Appearance" msgstr "Aussehen" -#: src/octoprint/server/views.py:594 +#: src/octoprint/server/views.py:604 msgid "Server" msgstr "Server" -#: src/octoprint/server/views.py:600 +#: src/octoprint/server/views.py:610 msgid "Access" msgstr "Zugriff" -#: src/octoprint/server/views.py:601 +#: src/octoprint/server/views.py:611 msgid "Interface" msgstr "Interface" -#: src/octoprint/server/views.py:617 +#: src/octoprint/server/views.py:627 msgid "Start" msgstr "Start" -#: src/octoprint/server/views.py:618 +#: src/octoprint/server/views.py:628 #: src/octoprint/templates/dialogs/wizard.jinja2:57 msgid "Finish" msgstr "Beenden" diff --git a/translations/messages.pot b/translations/messages.pot index 97f6b7b52..b397d294d 100644 --- a/translations/messages.pot +++ b/translations/messages.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: OctoPrint 1.3.11rc2.dev18+g0b6dd7e76\n" +"Project-Id-Version: OctoPrint 1.3.11rc3.dev25+g9775d99fe\n" "Report-Msgid-Bugs-To: i18n@octoprint.org\n" -"POT-Creation-Date: 2019-04-04 14:21+0200\n" +"POT-Creation-Date: 2019-04-10 12:34+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -595,13 +595,13 @@ msgid "Server Commands" msgstr "" #: src/octoprint/plugins/corewizard/subwizards.py:49 -#: src/octoprint/server/views.py:585 +#: src/octoprint/server/views.py:595 msgid "Webcam & Timelapse" msgstr "" #: src/octoprint/plugins/corewizard/subwizards.py:64 #: src/octoprint/plugins/corewizard/templates/corewizard_acl_wizard.jinja2:1 -#: src/octoprint/server/views.py:591 +#: src/octoprint/server/views.py:601 msgid "Access Control" msgstr "" @@ -1002,7 +1002,7 @@ msgid "" "discoverable on the network via Bonjour and uPnP." msgstr "" -#: src/octoprint/plugins/errortracking/__init__.py:39 +#: src/octoprint/plugins/errortracking/__init__.py:67 #: src/octoprint/plugins/errortracking/templates/errortracking_settings.jinja2:1 msgid "Error Tracking" msgstr "" @@ -1092,7 +1092,7 @@ msgid "" "

\n" msgstr "" -#: src/octoprint/plugins/forcelogin/__init__.py:189 +#: src/octoprint/plugins/forcelogin/__init__.py:190 msgid "" "Without this plugin anonymous users will have read-only access to your " "OctoPrint instance. Only disable this if you are comfortable with this, " @@ -1841,25 +1841,25 @@ msgstr "" msgid "Learn more..." msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:519 +#: src/octoprint/plugins/softwareupdate/__init__.py:521 msgid "Python" msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:520 +#: src/octoprint/plugins/softwareupdate/__init__.py:522 msgid "pip" msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:521 +#: src/octoprint/plugins/softwareupdate/__init__.py:523 msgid "setuptools" msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:608 +#: src/octoprint/plugins/softwareupdate/__init__.py:610 #: src/octoprint/plugins/softwareupdate/templates/softwareupdate_wizard.jinja2:1 msgid "Software Update" msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:1048 -#: src/octoprint/server/views.py:589 +#: src/octoprint/plugins/softwareupdate/__init__.py:1050 +#: src/octoprint/server/views.py:599 #: src/octoprint/static/js/app/viewmodels/appearance.js:99 #: src/octoprint/static/js/app/viewmodels/appearance.js:104 #: src/octoprint/static/js/app/viewmodels/appearance.js:106 @@ -1869,7 +1869,7 @@ msgstr "" msgid "OctoPrint" msgstr "" -#: src/octoprint/plugins/softwareupdate/__init__.py:1212 +#: src/octoprint/plugins/softwareupdate/__init__.py:1214 msgid "" "Without this plugin OctoPrint will no longer be able to update itself or " "any of your installed plugins which might put your system at risk." @@ -2410,109 +2410,109 @@ msgid "" "tracking.octoprint.org.\n" msgstr "" -#: src/octoprint/server/views.py:499 +#: src/octoprint/server/views.py:507 msgid "Plugins" msgstr "" -#: src/octoprint/server/views.py:556 +#: src/octoprint/server/views.py:566 #: src/octoprint/templates/dialogs/settings/serialconnection.jinja2:12 msgid "Connection" msgstr "" -#: src/octoprint/server/views.py:557 +#: src/octoprint/server/views.py:567 #: src/octoprint/templates/sidebar/state.jinja2:1 msgid "State" msgstr "" -#: src/octoprint/server/views.py:558 +#: src/octoprint/server/views.py:568 msgid "Files" msgstr "" -#: src/octoprint/server/views.py:564 +#: src/octoprint/server/views.py:574 msgid "Temperature" msgstr "" -#: src/octoprint/server/views.py:565 +#: src/octoprint/server/views.py:575 msgid "Control" msgstr "" -#: src/octoprint/server/views.py:566 +#: src/octoprint/server/views.py:576 msgid "GCode Viewer" msgstr "" -#: src/octoprint/server/views.py:567 +#: src/octoprint/server/views.py:577 msgid "Terminal" msgstr "" -#: src/octoprint/server/views.py:568 +#: src/octoprint/server/views.py:578 #: src/octoprint/templates/sidebar/state.jinja2:8 msgid "Timelapse" msgstr "" -#: src/octoprint/server/views.py:574 +#: src/octoprint/server/views.py:584 msgid "Printer" msgstr "" -#: src/octoprint/server/views.py:576 +#: src/octoprint/server/views.py:586 msgid "Serial Connection" msgstr "" -#: src/octoprint/server/views.py:577 +#: src/octoprint/server/views.py:587 #: src/octoprint/templates/dialogs/settings/printerprofiles.jinja2:1 msgid "Printer Profiles" msgstr "" -#: src/octoprint/server/views.py:578 +#: src/octoprint/server/views.py:588 msgid "Temperatures" msgstr "" -#: src/octoprint/server/views.py:579 +#: src/octoprint/server/views.py:589 msgid "Terminal Filters" msgstr "" -#: src/octoprint/server/views.py:580 +#: src/octoprint/server/views.py:590 msgid "GCODE Scripts" msgstr "" -#: src/octoprint/server/views.py:582 src/octoprint/server/views.py:584 +#: src/octoprint/server/views.py:592 src/octoprint/server/views.py:594 msgid "Features" msgstr "" -#: src/octoprint/server/views.py:586 +#: src/octoprint/server/views.py:596 msgid "GCODE Visualizer" msgstr "" -#: src/octoprint/server/views.py:587 +#: src/octoprint/server/views.py:597 msgid "API" msgstr "" -#: src/octoprint/server/views.py:592 +#: src/octoprint/server/views.py:602 #: src/octoprint/templates/dialogs/settings/folders.jinja2:2 #: src/octoprint/templates/sidebar/files_header.jinja2:10 msgid "Folders" msgstr "" -#: src/octoprint/server/views.py:593 +#: src/octoprint/server/views.py:603 msgid "Appearance" msgstr "" -#: src/octoprint/server/views.py:594 +#: src/octoprint/server/views.py:604 msgid "Server" msgstr "" -#: src/octoprint/server/views.py:600 +#: src/octoprint/server/views.py:610 msgid "Access" msgstr "" -#: src/octoprint/server/views.py:601 +#: src/octoprint/server/views.py:611 msgid "Interface" msgstr "" -#: src/octoprint/server/views.py:617 +#: src/octoprint/server/views.py:627 msgid "Start" msgstr "" -#: src/octoprint/server/views.py:618 +#: src/octoprint/server/views.py:628 #: src/octoprint/templates/dialogs/wizard.jinja2:57 msgid "Finish" msgstr ""