Merge branch 'staging/maintenance' into maintenance

This commit is contained in:
Gina Häußge committed 2020-11-16 14:18:56 +01:00
commit 83f488d1d2
21 files changed
+538 -298

No files matched your search

+1
View File
@@ -2,6 +2,7 @@
# Switch to black formatting
1f93b2355a2816918e11a55e61b42010d15a6720
5f2a95d154650366078b0d387e5b01427c4340c0
# Switch to prettier formatting
6b44909f21ee39237b7504cd31ffa6cf28275c33
+1 -1
View File
@@ -38,7 +38,7 @@ repos:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: https://github.com/prettier/prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: master
hooks:
- id: prettier
+1 -8
View File
@@ -63,7 +63,7 @@ For information about how to go about submitting bug reports or pull requests, p
Installation instructions for installing from source for different operating
systems can be found [on the forum](https://community.octoprint.org/tags/c/support/guides/15/setup).
If you want to run OctoPrint on a Raspberry Pi, you might want to take a look at [OctoPi](https://github.com/guysoft/OctoPi)
If you want to run OctoPrint on a Raspberry Pi, you really should take a look at [OctoPi](https://github.com/guysoft/OctoPi)
which is a custom SD card image that includes OctoPrint plus dependencies.
The generic steps that should basically be done regardless of operating system
@@ -76,13 +76,6 @@ you already have Python 2.7, 3.6 or 3.7, pip and virtualenv and their dependenci
parameter, e.g. `virtualenv --python=python3 venv`.
2. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install OctoPrint`
Or alternatively, for an install from source:
1. Checkout OctoPrint: `git clone https://github.com/OctoPrint/OctoPrint.git`
2. Change into the OctoPrint folder: `cd OctoPrint`
3. Create a user-owned virtual environment therein: `virtualenv venv`
4. Install OctoPrint *into that virtual environment*: `./venv/bin/pip install .`
You may then start the OctoPrint server via `/path/to/OctoPrint/venv/bin/octoprint`, see [Usage](#usage)
for details.
+4
View File
@@ -162,6 +162,10 @@ Resend stats
- 1
- int
- Number of resend requests received since connecting.
* - ``transmitted``
- 1
- int
- Number of transmitted lines since connecting.
* - ``ratio``
- 1
- int
+4 -3
View File
@@ -24,9 +24,6 @@ Use the following settings to enable access control:
.. code-block:: yaml
accessControl:
# whether to enable access control or not. Defaults to true
enabled: true
# The user manager implementation to use for accessing user information. Currently only a filebased
# user manager is implemented which stores configured accounts in a YAML file (Default: users.yaml
# in the default configuration folder, see below)
@@ -75,6 +72,10 @@ Use the following settings to enable access control:
# If a remote user is not found, add them. Use this only if all users from the remote system can use OctoPrint.
addRemoteUsers: false
# Secret salt used for password hashing, DO NOT TOUCH. If changed you will no longer be able to log in with your
# existing accounts.
salt: someSecretSalt
.. _sec-configuration-config_yaml-api:
API
+1 -1
View File
@@ -75,7 +75,7 @@ INSTALL_REQUIRES_PYTHON2 = [
"scandir>=1.10,<2",
"chainmap>=1.0.3,<2",
"typing>=3.7.4.1,<4",
"enum34>=1.1.10",
"enum34>=1.1.10,<1.2",
]
# Python 3 specific requirements
+18 -2
View File
@@ -502,6 +502,8 @@ class FilebasedUserManager(UserManager):
def __init__(self, group_manager, path=None, settings=None):
UserManager.__init__(self, group_manager, settings=settings)
self._logger = logging.getLogger(__name__)
if path is None:
path = self._settings.get(["accessControl", "userfile"])
if path is None:
@@ -517,10 +519,19 @@ class FilebasedUserManager(UserManager):
def _load(self):
if os.path.exists(self._userfile) and os.path.isfile(self._userfile):
self._customized = True
# noinspection PyBroadException
with io.open(self._userfile, "rt", encoding="utf-8") as f:
data = yaml.safe_load(f)
if not data or not isinstance(data, dict):
self._logger.fatal(
"{} does not contain a valid map of users. Fix "
"the file, or remove it, then restart OctoPrint.".format(
self._userfile
)
)
raise CorruptUserStorage()
for name, attributes in data.items():
if not isinstance(attributes, dict):
continue
@@ -570,6 +581,7 @@ class FilebasedUserManager(UserManager):
if self._dirty:
self._save()
self._customized = True
else:
self._customized = False
@@ -1008,10 +1020,14 @@ class UnknownUser(Exception):
class UnknownRole(Exception):
def _init_(self, role):
def __init__(self, role):
Exception.__init__(self, "Unknown role: %s" % role)
class CorruptUserStorage(Exception):
pass
##~~ Refactoring helpers
+9 -2
View File
@@ -11,7 +11,12 @@ import click
from octoprint import init_settings
from octoprint.access.groups import FilebasedGroupManager
from octoprint.access.users import FilebasedUserManager, UnknownUser, UserAlreadyExists
from octoprint.access.users import (
CorruptUserStorage,
FilebasedUserManager,
UnknownUser,
UserAlreadyExists,
)
from octoprint.cli import get_ctx_obj_option
from octoprint.util import get_class, sv
@@ -63,6 +68,8 @@ def user(ctx):
try:
clazz = get_class(name)
user_manager = clazz(group_manager=group_manager, settings=settings)
except CorruptUserStorage:
raise
except Exception:
click.echo(
"Could not instantiate user manager {}, falling back to FilebasedUserManager!".format(
@@ -76,7 +83,7 @@ def user(ctx):
except Exception:
click.echo("Could not instantiate user manager", err=True)
return
ctx.exit(-1)
@user.command(name="list")
+1 -1
View File
@@ -643,7 +643,7 @@ class LocalFileStorage(StorageInterface):
for key, node in nodes.items():
if node["type"] == "folder":
node = copy.copy(node)
node["children"] = []
node["children"] = {}
result[key] = node
return result
+3 -1
View File
@@ -501,7 +501,6 @@ class BackupPlugin(
backup_file,
exclude=exclude,
settings=settings,
logger=self._logger,
plugin_manager=cli_group.plugin_manager,
datafolder=datafolder,
)
@@ -839,6 +838,9 @@ class BackupPlugin(
on_backup_done=None,
on_backup_error=None,
):
if logger is None:
logger = logging.getLogger(__name__)
exclude_by_default = (
"generated",
"logs",
+2 -1
View File
@@ -1149,9 +1149,10 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
def _updateResendDataCallback(self):
if not self._comm:
return self._dict(count=0, ratio=0)
return self._dict(count=0, transmitted=0, ratio=0)
return self._dict(
count=self._comm.received_resends,
transmitted=self._comm.transmitted_lines,
ratio=int(self._comm.resend_ratio * 100.0),
)
+2
View File
@@ -547,6 +547,8 @@ class Server(object):
try:
clazz = octoprint.util.get_class(user_manager_name)
userManager = clazz(groupManager)
except octoprint.access.users.CorruptUserStorage:
raise
except Exception:
self._logger.exception(
"Could not instantiate user manager {}, "
+4 -2
View File
@@ -140,8 +140,10 @@ def uploadLanguagePack():
upload_name = request.values[input_upload_name]
upload_path = request.values[input_upload_path]
exts = filter(
lambda x: upload_name.lower().endswith(x), (".zip", ".tar.gz", ".tgz", ".tar")
exts = list(
filter(
lambda x: upload_name.lower().endswith(x), (".zip", ".tar.gz", ".tgz", ".tar")
)
)
if not len(exts):
return make_response(
+3
View File
@@ -243,6 +243,7 @@ def getSettings():
["serial", "capabilities", "emergency_parser"]
),
"resendRatioThreshold": s.getInt(["serial", "resendRatioThreshold"]),
"resendRatioStart": s.getInt(["serial", "resendRatioStart"]),
},
"folder": {
"uploads": s.getBaseFolder("uploads"),
@@ -871,6 +872,8 @@ def _saveSettings(data):
s.setInt(
["serial", "resendRatioThreshold"], data["serial"]["resendRatioThreshold"]
)
if "resendRatioStart" in data["serial"]:
s.setInt(["serial", "resendRatioStart"], data["serial"]["resendRatioStart"])
oldLog = s.getBoolean(["serial", "log"])
if "log" in data["serial"]:
+1
View File
@@ -170,6 +170,7 @@ default_settings = {
"emergency_parser": True,
},
"resendRatioThreshold": 10,
"resendRatioStart": 100,
# command specific flags
"triggerOkForM29": True,
},
@@ -12,7 +12,10 @@ $(function () {
self.resendTotalTransmitted = ko.observable(0);
self.resendRatio = ko.observable(0);
self.resendRatioCritical = ko.pureComputed(function () {
return self.resendRatio() >= self.settings.serial_resendRatioThreshold();
return (
self.resendRatio() >= self.settings.serial_resendRatioThreshold() &&
self.resendTotalTransmitted() >= self.settings.serial_resendRatioStart()
);
});
self.resendRatioNotification = undefined;
@@ -387,6 +390,7 @@ $(function () {
self._processResends = function (data) {
self.resendCount(data.count);
self.resendTotalTransmitted(data.transmitted);
self.resendRatio(data.ratio);
};
@@ -235,6 +235,7 @@ $(function () {
self.serial_disableSdPrintingDetection = ko.observable(undefined);
self.serial_ackMax = ko.observable(undefined);
self.serial_resendRatioThreshold = ko.observable(100);
self.serial_resendRatioStart = ko.observable(100);
self.folder_uploads = ko.observable(undefined);
self.folder_timelapse = ko.observable(undefined);
@@ -526,6 +526,15 @@
</div>
</div>
</div>
<div class="control-group" title="{{ _('Start tracking resend request after these many transmitted lines.')|edq }}">
<label class="control-label" for="settings-serialResendRatioStart">{{ _('Tracking start') }}</label>
<div class="controls">
<div class="input-append">
<input type="number" step="1" class="input-mini text-right" id="settings-serialResendRatioStart" data-bind="value: serial_resendRatioStart">
<span class="add-on">lines</span>
</div>
</div>
</div>
</fieldset>
</div>
</div>
+1 -1
View File
@@ -1,5 +1,5 @@
<span title="{{ _('Current printer state')|edq }}">{{ _('State') }}</span>: <strong data-test-id="state-string" data-bind="text: stateString"></strong><br>
<span data-bind="visible: isOperational"><span title="{{ _('Count of resend requests and resend ratio')|edq }}">{{ _('Resend requests') }}</span>: <strong data-bind="css: {'text-error': resendRatioCritical}"><span title="{{ _('resend requests') | edq }}" data-bind="text: formatHuman(resendCount())"></span> (<span data-bind="text: resendRatio"></span>%) <a href="https://faq.octoprint.org/communication-errors" target="_blank" class="text-error" data-bind="visible: resendRatioCritical"><i class="fas fa-question-circle"></i></a></strong><br></span>
<span data-bind="visible: isOperational"><span title="{{ _('Count of resend requests, transmitted lines and resend ratio')|edq }}">{{ _('Resend ratio') }}</span>: <strong data-bind="css: {'text-error': resendRatioCritical}"><span title="{{ _('resend requests') | edq }}" data-bind="text: formatHuman(resendCount())"></span> / <span title="{{ _('transmitted lines') | edq }}" data-bind="text: formatHuman(resendTotalTransmitted())"></span> (<span title="{{ _('resend ratio') }}" data-bind="text: resendRatio"></span>%) <a href="https://faq.octoprint.org/communication-errors" target="_blank" class="text-error" data-bind="visible: resendRatioCritical"><i class="fas fa-question-circle"></i></a></strong><br></span>
<hr>
<span title="{{ _('Name of file currently selected for printing')|edq }}">{{ _('File') }}</span>: <strong data-bind="text: filedisplay, attr: {title: filepath}"></strong>&nbsp;<strong data-bind="visible: sd">(SD)</strong><br>
<span title="{{ _('Upload date of the file currently selected or printing')|edq }}">{{ _('Uploaded') }}</span>: <strong data-bind="text: dateString"></strong><br>
+5 -3
View File
@@ -665,6 +665,7 @@ class MachineCom(object):
self._transmitted_lines = 0
self._received_resend_requests = 0
self._resend_ratio_start = settings().getInt(["serial", "resendRatioStart"])
self._resend_ratio_threshold = (
settings().getInt(["serial", "resendRatioThreshold"]) / 100.0
)
@@ -826,13 +827,14 @@ class MachineCom(object):
resend_ratio = self.resend_ratio
if (
resend_ratio >= self._resend_ratio_threshold
and self._transmitted_lines > self._resend_ratio_start
and not self._resend_ratio_reported
):
message = (
"Over {}% of transmitted lines have triggered resend requests "
"({:.2f}%). The communication with the printers is unreliable. "
"Over {:.0f}% of transmitted lines have triggered resend requests "
"({:.2f}%). The communication with the printer is unreliable. "
"Please see https://faq.octoprint.org/communication-errors.".format(
self._resend_ratio_threshold, resend_ratio
self._resend_ratio_threshold * 100, resend_ratio * 100
)
)
self._log(message)
+462 -271
View File
File diff suppressed because it is too large. Load diff