Merge branch 'staging/maintenance' into maintenance
This commit is contained in:
commit
83f488d1d2
21 files changed
+538
-298
No files matched your search
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
|
||||
|
||||
@@ -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 {}, "
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"]:
|
||||
|
||||
@@ -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,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> <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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Vendored
+462
-271
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user