Merge branch 'staging/maintenance' into maintenance

This commit is contained in:
Gina Häußge committed 2017-12-05 16:01:28 +01:00
commit 9bdbb930ad
21 files changed
+1524 -3489

No files matched your search

+3 -3
View File
@@ -22,10 +22,10 @@ maintenance 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
fix/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
improve/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.6rc2
# staging/maintenance is currently the branch for preparation of 1.3.6rc3
# so is regressionfix/...
staging/maintenance 1.3.6rc2 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
regressionfix/.* 1.3.6rc2 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
staging/maintenance 1.3.6rc3 3f4a70cf92a7d9081932850be1ea9fb298f0e3f7 pep440-dev
regressionfix/.* 1.3.6rc3 3f4a70cf92a7d9081932850be1ea9fb298f0e3f7 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
+19
View File
@@ -1,5 +1,24 @@
# OctoPrint Changelog
## 1.3.6rc2 (2017-12-05)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
A change to solve issues with plugins bundling JS assets that cause interference with other plugins (e.g. through the declaration of `"use strict"`) and in general to add better isolation and error handling might cause errors for some plugins that go beyond your run-off-the-mill view model and also implicitly declare new globals.
If you happen to run into any such issues, you can switch back to the old way of bundling JS assets via the newly introduced "Settings > Feature > Enable legacy plugin asset bundling" toggle (check it, save the settings, restart the server). This is provided to allow for a minimally invasive adjustment period until affected plugins have been updated.
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
### Bug fixes
* [#2262](https://github.com/foosel/OctoPrint/issues/2262) - Fixed a bug causing `Error:checksum mismatch, Last Line: ...` errors from the firmware to be handled incorrectly.
* [#2267](https://github.com/foosel/OctoPrint/issues/2267) - Fixed a bug causing the GCODE viewer to not get properly initialized due to a JS error on load if "Also show next layer" was selected.
* [#2268](https://github.com/foosel/OctoPrint/issues/2268) - Fixed a bug causing a display error with the temperature offsets. If one offset was changed, all others seemed to revert back to 0.
* Fixed ordering of plugin assets, should be alphabetical based on the plugin identifier.
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.6rc1...1.3.6rc2))
## 1.3.6rc1 (2017-12-01)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
+1 -3
View File
@@ -38,14 +38,12 @@ thanks to everyone who contributed!
* Marcus Ackermann
* Mark Qvist
* Mark Walker
* Masayoshi Mitsui
* Michael Aumock
* Miles Flavel
* mitchell hirsch
* Mohammed khorakiwala
* Noe Ruiz
* Patrick McGinnis
* Peter Grace
* Peter Schmehl
* PRINT3Dforum.com
* Robert Gusek
@@ -61,4 +59,4 @@ thanks to everyone who contributed!
* Timeshell.ca
* Trent Shumay
and 1151 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1144 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
+1 -1
View File
@@ -146,7 +146,7 @@ Out of the box, OctoPrint defaults to the following script setup for ``afterPrin
;disable all heaters
{% snippet 'disable_hotends' %}
[% snippet 'disable_bed' %}
{% snippet 'disable_bed' %}
;disable fan
M106 S0
+1 -1
View File
@@ -63,7 +63,7 @@ EXTRA_REQUIRES = dict(
# Dependencies for developing OctoPrint
develop=[
# Testing dependencies
"mock>=1.0.1,<1.1",
"mock>=2.0.0,<3",
"nose>=1.3.0,<1.4",
"ddt",
@@ -6,6 +6,11 @@
normal operation, allowing you to uninstall or update them to a newer version.
{% endtrans %}</p>
<p>{% trans url="http://plugins.octoprint.org/blacklist/" %}
By default, OctoPrint will use the blacklist hosted at <code>plugins.octoprint.org/blacklist.json</code> which you
can also take a look at in a more human readable format <a href="{{ url }}" target="_blank">here</a>.
{% endtrans %}</p>
<p>{% trans %}
Please decide whether to allow fetch and use of this centralized blacklist starting with the next server start.
You may also change your decision at any time through Settings > Server right from within OctoPrint.
@@ -66,6 +66,8 @@ class VirtualPrinter(object):
self._prepared_errors = []
self._errors = settings().get(["devel", "virtualPrinter", "errors"], merged=True)
self.currentExtruder = 0
self.extruderCount = settings().getInt(["devel", "virtualPrinter", "numExtruders"])
self.pinnedExtruders = settings().get(["devel", "virtualPrinter", "pinnedExtruders"])
@@ -146,8 +148,8 @@ class VirtualPrinter(object):
self._triggerResendAt100 = True
self._triggerResendWithTimeoutAt105 = True
self._triggeredResendWithTimeoutAt105 = False
self._triggerResendWithMissingLinenoAt110 = True
self._triggerResendWithChecksumMismatchAt115 = True
readThread = threading.Thread(target=self._processIncoming, name="octoprint.plugins.virtual_printer.wait_thread")
readThread.start()
@@ -227,7 +229,7 @@ class VirtualPrinter(object):
self.currentLine += 1
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
self._send("Error: Missing checksum")
self._send(self._error("checksum_missing"))
continue
# track N = N + 1
@@ -261,7 +263,11 @@ class VirtualPrinter(object):
continue
elif linenumber == 110 and self._triggerResendWithMissingLinenoAt110 and not self._writingToSd:
self._triggerResendWithMissingLinenoAt110 = False
self._send("Error: No Line Number with checksum, Last Line: {}".format(self.lastN))
self._send(self._error("lineno_missing", self.lastN))
continue
elif linenumber == 115 and self._triggerResendWithChecksumMismatchAt115 and not self._writingToSd:
self._triggerResendWithChecksumMismatchAt115 = False
self._triggerResend(checksum=True)
continue
elif len(self._prepared_errors):
prepared = self._prepared_errors.pop(0)
@@ -355,7 +361,7 @@ class VirtualPrinter(object):
self._send("echo:changed F value")
return False
else:
self._send("Error: Unknown command F")
self._send(self._error("command_unknown", "F"))
return True
def _gcode_M104(self, data):
@@ -549,11 +555,11 @@ class VirtualPrinter(object):
if actual is None:
if checksum:
self._send("Error: Wrong checksum")
self._send(self._error("checksum_mismatch"))
else:
self._send("Error: Missing checksum")
self._send(self._error("checksum_missing"))
else:
self._send("Error: expected line %d got %d" % (expected, actual))
self._send(self._error("lineno_mismatch", expected, actual))
def request_resend():
self._send("Resend:%d" % expected)
@@ -636,11 +642,13 @@ class VirtualPrinter(object):
elif data == "trigger_missing_checksum":
self._prepared_errors.append(lambda cur, last, line: self._triggerResend(expected=last, checksum=False))
elif data == "trigger_missing_lineno":
self._prepared_errors.append(lambda cur, last, line: self._send("Error: No Line Number with checksum, Last Line: {}".format(last)))
self._prepared_errors.append(lambda cur, last, line: self._send(self._error("lineno_missing", last)))
elif data == "drop_connection":
self._debug_drop_connection = True
elif data == "mintemp_error":
self._send(self._error("mintemp"))
elif data == "maxtemp_error":
self._send("Error: MAXTEMP triggered!")
self._send(self._error("maxtemp"))
elif data == "go_awol":
self._send("// Going AWOL")
self._debug_awol = True
@@ -1182,6 +1190,9 @@ class VirtualPrinter(object):
return ok.format(ok, lastN=self.lastN, buffer=self.buffered.maxsize - self.buffered.qsize())
def _error(self, error, *args, **kwargs):
return "Error: {}".format(self._errors.get(error).format(*args, **kwargs))
class CharCountingQueue(queue.Queue):
def __init__(self, maxsize, name=None):
+1 -1
View File
@@ -367,7 +367,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
return
self._comm.setTemperatureOffset(offsets)
self._setOffsets(offsets)
self._setOffsets(self._comm.getOffsets())
def _convert_rate_value(self, factor, min=0, max=200):
if not isinstance(factor, (int, float, long)):
+3 -3
View File
@@ -15,7 +15,7 @@ from flask.ext.assets import Environment, Bundle
from babel import Locale
from watchdog.observers import Observer
from watchdog.observers.polling import PollingObserver
from collections import defaultdict
from collections import defaultdict, OrderedDict
from builtins import bytes, range
from past.builtins import basestring
@@ -1268,7 +1268,7 @@ class Server(object):
# TODO remove again in 1.3.8
def js_bundles_for_plugins(collection, filters=None):
"""Produces Bundle instances"""
result = dict()
result = OrderedDict()
for plugin, assets in collection.items():
if len(assets):
result[plugin] = Bundle(*assets, filters=filters)
@@ -1277,7 +1277,7 @@ class Server(object):
else:
def js_bundles_for_plugins(collection, filters=None):
"""Produces JsPluginBundle instances that output IIFE wrapped assets"""
result = dict()
result = OrderedDict()
for plugin, assets in collection.items():
if len(assets):
result[plugin] = JsPluginBundle(plugin, *assets, filters=filters)
+8 -6
View File
@@ -28,6 +28,8 @@ import octoprint.server
import octoprint.users
import octoprint.plugin
from octoprint.util import DefaultOrderedDict
from werkzeug.contrib.cache import BaseCache
from past.builtins import basestring
@@ -1348,12 +1350,12 @@ def collect_plugin_assets(enable_gcodeviewer=True, preferred_stylesheet="css"):
logger = logging.getLogger(__name__ + ".collect_plugin_assets")
supported_stylesheets = ("css", "less")
assets = dict(bundled=dict(js=collections.defaultdict(list),
css=collections.defaultdict(list),
less=collections.defaultdict(list)),
external=dict(js=collections.defaultdict(list),
css=collections.defaultdict(list),
less=collections.defaultdict(list)))
assets = dict(bundled=dict(js=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)),
external=dict(js=DefaultOrderedDict(list),
css=DefaultOrderedDict(list),
less=DefaultOrderedDict(list)))
asset_plugins = octoprint.plugin.plugin_manager().get_implementations(octoprint.plugin.AssetPlugin)
for implementation in asset_plugins:
+10 -1
View File
@@ -389,7 +389,16 @@ default_settings = {
"capabilities": {
"AUTOREPORT_TEMP": True
},
"ambientTemperature": 21.3
"ambientTemperature": 21.3,
"errors": {
"checksum_mismatch": "Checksum mismatch",
"checksum_missing": "Missing checksum",
"lineno_mismatch": "expected line {} got {}",
"lineno_missing": "No Line Number with checksum, Last Line: {}",
"maxtemp": "MAXTEMP triggered!",
"mintemp": "MINTEMP triggered!",
"command_unknown": "Unknown command {}"
}
}
}
}
@@ -69,7 +69,7 @@ GCODE.renderer = (function(){
ctx.clearRect(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
drawGrid();
drawBoundingBox();
if(renderOptions['showNextLayer'] && layerNumStore < model.length - 1) {
if (renderOptions['showNextLayer'] && model && model.length && layerNumStore < model.length - 1) {
drawLayer(layerNumStore + 1, 0, GCODE.renderer.getLayerNumSegments(layerNumStore + 1), true);
}
if (renderOptions['showPreviousLayer'] && layerNumStore > 0) {
@@ -3,3 +3,8 @@
the use of a centralized plugin version blacklist to automatically disable such plugins before they can interfere
with normal operation.
{% endtrans %}</p>
<p>{% trans url="http://plugins.octoprint.org/blacklist/" %}
By default, OctoPrint will use the blacklist hosted at <code>plugins.octoprint.org/blacklist.json</code> which you
can also take a look at in a more human readable format <a href="{{ url }}" target="_blank">here</a>.
{% endtrans %}</p>
File diff suppressed because it is too large. Load diff
+46
View File
@@ -20,6 +20,7 @@ import threading
from functools import wraps
import warnings
import contextlib
import collections
try:
import queue
@@ -737,6 +738,51 @@ def dict_filter(dictionary, filter_function):
return dict((k, v) for k, v in dictionary.items() if filter_function(k, v))
# Source: http://stackoverflow.com/a/6190500/562769
class DefaultOrderedDict(collections.OrderedDict):
def __init__(self, default_factory=None, *a, **kw):
if default_factory is not None and not callable(default_factory):
raise TypeError('first argument must be callable')
collections.OrderedDict.__init__(self, *a, **kw)
self.default_factory = default_factory
def __getitem__(self, key):
try:
return collections.OrderedDict.__getitem__(self, key)
except KeyError:
return self.__missing__(key)
def __missing__(self, key):
if self.default_factory is None:
raise KeyError(key)
self[key] = value = self.default_factory()
return value
def __reduce__(self):
if self.default_factory is None:
args = tuple()
else:
args = self.default_factory,
return type(self), args, None, None, self.items()
def copy(self):
return self.__copy__()
def __copy__(self):
return type(self)(self.default_factory, self)
def __deepcopy__(self, memo):
import copy
return type(self)(self.default_factory,
copy.deepcopy(self.items()))
# noinspection PyMethodOverriding
def __repr__(self):
return 'OrderedDefaultDict(%s, %s)' % (self.default_factory,
collections.OrderedDict.__repr__(self))
class Object(object):
pass
+14 -12
View File
@@ -1953,18 +1953,20 @@ class MachineCom(object):
return False
_resend_request_communication_errors = ("line number",
"wrong checksum",
"missing checksum",
"format error",
"expected line")
_recoverable_communication_errors = ("no line number with checksum",)
_sd_card_errors = ("volume.init",
"openroot",
"workdir",
"error writing to file",
"cannot open",
"cannot enter")
_recoverable_communication_errors = ("no line number with checksum",)
_resend_request_communication_errors = ("line number", # since this error class get's checked after recoverable
# communication errors, we can use this broad term here
"checksum", # since this error class get's checked after recoverable
# communication errors, we can use this broad term here
"format error",
"expected line")
_sd_card_errors = ("volume.init",
"openroot",
"workdir",
"error writing to file",
"cannot open",
"open failed",
"cannot enter")
def _handle_errors(self, line):
if line is None:
return
+237
View File
@@ -0,0 +1,237 @@
import unittest
import mock
import ddt
import octoprint.util.comm
@ddt.ddt
class TestCommErrorHandling(unittest.TestCase):
def setUp(self):
self._comm = mock.create_autospec(octoprint.util.comm.MachineCom)
# mocks
self._comm._handle_errors = lambda *args, **kwargs: octoprint.util.comm.MachineCom._handle_errors(self._comm, *args, **kwargs)
self._comm._recoverable_communication_errors = octoprint.util.comm.MachineCom._recoverable_communication_errors
self._comm._resend_request_communication_errors = octoprint.util.comm.MachineCom._resend_request_communication_errors
self._comm._sd_card_errors = octoprint.util.comm.MachineCom._sd_card_errors
self._comm._lastCommError = None
self._comm._errorValue = None
self._comm._clear_to_send = mock.Mock()
# settings
self._comm._ignore_errors = False
self._comm._disconnect_on_errors = True
self._comm.isPrinting.return_value = True
self._comm.isError.return_value = False
@ddt.data(
# Marlin
"Error: Line Number is not Last Line Number+1, Last Line: 1",
# Repetier
"Error: Expected Line 1 got 2",
# !! error type for good measure
"!! expected line 1 got 2"
)
def test_lineno_mismatch(self, line):
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_resend()
@ddt.data(
# Marlin
"Error: No Line Number with checksum, Last Line: 1",
)
def test_lineno_missing(self, line):
"""Should simulate OK to force resend request"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_recoverable()
@ddt.data(
# Marlin
"Error: checksum mismatch",
# Repetier
"Error: Wrong checksum",
)
def test_checksum_mismatch(self, line):
"""Should prepare receiving resend request"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_resend()
@ddt.data(
# Marlin
"Error: No Checksum with line number, Last Line: 1",
# Repetier
"Error: Missing checksum",
)
def test_checksum_missing(self, line):
"""Should prepare receiving resend request"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_resend()
@ddt.data(
# Marlin
"Error: volume.init failed",
"Error: openRoot failed",
"Error: workDir open failed",
"Error: Cannot enter subdir: folder",
# Repetier
"Error: file.open failed",
# Marlin & Repetier (halleluja!)
"Error: error writing to file",
"Error: open failed, File: foo.gco",
# Legacy?
"Error: Cannot open foo.gco",
)
def test_sd_error(self, line):
"""Should pass"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_nop()
@ddt.data(
# Marlin
"Error: Unknown command: \"ABC\"",
# Repetier
"Error: Unknown command:ABC",
)
def test_unknown_command(self, line):
"""Should pass"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
self.assert_nop()
@ddt.data("Error: Printer on fire")
def test_other_error_disconnect(self, line):
"""Should trigger escalation"""
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
# what should have happened
self.assert_disconnected()
# what should not have happened
self.assert_not_handle_ok()
self.assert_not_last_comm_error()
self.assert_not_print_cancelled()
self.assert_not_cleared_to_send()
@ddt.data("Error: Printer on fire")
def test_other_error_cancel(self, line):
"""Should trigger print cancel"""
self._comm._disconnect_on_errors = False
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
# what should have happened
self.assert_print_cancelled()
self.assert_cleared_to_send()
# what should not have happened
self.assert_not_handle_ok()
self.assert_not_last_comm_error()
self.assert_not_disconnected()
@ddt.data("Error: Printer on fire")
def test_other_error_ignored(self, line):
"""Should only log"""
self._comm._ignore_errors = True
result = self._comm._handle_errors(line)
self.assertEqual(line, result)
# what should have happened
self.assert_cleared_to_send()
# what should not have happened
self.assert_not_handle_ok()
self.assert_not_last_comm_error()
self.assert_not_print_cancelled()
def test_not_an_error(self):
"""Should pass"""
result = self._comm._handle_errors("Not an error")
self.assertEqual("Not an error", result)
self.assert_nop()
def test_already_error(self):
"""Should pass"""
self._comm.isError.return_value = True
result = self._comm._handle_errors("Error: Printer on fire")
self.assertEqual("Error: Printer on fire", result)
self.assert_nop()
def test_line_none(self):
"""Should pass"""
self.assertIsNone(self._comm._handle_errors(None))
##~~ assertion helpers
def assert_handle_ok(self):
self._comm._handle_ok.assert_called_once()
def assert_not_handle_ok(self):
self._comm._handle_ok.assert_not_called()
def assert_last_comm_error(self):
self.assertIsNotNone(self._comm._lastCommError)
def assert_not_last_comm_error(self):
self.assertIsNone(self._comm._lastCommError)
def assert_disconnected(self):
self.assertIsNotNone(self._comm._errorValue)
self._comm._changeState.assert_called_once()
def assert_not_disconnected(self):
self.assertIsNone(self._comm._errorValue)
self._comm._changeState.assert_not_called()
def assert_print_cancelled(self):
self._comm.cancelPrint.assert_called_once()
def assert_not_print_cancelled(self):
self._comm.cancelPrint.assert_not_called()
def assert_cleared_to_send(self):
self._comm._clear_to_send.set.assert_called_once()
def assert_not_cleared_to_send(self):
self._comm._clear_to_send.set.assert_not_called()
def assert_nop(self):
self.assert_not_handle_ok()
self.assert_not_last_comm_error()
self.assert_not_disconnected()
self.assert_not_print_cancelled()
self.assert_not_cleared_to_send()
def assert_recoverable(self):
self.assert_handle_ok()
self.assert_not_last_comm_error()
self.assert_not_disconnected()
self.assert_not_print_cancelled()
self.assert_not_cleared_to_send()
def assert_resend(self):
self.assert_last_comm_error()
self.assert_not_handle_ok()
self.assert_not_disconnected()
self.assert_not_print_cancelled()
self.assert_not_cleared_to_send()
Binary file not shown.
File diff suppressed because it is too large. Load diff
+17 -6
View File
@@ -6,9 +6,9 @@
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: OctoPrint 1.3.6.dev192+ge9d17f0f.dirty\n"
"Project-Id-Version: OctoPrint 1.3.6rc2.dev10+g41eb9481\n"
"Report-Msgid-Bugs-To: i18n@octoprint.org\n"
"POT-Creation-Date: 2017-11-30 18:14+0100\n"
"POT-Creation-Date: 2017-12-05 12:29+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -349,6 +349,17 @@ msgid ""
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:9
#: src/octoprint/templates/snippets/settings/server/serverPluginBlacklistDescription.jinja2:7
#, python-format
msgid ""
"\n"
" By default, OctoPrint will use the blacklist hosted at "
"<code>plugins.octoprint.org/blacklist.json</code> which you\n"
" can also take a look at in a more human readable format <a "
"href=\"%(url)s\" target=\"_blank\">here</a>.\n"
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:14
msgid ""
"\n"
" Please decide whether to allow fetch and use of this centralized "
@@ -357,15 +368,15 @@ msgid ""
"Server right from within OctoPrint.\n"
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:15
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:20
msgid "Disable Plugin Blacklist Processing"
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:16
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:21
msgid "Enable Plugin Blacklist Processing"
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:20
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:25
msgid ""
"\n"
" Plugin blacklist processing is <strong class=\"text-"
@@ -373,7 +384,7 @@ msgid ""
" "
msgstr ""
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:23
#: src/octoprint/plugins/corewizard/templates/corewizard_pluginblacklist_wizard.jinja2:28
msgid ""
"\n"
" Plugin blacklist processing is <strong class=\"text-"