Compare commits

...
Author SHA1 Message Date
Gina Häußge e14c00f135 Revert "Updated several dependencies to current version"
This reverts commit 4ed5f7e

The updates cause issues on very old python environments (distribute
instead of setuptools, e.g. OctoPi 0.12) due to new package formats.

We'll postpone them to 1.3.11, since OctoPrint 1.3.10 will then refuse
to upgrade in such environments anyhow.
2018-11-05 14:25:10 +01:00
Gina Häußge b0a4a49f99 Changelog for 1.3.10rc1 2018-11-05 13:18:05 +01:00
Gina Häußge 5b4839369e appkeys: Probe endpoint to check for workflow support
Also adjusted docs and js client lib accordingly.
2018-11-05 12:50:05 +01:00
Gina Häußge 1ff02b9f1c Update bundled German translation 2018-11-05 11:59:48 +01:00
Gina Häußge e2c1fa3d43 Appkeys: request creation should respond with 201 2018-11-02 17:04:58 +01:00
Gina Häußge 39a466e316 Appkeys: Make timeout thread safe 2018-11-02 12:53:30 +01:00
Gina Häußge 9e940eacc3 Merge branch 'fix_appkey_orphan_dialogs' of https://github.com/fieldOfView/OctoPrint into pr/2869 2018-11-02 12:27:16 +01:00
Gina Häußge 2e38f237de Fix cancel snippet for shared nozzle setups
See https://discourse.octoprint.org/t/prusa-mmu2-how-to-properly-configure/4937/
2018-11-02 12:20:05 +01:00
fieldOfView 7f36ffdafd Expire request_access when the client stops polling 2018-11-02 11:04:06 +01:00
Gina Häußge 39b2da3230 Merge pull request #2868 from gdombiak/extrude_speed2
Documentation fixed and extrusion speed value check
2018-11-02 10:52:42 +01:00
fieldOfView c489829efb Add myself to AUTHORS.md
because it's a requirement for a PR
2018-11-02 09:31:56 +01:00
fieldOfView e30e129e2a Close request_access dialogs on other open connections when a decision is made
Once a decision is made on one connection (browser window), dialogs on other connections are no longer relevant.
2018-11-02 09:22:30 +01:00
Gaston Dombiak 32d5b25013 Removed unnecessary variable initialization 2018-11-01 21:44:42 -07:00
Gaston Dombiak 6227a0dfb9 1) Fixed documentation about speed unit and 2) extrusion speed is now limited to printer profile max value 2018-10-31 20:45:56 -07:00
Gina Häußge e234c6146e Better detection of ipv6 support
Apparently socket.has_ipv6 doesn't actually do what it says in the docs
(state whether the underlying platform supports ipv6). It returns True
even when ipv6 has manually been disabled for whatever reason. So we
will no longer trust this but instead attempt to actually create a v6
socket and only if that succeeds assume that v6 is indeed supported on
the platform.
2018-10-31 13:39:54 +01:00
Gina Häußge c146731e5a Merge pull request #2865 from gdombiak/extrude_speed
Extrude speed
2018-10-31 11:58:28 +01:00
Gina Häußge 5ee242be4a Fix doc bug: mm/s => mm/min 2018-10-31 11:54:17 +01:00
Gaston Dombiak 556878a774 Merge branch 'maintenance' into extrude_speed 2018-10-30 19:09:05 -07:00
Gaston Dombiak 00aa4876e9 Added support to specify extrude/retract speed. Only at REST API. No UI changes were made 2018-10-30 19:01:20 -07:00
Gina Häußge 2f89082df2 Missed something in yesterday's changes to contrib guide 2018-10-19 13:14:52 +02:00
Gina Häußge 108db045ce Small changes to the contribution guidelines
* allow PRs against `maintenance` branch for improvements and small
    new features
  * suggest getting in touch on the forum for larger changes
2018-10-18 18:06:01 +02:00
20 changed files with 4495 additions and 5875 deletions

No files matched your search

+2
View File
@@ -91,7 +91,9 @@ date of first contribution):
* [Ganey](https://github.com/ganey)
* [Sven Lohrmann](https://github.com/malnvenshorn)
* [Andy Castille](https://github.com/klikini)
* [Gaston Dombiak](https://github.com/gdombiak)
* [Brad Fisher](https://github.com/bradcfisher)
* [Aldo Hoeben](https://github.com/fieldofview)
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
+91 -1015
View File
File diff suppressed because it is too large. Load diff
+3 -1
View File
@@ -219,7 +219,7 @@ Issue a print head command
axes values are relative amounts) or to absolute position (provided axes values are coordinates)
* ``speed``: Optional. Speed at which to move. If not provided, minimum speed for all selected axes from printer
profile will be used. If provided but ``false``, no speed parameter will be appended to the command. Otherwise
interpreted as an integer signifying the speed in mm/s, to append to the command.
interpreted as an integer signifying the speed in mm/min, to append to the command.
home
Homes the print head in all of the given axes. Additional parameters are:
@@ -362,6 +362,8 @@ Issue a tool command
Extrudes the given amount of filament from the currently selected tool. Additional parameters:
* ``amount``: The amount of filament to extrude in mm. May be negative to retract.
* ``speed``: Optional. Speed at which to extrude. If not provided, maximum speed for E axis from printer
profile will be used. Otherwise interpreted as an integer signifying the speed in mm/min, to append to the command.
flowrate
Changes the flow rate factor to apply to extrusion of the tool.
+57 -25
View File
@@ -40,15 +40,18 @@ of the following steps:
1. The User opens the App and gets prompted to enter or select an instance URL. Optionally (recommended!) the User also
enters their username which is also their user ID into the App.
2. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
2. The App :ref:`probes for workflow support <sec-bundledplugins-appkeys-api-probe>` on the Server. If this request
doesn't get an HTTP :http:statuscode:`204` the App needs to direct the user to an alternative manual workflow
(copy-paste API key) and abort this one. Otherwise it proceeds to the next step.
3. The App sends a :ref:`key request <sec-bundledplugins-appkey-datamodel-keyrequest>` to the Server to start the
authorization process.
3. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
4. The Server triggers a confirmation dialog for the User on the Webinterface and returns an endpoint to the
App to poll for a decision in the ``Location`` header of an HTTP :http:statuscode:`201`.
4. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
5. The App uses the obtained request specific endpoint to poll for a decision every second. An HTTP :http:statuscode:`202`
signals that no decision has been made yet.
5. The User either accepts or denies the access request which makes the Webinterface send a
6. The User either accepts or denies the access request which makes the Webinterface send a
:ref:`decision request <sec-bundledplugins-appkey-datamodel-decisionrequest>` to the Server.
6. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
7. If the User accepted the request, the App receives an HTTP :http:statuscode:`200` with an attached
:ref:`API key response <sec-bundledplugins-appkey-datamodel-keyresponse>`. If they deny it, the App will receive
an HTTP :http:statuscode:`404`.
@@ -61,31 +64,35 @@ of the following steps:
participant Webinterface
participant Server
note over User, Server: Step 1 & 2
note over User, Server: Step 1, 2 & 3
User->>App: enters URL of instance to connect to
User->>App: enters URL of instance to connect to and optional user_id
App->>Server: GET /plugin/appkeys/probe
alt Workflow unsupported
Server->>App: 404
App->>User: alternative workflow, copy-paste key manually
else Workflow supported
alt Limit to specific user
User->>App: enters user_id
App->>Server: POST /plugin/appkeys/request, (app_name, user_id)
else
App->>Server: POST /plugin/appkeys/request, (app_name)
end
note over User, Server: Step 3
note over User, Server: Step 4
Server-->>Webinterface: plugin message for "appkeys" w/ (app_name, user_token, user_id)
Webinterface-->>User: Display confirmation dialog
Server->>App: 201, Location: /plugin/appkeys/request/<app_token>
note over User, Server: Step 4
note over User, Server: Step 5
loop
loop Poll for decision
App->>Server: GET /plugin/appkeys/request/<app_token>
Server->>App: 202
end
note over User, Server: Step 5 & 6
note over User, Server: Step 6 & 7
alt User accepts
@@ -105,11 +112,27 @@ of the following steps:
end
end
.. _sec-bundledplugins-appkeys-api:
API
---
.. _sec-bundledplugins-appkeys-api-probe:
Probe for workflow support
..........................
.. http:get:: /plugin/appkeys/probe
Probes for support of the workflow.
Normally returns an HTTP :http:statuscode:`204`, indicating workflow availability. If a different status code is returned
(usually an HTTP :http:statuscode:`404`), the plugin is disabled or not installed. Fall back to manual api key exchange.
:status 204: the workflow is supported
.. _sec-bundledplugins-appkeys-api-startauthprocess:
Start authorization process
@@ -131,12 +154,6 @@ Start authorization process
it in the ``user`` parameter. OctoPrint will then only display the authorization request on browsers the user ``me``
is logged in on.
.. note::
If this endpoint produces an HTTP :http:statuscode:`404` and the instance URL is correct, the bundled
Application Keys Plugin has in all likelihood been disabled by the user. Fall back on manual API key copy-pasting
by the user.
:json app: application identifier to use for the request, case insensitive
:json user: optional user id to restrict the decision to the specified user
:status 201: authorization process started, polling URL to query can be found in ``Location`` header
@@ -154,6 +171,11 @@ Poll for decision on existing request
a :ref:`Key response <sec-bundledplugins-appkey-datamodel-keyresponse>` if access has been granted and an
HTTP :http:statuscode:`404` if the request has been denied or timed out.
.. note::
The request will be considered stale and deleted internally if the polling endpoint for it isn't called
for more than 5s.
:status 200: access granted, API key in response body
:status 202: no decision has been made yet, continue polling
:status 404: access denied or request timed out
@@ -452,6 +474,15 @@ JavaScript Client Library
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.probe(opts)
Probes for workflow support.
See :ref:`Probe for workflow support <sec-bundledplugins-appkeys-api-probe>` for more details.
:param object opts: Additional options for the request
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
.. js:function:: OctoPrintClient.plugins.appkeys.request(app, opts)
Starts a new authorization request for the provided ``app`` identifier.
@@ -481,9 +512,10 @@ JavaScript Client Library
.. js:function:: OctoPrintClient.plugins.appkeys.authenticate(app, user, opts)
Convenience function that issues a request and then automatically starts polling for a decision on the returned
polling endpoint every 1s, until either a positive or negative decision is returned. On success the returned
promise is resolved with the generated API key as argument.
Convenience function that probes for support, issues a request and then automatically starts polling for a decision
on the returned polling endpoint every 1s, until either a positive or negative decision is returned. On success the
returned promise is resolved with the generated API key as argument. If anything goes wrong or there is no support
for the workflow, the promise is rejected.
**Example usage**
+4
View File
@@ -157,9 +157,13 @@ The ``disable_hotends`` snippet is defined as follows:
.. code-block:: jinja
:caption: Default ``disable_hotends`` snippet
{% if printer_profile.extruder.sharedNozzle %}
M104 T0 S0
{% else %}
{% for tool in range(printer_profile.extruder.count) %}
M104 T{{ tool }} S0
{% endfor %}
{% endif %}
The ``disable_bed`` snippet is defined as follows:
+32 -36
View File
@@ -17,47 +17,43 @@ PYTHON_REQUIRES = ">=2.7.3,<3" # TODO change to >=2.7.9,<3 in 1.3.11
# Requirements for our application
INSTALL_REQUIRES = [
# the following dependencies are non trivial to update since later versions introduce backwards incompatible
# changes that might affect plugins, or due to other observed problems
"flask>=0.10.1,<0.11", # newer versions require newer Jinja versions
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
"tornado==4.5.3", # a memory leak was observed in tornado >= 5, see #2585
"Flask-Login>=0.2.11,<0.3", # some functions changed to properties in 0.3
# anything below this should be checked on releases for new versions
"Flask-Principal>=0.4,<0.5",
"Flask-Babel>=0.12,<0.13",
"Flask-Assets>=0.12,<0.13",
"werkzeug>=0.14.1,<0.15",
"PyYAML>=3.13,<4",
"markdown>=3.0,<3.1",
"flask>=0.10.1,<0.11",
"Jinja2>=2.8.1,<2.9", # Jinja 2.9 has breaking changes WRT template scope - we can't
# guarantee backwards compatibility for plugins and such with that
# version, hence we need to pin to a lower version for now. See #1697
"werkzeug>=0.8.3,<0.9",
"tornado==4.5.3",
#"sockjs-tornado>=1.0.3,<1.1", # current version is incompatible to tornado 5, we use a
# vendored one
"PyYAML>=3.10,<3.11",
"Flask-Login>=0.2.11,<0.3",
"Flask-Principal>=0.3.5,<0.4",
"Flask-Babel>=0.9,<0.10",
"Flask-Assets>=0.10,<0.11",
"markdown>=2.6.9,<2.7",
"pyserial>=3.4,<3.5",
"netaddr>=0.7.19,<0.8",
"watchdog>=0.9.0,<0.10",
"watchdog>=0.8.3,<0.9",
"sarge==0.1.5post0",
"netifaces>=0.10.7,<0.11",
"pylru>=1.1,<1.2",
"rsa>=4.0,<5",
"netifaces>=0.10.6,<0.11",
"pylru>=1.0.9,<1.1",
"rsa>=3.2.3,<3.3",
"pkginfo>=1.4.2,<1.5",
"requests>=2.20.0,<3",
"semantic_version>=2.6,<2.7",
"psutil>=5.4.8,<5.5",
"Click>=7,<8",
"requests>=2.18.4,<3",
"semantic_version>=2.4.2,<2.5",
"psutil>=5.4.6,<5.5",
"Click>=6.2,<6.3",
"awesome-slugify>=1.6.5,<1.7",
"feedparser>=5.2.1,<5.3",
"chainmap>=1.0.2,<1.1",
"future>=0.17,<0.18",
"scandir>=1.9,<1.10",
"websocket-client>=0.53,<0.54",
"python-dateutil>=2.7.5,<2.8",
"future>=0.15.2,<0.16",
"scandir>=1.3,<1.4",
"websocket-client>=0.40.0,<0.41",
"python-dateutil>=2.6.1,<2.7",
"wrapt>=1.10.11,<1.11",
"futures>=3.2,<3.3",
"emoji>=0.5.1,<0.6",
"monotonic>=1.5,<1.6",
"futures>=3.1.1,<3.2",
"emoji>=0.4.5,<0.5",
"monotonic>=1.3,<1.4",
"frozendict>=1.2,<1.3"
]
@@ -70,11 +66,11 @@ EXTRA_REQUIRES = dict(
develop=[
# Testing dependencies
"mock>=2.0.0,<3",
"nose>=1.3.7,<1.4",
"nose>=1.3.0,<1.4",
"ddt",
# Documentation dependencies
"sphinx>=1.8.1,<1.9",
"sphinx>=1.6,<1.7",
"sphinxcontrib-httpdomain",
"sphinxcontrib-mermaid>=0.3",
"sphinx_rtd_theme",
@@ -82,7 +78,7 @@ EXTRA_REQUIRES = dict(
# Dependencies for developing OctoPrint plugins
plugins=[
"cookiecutter>=1.6,<1.7"
"cookiecutter>=1.4,<1.7"
]
)
+44 -12
View File
@@ -15,24 +15,28 @@ import octoprint.plugin
from octoprint.settings import valid_boolean_trues
from octoprint.server.util.flask import restricted_access, no_firstrun_access
from octoprint.server import NO_CONTENT, current_user, admin_permission
from octoprint.util import atomic_write, monotonic_time
from octoprint.util import atomic_write, monotonic_time, ResettableTimer
CUTOFF_TIME = 10 * 60 # 10min
POLL_TIMEOUT = 5 # 5 seconds
class AppAlreadyExists(Exception):
pass
class PendingDecision(object):
def __init__(self, app_id, app_token, user_id, user_token):
def __init__(self, app_id, app_token, user_id, user_token, timeout_callback=None):
self.app_id = app_id
self.app_token = app_token
self.user_id = user_id
self.user_token = user_token
self.created = monotonic_time()
if callable(timeout_callback):
self.poll_timeout = ResettableTimer(POLL_TIMEOUT, timeout_callback, [user_token])
self.poll_timeout.start()
def external(self):
return dict(app_id=self.app_id,
user_id=self.user_id,
@@ -107,6 +111,11 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
##~~ BlueprintPlugin mixin
@octoprint.plugin.BlueprintPlugin.route("/probe", methods=["GET"])
@no_firstrun_access
def handle_probe(self):
return NO_CONTENT
@octoprint.plugin.BlueprintPlugin.route("/request", methods=["POST"])
@no_firstrun_access
def handle_request(self):
@@ -126,14 +135,18 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
user_token=user_token,
user_id=user_id))
response = flask.jsonify(app_token=app_token)
response.status_code = 202
response.status_code = 201
response.headers["Location"] = flask.url_for(".handle_decision_poll", app_token=app_token, _external=True)
return response
@octoprint.plugin.BlueprintPlugin.route("/request/<app_token>")
@no_firstrun_access
def handle_decision_poll(self, app_token):
if self._is_pending(app_token):
result = self._get_pending_by_app_token(app_token)
if result:
for pending_decision in result:
pending_decision.poll_timeout.reset()
response = flask.jsonify(message="Awaiting decision")
response.status_code = 202
return response
@@ -157,6 +170,12 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
if not result:
return flask.abort(404)
# Close access_request dialog for this request on all open OctoPrint connections
self._plugin_manager.send_plugin_message(self._identifier, dict(
type="end_request",
user_token=user_token
))
return NO_CONTENT
def is_blueprint_protected(self):
@@ -179,7 +198,7 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
keys = self._api_keys_for_user(user_id)
return flask.jsonify(keys=map(lambda x: x.external(), keys),
pending=dict((x.user_token, x.external()) for x in self._get_pending(user_id)))
pending=dict((x.user_token, x.external()) for x in self._get_pending_by_user_id(user_id)))
def on_api_command(self, command, data):
user_id = current_user.get_name()
@@ -221,20 +240,21 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
with self._pending_lock:
self._remove_stale_pending()
self._pending_decisions.append(PendingDecision(app_name, app_token, user_id, user_token))
self._pending_decisions.append(PendingDecision(app_name, app_token, user_id, user_token,
timeout_callback=self._expire_pending))
return app_token, user_token
def _is_pending(self, app_token):
def _get_pending_by_app_token(self, app_token):
result = []
with self._pending_lock:
self._remove_stale_pending()
for data in self._pending_decisions:
if data.app_token == app_token:
return True
result.append(data)
return result
return False
def _get_pending(self, user_id):
def _get_pending_by_user_id(self, user_id):
result = []
with self._pending_lock:
self._remove_stale_pending()
@@ -243,6 +263,18 @@ class AppKeysPlugin(octoprint.plugin.AssetPlugin,
result.append(data)
return result
def _expire_pending(self, user_token):
with self._pending_lock:
len_before = len(self._pending_decisions)
self._pending_decisions = filter(lambda x: x.user_token != user_token, self._pending_decisions)
len_after = len(self._pending_decisions)
if len_after < len_before:
self._plugin_manager.send_plugin_message(self._identifier, dict(
type="end_request",
user_token=user_token
))
def _remove_stale_pending(self):
with self._pending_lock:
cutoff = monotonic_time() - CUTOFF_TIME
@@ -29,6 +29,10 @@
return this.base.postJson(this.base.getBlueprintUrl("appkeys") + "decision/" + token, {decision: !!decision}, opts);
};
OctoPrintAppKeysClient.prototype.probe = function(opts) {
return this.base.get(this.base.getBlueprintUrl("appkeys") + "probe", opts);
};
OctoPrintAppKeysClient.prototype.request = function(app, opts) {
return this.requestForUser(app, undefined, opts);
};
@@ -45,37 +49,44 @@
var deferred = $.Deferred();
var client = this;
client.requestForUser(app, user)
.done(function(response) {
var token = response.app_token;
if (!token) {
// no token received, something went wrong
deferred.reject();
return;
}
var interval = 1000;
var poll = function() {
client.checkDecision(token)
.done(function(response) {
if (response.api_key) {
// got a decision, resolve the promise
deferred.resolve(response.api_key);
} else {
// no decision yet, poll a bit more
deferred.notify();
window.setTimeout(poll, interval);
}
})
.fail(function() {
// something went wrong
client.probe()
.done(function() {
client.requestForUser(app, user)
.done(function(response) {
var token = response.app_token;
if (!token) {
// no token received, something went wrong
deferred.reject();
});
};
window.setTimeout(poll, interval);
return;
}
var interval = 1000;
var poll = function() {
client.checkDecision(token)
.done(function(response) {
if (response.api_key) {
// got a decision, resolve the promise
deferred.resolve(response.api_key);
} else {
// no decision yet, poll a bit more
deferred.notify();
window.setTimeout(poll, interval);
}
})
.fail(function() {
// something went wrong
deferred.reject();
});
};
window.setTimeout(poll, interval);
})
.fail(function() {
// something went wrong
deferred.reject();
});
})
.fail(function() {
// something went wrong
// workflow unsupported
deferred.reject();
});
+3 -1
View File
@@ -231,12 +231,14 @@ class PrinterInterface(object):
"""
raise NotImplementedError()
def extrude(self, amount, tags=None, *args, **kwargs):
def extrude(self, amount, speed=None, tags=None, *args, **kwargs):
"""
Extrude ``amount`` millimeters of material from the tool.
Arguments:
amount (int, float): The amount of material to extrude in mm
speed (int, None): Speed at which to extrude (F parameter). If set to ``None`` (or left out)
the maximum speed of E axis from the printer profile will be used.
tags (set of str): An optional set of tags to attach to the command(s) throughout their lifecycle
"""
raise NotImplementedError()
+12 -2
View File
@@ -361,12 +361,22 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_axes)), "G90"],
tags=kwargs.get("tags", set) | {"trigger:printer.home"})
def extrude(self, amount, *args, **kwargs):
def extrude(self, amount, speed=None, *args, **kwargs):
if not isinstance(amount, (int, long, float)):
raise ValueError("amount must be a valid number: {amount}".format(amount=amount))
printer_profile = self._printerProfileManager.get_current_or_default()
extrusion_speed = printer_profile["axes"]["e"]["speed"]
# Use specified speed (if any)
max_e_speed = printer_profile["axes"]["e"]["speed"]
if speed is None:
# No speed was specified so default to value configured in printer profile
extrusion_speed = max_e_speed
else:
# Make sure that specified value is not greater than maximum as defined in printer profile
extrusion_speed = min([speed, max_e_speed])
self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"],
tags=kwargs.get("tags", set()) | {"trigger:printer.extrude"})
-1
View File
@@ -242,7 +242,6 @@ class Server(object):
# monkey patch a bunch of stuff
util.tornado.fix_json_encode()
util.flask.fix_flask_jsonify()
util.flask.enable_additional_translations(additional_folders=[self._settings.getBaseFolder("translations")])
# setup app
+2 -1
View File
@@ -129,9 +129,10 @@ def printerToolCommand():
return make_response("Printer is currently printing", 409)
amount = data["amount"]
speed = data.get("speed", None)
if not isinstance(amount, (int, long, float)):
return make_response("Not a number for extrusion amount: %r" % amount, 400)
printer.extrude(amount, tags=tags)
printer.extrude(amount, speed=speed, tags=tags)
elif command == "flowrate":
factor = data["factor"]
-26
View File
@@ -251,32 +251,6 @@ def fix_flask_login_remote_address():
flask_login._get_remote_addr = fixed_get_remote_addr
def fix_flask_jsonify():
def fixed_jsonify(*args, **kwargs):
"""Backported from https://github.com/pallets/flask/blob/7e714bd28b6e96d82b2848b48cf8ff48b517b09b/flask/json/__init__.py#L257"""
from flask.json import current_app, dumps
indent = None
separators = (',', ':')
if current_app.config['JSONIFY_PRETTYPRINT_REGULAR'] or current_app.debug:
indent = 2
separators = (', ', ': ')
if args and kwargs:
raise TypeError('jsonify() behavior undefined when passed both args and kwargs')
elif len(args) == 1: # single args are passed directly to dumps()
data = args[0]
else:
data = args or kwargs
return current_app.response_class(
dumps(data, indent=indent, separators=separators) + '\n',
mimetype='application/json'
)
flask.jsonify = fixed_jsonify
#~~ WSGI environment wrapper for reverse proxying
class ReverseProxiedEnvironment(object):
+1 -1
View File
@@ -355,7 +355,7 @@ default_settings = {
"gcode": {
"afterPrintCancelled": "; disable motors\nM84\n\n;disable all heaters\n{% snippet 'disable_hotends' %}\n{% snippet 'disable_bed' %}\n;disable fan\nM106 S0",
"snippets": {
"disable_hotends": "{% for tool in range(printer_profile.extruder.count) %}M104 T{{ tool }} S0\n{% endfor %}",
"disable_hotends": "{% if printer_profile.extruder.sharedNozzle %}M104 T0 S0\n{% else %}{% for tool in range(printer_profile.extruder.count) %}M104 T{{ tool }} S0\n{% endfor %}{% endif %}",
"disable_bed": "{% if printer_profile.heatedBed %}M140 S0\n{% endif %}"
}
}
File diff suppressed because it is too large. Load diff
+21 -2
View File
@@ -9,7 +9,26 @@ import sys
import netaddr
import netifaces
HAS_V6 = socket.has_ipv6
_cached_check_v6 = None
def check_v6():
global _cached_check_v6
def f():
if not socket.has_ipv6:
return False
try:
socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
except:
# "[Errno 97] Address family not supported by protocol" or anything else really...
return False
return True
if _cached_check_v6 is None:
_cached_check_v6 = f()
return _cached_check_v6
HAS_V6 = check_v6()
if hasattr(socket, "IPPROTO_IPV6") and hasattr(socket, "IPV6_V6ONLY"):
# Dual stack support, hooray!
@@ -21,7 +40,7 @@ else:
IPPROTO_IPV6 = 41
IPV6_V6ONLY = 27
else:
# Whatever we are running on here, it we don't want to use V6 on here due to lack of dual stack support
# Whatever we are running on here, we don't want to use V6 on here due to lack of dual stack support
HAS_V6 = False
def is_lan_address(address, additional_private=None):
Binary file not shown.
File diff suppressed because it is too large. Load diff
+1030 -414
View File
File diff suppressed because it is too large. Load diff