Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maintenance' into maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
foosel committed May 18, 2021
2 parents 5d326e9 + ac07c77 commit 1f4d22a
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 10 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ date of first contribution):
* [Yvan Rodrigues](https://github.com/TwoRedCells)
* [Elton Law](https://github.com/eltonlaw)
* ["sparxooo"](https://github.com/sparxooo)
* ["Stevil Knevil"](https://github.com/StevilKnevil)

OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
[Daid Braam](https://github.com/daid). Parts of its communication layer and
Expand Down
11 changes: 8 additions & 3 deletions docs/configuration/config_yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@ Use the following settings to configure the serial connection to the printer:
- M0
- M1
# Commands which should not be sent to the printer and just silently ignored.
# An example of when you may wish to use this could be useful if you wish to manually change a filament on M600,
# by using that as a Pausing command (below)
ignoredCommands:
# Commands which should cause OctoPrint to pause any ongoing prints.
pausingCommands:
- M0
Expand Down Expand Up @@ -904,9 +909,9 @@ Use the following settings to configure the server:
# Settings for further configuration of the cookies that OctoPrint sets (login, remember me, ...)
cookies:
# SameSite setting to use on the cookies. Possible values are None, Lax and Strict. Defaults to None but
# be advised that browsers will soon force this to Lax unless also being set as Secure and served over
# https, which will cause issues with embedding OctoPrint in frames.
# SameSite setting to use on the cookies. Possible values are None, Lax and Strict. Defaults to not set but
# be advised that many browsers now default to Lax unless set as Secure, explicitly setting the cookie type
# here and served over https, which causes issues with embedding OctoPrint in frames.
#
# See also https://www.chromestatus.com/feature/5088147346030592,
# https://www.chromestatus.com/feature/5633521622188032 and issue #3482
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,15 @@ $(function () {
}

OctoPrint.plugins.pluginmanager
.getRepository(!!options.refresh)
.getRepository(!!options.refresh, {ifModified: true})
.fail(function () {
deferred.reject();
})
.done(function (data) {
.done(function (data, status, xhr) {
// Don't update if cached - requires ifModified: true to pass through
// the 304 status, otherwise it fakes it and produces 200 all the time.
if (xhr.status === 304) return;

self.fromRepositoryResponse(data.repository);
self.online(data.online !== undefined ? data.online : true);
deferred.resolveWith(data);
Expand Down
7 changes: 6 additions & 1 deletion src/octoprint/server/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def getSettings():
"longRunningCommands": s.get(["serial", "longRunningCommands"]),
"checksumRequiringCommands": s.get(["serial", "checksumRequiringCommands"]),
"blockedCommands": s.get(["serial", "blockedCommands"]),
"ignoredCommands": s.get(["serial", "ignoredCommands"]),
"pausingCommands": s.get(["serial", "pausingCommands"]),
"emergencyCommands": s.get(["serial", "emergencyCommands"]),
"helloCommand": s.get(["serial", "helloCommand"]),
Expand Down Expand Up @@ -647,7 +648,7 @@ def _saveSettings(data):
if "runAt" in data["gcodeAnalysis"]:
s.set(["gcodeAnalysis", "runAt"], data["gcodeAnalysis"]["runAt"])
if "bedZ" in data["gcodeAnalysis"]:
s.setBoolean(["gcodeAnalysis", "bedZ"], data["gcodeAnalysis"]["bedZ"])
s.setFloat(["gcodeAnalysis", "bedZ"], data["gcodeAnalysis"]["bedZ"])

if "serial" in data:
if "autoconnect" in data["serial"]:
Expand Down Expand Up @@ -769,6 +770,10 @@ def _saveSettings(data):
data["serial"]["blockedCommands"], (list, tuple)
):
s.set(["serial", "blockedCommands"], data["serial"]["blockedCommands"])
if "ignoredCommands" in data["serial"] and isinstance(
data["serial"]["ignoredCommands"], (list, tuple)
):
s.set(["serial", "ignoredCommands"], data["serial"]["ignoredCommands"])
if "pausingCommands" in data["serial"] and isinstance(
data["serial"]["pausingCommands"], (list, tuple)
):
Expand Down
6 changes: 4 additions & 2 deletions src/octoprint/server/util/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,10 @@ def set_cookie(self, key, *args, **kwargs):
if samesite is not None:
samesite = samesite.lower()
if samesite == "none":
samesite = None
if samesite not in (None, "strict", "lax"):
# Must be string "None"
samesite = "None"
if samesite not in ("None", "strict", "lax"):
# If NoneType, the cookie is not set
samesite = None
kwargs["samesite"] = samesite

Expand Down
1 change: 1 addition & 0 deletions src/octoprint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def settings(init=False, basedir=None, configfile=None, overlays=None):
"blacklistedBaudrates": [],
"longRunningCommands": ["G4", "G28", "G29", "G30", "G32", "M400", "M226", "M600"],
"blockedCommands": ["M0", "M1"],
"ignoredCommands": [],
"pausingCommands": ["M0", "M1", "M25"],
"emergencyCommands": ["M112", "M108", "M410"],
"checksumRequiringCommands": ["M110"],
Expand Down
7 changes: 7 additions & 0 deletions src/octoprint/static/js/app/viewmodels/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ $(function () {
self.serial_longRunningCommands = ko.observable(undefined);
self.serial_checksumRequiringCommands = ko.observable(undefined);
self.serial_blockedCommands = ko.observable(undefined);
self.serial_ignoredCommands = ko.observable(undefined);
self.serial_pausingCommands = ko.observable(undefined);
self.serial_emergencyCommands = ko.observable(undefined);
self.serial_helloCommand = ko.observable(undefined);
Expand Down Expand Up @@ -1058,6 +1059,9 @@ $(function () {
blockedCommands: function () {
return splitTextToArray(self.serial_blockedCommands(), ",", true);
},
ignoredCommands: function () {
return splitTextToArray(self.serial_ignoredCommands(), ",", true);
},
pausingCommands: function () {
return splitTextToArray(self.serial_pausingCommands(), ",", true);
},
Expand Down Expand Up @@ -1260,6 +1264,9 @@ $(function () {
blockedCommands: function (value) {
self.serial_blockedCommands(value.join(", "));
},
ignoredCommands: function (value) {
self.serial_ignoredCommands(value.join(", "));
},
pausingCommands: function (value) {
self.serial_pausingCommands(value.join(", "));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@
<span class="help-inline">{{ _('Use this to specify commands that should never be sent to the printer. Just the G or M code, comma separated. Defaults to <code>M0</code> and <code>M1</code> since most firmware will block until a button on the controller has been pressed if it receives either of those two commands.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialIgnoredCommands">{{ _('Ignored commands') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialIgnoredCommands" data-bind="value: serial_ignoredCommands">
<span class="help-inline">{{ _('Use this to specify commands that should be silently ignored and never be sent to the printer. Just the G or M code, comma separated. Unlike blocked commands above, there will be no warning popup when these commands are encountered.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="settings-serialPausingCommands">{{ _('Pausing commands') }}</label>
<div class="controls">
Expand Down
2 changes: 1 addition & 1 deletion src/octoprint/translations/de/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -5852,7 +5852,7 @@ msgid "\n"
" web interface now by clicking the button below.\n"
" "
msgstr "\n"
" Die Serverversion hat sich geändert, ein Neuladen des Webinterfaces ist notwendig. Das wird evtl. laufenden Printjobs nicht unterbrechen. Bitte lade das Webinterface jetzt neu, indem du auf den Button unten klickst."
" Die Serverversion hat sich geändert, ein Neuladen des Webinterfaces ist notwendig. Das wird evtl. laufende Printjobs nicht unterbrechen. Bitte lade das Webinterface jetzt neu, indem du auf den Button unten klickst."

#: src/octoprint/templates/sidebar/connection.jinja2:8
msgid "Save connection settings"
Expand Down
16 changes: 16 additions & 0 deletions src/octoprint/util/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def __init__(
["serial", "checksumRequiringCommands"]
)
self._blocked_commands = settings().get(["serial", "blockedCommands"])
self._ignored_commands = settings().get(["serial", "ignoredCommands"])
self._pausing_commands = settings().get(["serial", "pausingCommands"])
self._emergency_commands = settings().get(["serial", "emergencyCommands"])
self._sanity_check_tools = settings().getBoolean(["serial", "sanityCheckTools"])
Expand Down Expand Up @@ -5311,6 +5312,21 @@ def _command_phase_queuing(
},
)
return (None,)
if gcode in self._ignored_commands:
message = "Not sending {} to printer, it's configured as an ignored command".format(
gcode
)
self._log("Info: " + message)
self._logger.info(message)
eventManager().fire(
Events.COMMAND_SUPPRESSED,
{
"command": cmd,
"message": message,
"severity": "info",
},
)
return (None,)

def _command_phase_sending(
self, cmd, cmd_type=None, gcode=None, subcode=None, *args, **kwargs
Expand Down
2 changes: 1 addition & 1 deletion tests/server/util/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def tearDown(self):

@data(
[None, None, False, None, None],
[None, None, False, "none", None],
[None, None, False, "none", "None"],
[None, None, False, "lax", "lax"],
[None, None, False, "StRiCt", "strict"],
[None, None, False, "INVALID", None],
Expand Down

0 comments on commit 1f4d22a

Please sign in to comment.