🥅 PiSupport: Warning if run on a zero/zero w

This commit is contained in:
Gina Häußge committed 2020-10-21 11:54:46 +02:00
1 parent 0d90bb9e8f
commit fd319fc82f
4 files changed
+57 -4

No files matched your search

+9 -2
View File
@@ -252,8 +252,14 @@ class PiSupportPlugin(
def on_api_get(self, request):
if not Permissions.PLUGIN_PI_SUPPORT_STATUS.can():
return flask.abort(403)
result = {"throttle_state": self._throttle_state.as_dict()}
result.update(self.get_additional_environment())
environment = self.get_additional_environment()
result = {
"throttle_state": self._throttle_state.as_dict(),
"model_unrecommended": "zero" in environment.get("model").lower(),
}
result.update(environment)
return flask.jsonify(**result)
# ~~ AssetPlugin
@@ -309,6 +315,7 @@ class PiSupportPlugin(
return {
"vcgencmd_throttle_check_enabled": True,
"vcgencmd_throttle_check_command": _VCGENCMD_THROTTLE,
"ignore_unrecommended_model": False,
}
def get_settings_restricted_paths(self):
@@ -4,6 +4,7 @@ $(function () {
self.loginState = parameters[0];
self.access = parameters[1];
self.settings = parameters[2];
self.model = ko.observable();
@@ -27,6 +28,42 @@ $(function () {
// Raspberry Pi model
self.model(response.model);
// Unrecommended model
if (
response.model_unrecommended &&
!self.settings.settings.plugins.pi_support.ignore_unrecommended_model()
) {
var warning = gettext(
"OctoPrint does not and never has supported the " +
"RPi Zero or Zero W. Use at least a Raspberry Pi 3, or " +
"risk bad performance and failed prints."
);
var faq = gettext(
"" +
'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
);
var remove = gettext(
"You can disable this message via Settings > " +
"Pi Support > Ignore warning on unsupported hardware"
);
new PNotify({
title: gettext("Unsupported hardware detected"),
text:
"<p>" +
warning +
"</p><p>" +
_.sprintf(faq, {
url: "https://faq.octoprint.org/recommended-hardware"
}) +
"</p><p>" +
"<small>" +
remove +
"</small></p>",
type: "error",
hide: false
});
}
// Throttle state
self.fromThrottleState(response.throttle_state);
@@ -130,6 +167,6 @@ $(function () {
OCTOPRINT_VIEWMODELS.push({
construct: PiSupportViewModel,
elements: ["#navbar_plugin_pi_support"],
dependencies: ["loginStateViewModel", "accessViewModel"]
dependencies: ["loginStateViewModel", "accessViewModel", "settingsViewModel"]
});
});
@@ -3,6 +3,15 @@
<p>{{ _('Please restart OctoPrint after changing any of this plugin\'s settings.') }}</p>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.pi_support.ignore_unrecommended_model"> {{ _('Disable warning about unsupported hardware') }} <label class="label label-important">{{ _('Warning') }}</label>
</label>
<span class="help-block">{{ _('If you check this, you will no longer get warned if you run OctoPrint on Raspberry Pi models that are not officially supported due to bad performance that can lead to failed prints. Do so at your own risk.') }}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1 +1 @@
Raspberry Pi Model F Rev 1.1
Raspberry Pi Zero W Rev 1.1