Merge branch 'devel' into dev/commRefactoringNG

This commit is contained in:
Gina Häußge committed 2019-02-21 11:52:11 +01:00
commit 8080e65366
34 files changed
+810 -92

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
.. _sec-bundledplugins-errortracking:
Error Tracking Plugin
=====================
The Error Tracking plugin will cause any logged exceptions in the server and the browser interface to be sent to
OctoPrint's `Sentry instance <https://sentry.io/>`_.
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially
valuable on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects
that you are subscribed to an RC release channel.
By default, even when enabled it will only be active if you are running a released OctoPrint version, so either a stable
release or a release candidate.
The Error Tracking plugin is using a Sentry instance kindly provided by `sentry.io <https://sentry.io/>`_. For information on their service
please refer to their `Security & Compliance documentation <https://sentry.io/security/>`_
and their `Privacy Policy <https://sentry.io/privacy/>`_.
The Error Tracking plugin has been bundled with OctoPrint since version 1.3.11.
.. _sec-bundledplugins-errortracking-configuration:
Configuring the plugin
----------------------
The plugin supports the following configuration keys:
* ``enabled``: Whether to enable error tracking. Defaults to ``false``.
* ``enabled_unreleased``: Whether to also enable tracking on unreleased OctoPrint versions (anything not stable releases
or release candidates). Defaults to ``false``.
* ``unique_id``: Unique instance identifier, auto generated on first activation
.. _sec-bundledplugins-errortracking-sourcecode:
Source Code
-----------
The source of the Error Tracking plugin is bundled with OctoPrint and can be
found in its source repository under ``src/octoprint/plugins/errortracking``.
+2
View File
@@ -9,9 +9,11 @@ Bundled Plugins
action_command_prompt.rst
announcements.rst
tracking.rst
appkeys.rst
backup.rst
discovery.rst
errortracking.rst
forcelogin.rst
logging.rst
pluginmanager.rst
+45
View File
@@ -0,0 +1,45 @@
.. _sec-bundledplugins-tracking:
Anonymous Usage Tracking Plugin
===============================
The Anonymous Usage Tracking plugin provides valuable insights into how many instances running what versions of
OctoPrint are out there, whether they are successfully completing print jobs and various other metrics.
By enabling it you help to identify problems with new releases and release candidates early on, and to better tailor
OctoPrint's future development to actual use.
For details on what gets tracked, please refer to `tracking.octoprint.org <https://tracking.octoprint.org>`_
and also the `Privacy Policy at tracking.octoprint.org <https://tracking.octoprint.org/privacy>`_.
The Anonymous Usage Tracking plugin has been bundled with OctoPrint since version 1.3.10.
.. _sec-bundledplugins-tracking-configuration:
Configuring the plugin
----------------------
The plugin supports the following configuration keys:
* ``enabled``: Whether to enable usage tracking. Defaults to ``false``.
* ``unique_id``: Unique instance identifier, auto generated on first activation
* ``server``: The tracking server to track against. Defaults to a tracking endpoint on ``https://tracking.octoprint.org``.
* ``ping``: How often to send a ``ping`` tracking event, in seconds. Defaults to a 15min interval.
* ``events``: Granular configuration of enabled tracking events. All default to ``true``.
* ``startup``: Whether to track startup/shutdown events
* ``printjob``: Whether to track print job related events (start, completion, cancel, ...)
* ``commerror``: Whether to track communication errors with the printer
* ``plugin``: Whether to track plugin related events (install, uninstall, ...)
* ``update``: Whether to track update related events (update successful or not, ...)
* ``printer``: Whether to track printer related events (connected, firmware, ...)
* ``printer_safety_check``: Whether to track warnings of the :ref:`Printer Safety Check <sec-bundledplugins-printer_safety_check>`
* ``throttled``: Whether to track throttle events detected on the underlying system
.. _sec-bundledplugins-tracking-sourcecode:
Source Code
-----------
The source of the Anonymous Usage Tracking plugin is bundled with OctoPrint and can be
found in its source repository under ``src/octoprint/plugins/tracking``.
+15
View File
@@ -13,6 +13,7 @@ plugin subsystem about themselves. These are simple package attributes defined i
# ...
__plugin_name__ = "My Plugin"
__plugin_pythoncompat__ = ">=2.7,<4"
def __plugin_load__():
# whatever you need to do to load your plugin, if anything at all
pass
@@ -52,6 +53,20 @@ The following properties are recognized:
``__plugin_license__``
License of your plugin, optional, overrides the license specified in ``setup.py`` if provided.
.. _sec-plugins-controlproperties-plugin_pythoncompat:
``__plugin_pythoncompat__``
Python compatibility string of your plugin, optional, defaults to ``>=2.7,<3`` if not set and thus Python 2 but no
Python 3 compatibility.
If your plugin is compatible to Python 3, you should set this to ``>=2.7,<4``, otherwise your plugin will not load
on OctoPrint instances installed under Python 3.
.. code-block:: python
__plugin_pythoncompat__ = ">=2.7,<4"
.. _sec-plugins-controlproperties-plugin_implementation:
``__plugin_implementation__``
+2 -1
View File
@@ -57,7 +57,8 @@ INSTALL_REQUIRES = [
"python-dateutil>=2.7.5,<2.8",
"wrapt>=1.10.11,<1.11",
"emoji>=0.5.1,<0.6",
"frozendict>=1.2,<1.3"
"frozendict>=1.2,<1.3",
"sentry-sdk==0.6.6"
]
# Python 2 specific requirements
+2 -2
View File
@@ -7,7 +7,6 @@ __copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms
import copy
import logging
import os
import platform
import sys
import threading
import yaml
@@ -16,6 +15,7 @@ import psutil
from octoprint.plugin import EnvironmentDetectionPlugin
from octoprint.util.platform import get_os
from octoprint.util.version import get_python_version_string
class EnvironmentDetector(object):
@@ -70,7 +70,7 @@ class EnvironmentDetector(object):
# determine python version
try:
result["version"] = platform.python_version()
result["version"] = get_python_version_string()
except Exception:
self._logger.exception("Error detecting python version")
+52 -11
View File
@@ -41,6 +41,7 @@ import pkginfo
from past.builtins import unicode
from octoprint.util import to_unicode
from octoprint.util.version import is_python_compatible, get_python_version_string
try:
from os import scandir
@@ -93,6 +94,18 @@ class PluginInfo(object):
attr_license = '__plugin_license__'
""" Module attribute from which to retrieve the plugin's license. """
attr_pythoncompat = '__plugin_pythoncompat__'
"""
Module attribute from which to retrieve the plugin's python compatibility string.
If unset a default of ``>=2.7,<3`` will be assumed, meaning that the plugin will be considered compatible to
Python 2 but not Python 3.
To mark a plugin as Python 3 compatible, a string of ``>=2.7,<4`` is recommended.
Bundled plugins will automatically be assumed to be compatible.
"""
attr_hooks = '__plugin_hooks__'
""" Module attribute from which to retrieve the plugin's provided hooks. """
@@ -148,6 +161,7 @@ class PluginInfo(object):
self.enabled = True
self.blacklisted = False
self.forced_disabled = False
self.incompatible = False
self.bundled = False
self.loaded = False
self.managable = True
@@ -168,7 +182,7 @@ class PluginInfo(object):
result = True
if phase == "before_import":
result = not self.forced_disabled and not self.blacklisted and result
result = not self.forced_disabled and not self.blacklisted and not self.incompatible and result
elif phase == "before_load":
# if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__
@@ -216,7 +230,7 @@ class PluginInfo(object):
def long_str(self, show_bundled=False, bundled_strs=(" [B]", ""),
show_location=False, location_str=" - {location}",
show_enabled=False, enabled_strs=("* ", " ", "X ")):
show_enabled=False, enabled_strs=("* ", " ", "X ", "C ")):
"""
Long string representation of the plugin's information. Will return a string of the format ``<enabled><str(self)><bundled><location>``.
@@ -224,8 +238,9 @@ class PluginInfo(object):
The will be filled from ``enabled_str``, ``bundled_str`` and ``location_str`` as follows:
``enabled_str``
a 3-tuple, the first entry being the string to insert when the plugin is enabled, the second
entry the string to insert when it is not, the third entry the string when it is blacklisted.
a 4-tuple, the first entry being the string to insert when the plugin is enabled, the second
entry the string to insert when it is not, the third entry the string when it is blacklisted
and the fourth when it is incompatible.
``bundled_str``
a 2-tuple, the first entry being the string to insert when the plugin is bundled, the second
entry the string to insert when it is not.
@@ -245,9 +260,14 @@ class PluginInfo(object):
str: The long string representation of the plugin as described above
"""
if show_enabled:
ret = to_unicode(enabled_strs[2]) if self.blacklisted \
else (to_unicode(enabled_strs[0]) if self.enabled
else to_unicode(enabled_strs[1]))
if self.incompatible:
ret = to_unicode(enabled_strs[3])
elif self.blacklisted:
ret = to_unicode(enabled_strs[2])
elif not self.enabled:
ret = to_unicode(enabled_strs[1])
else:
ret = to_unicode(enabled_strs[0])
else:
ret = ""
@@ -384,6 +404,19 @@ class PluginInfo(object):
default=self._license,
incl_metadata=True)
@property
def pythoncompat(self):
"""
Python compatibility string of the plugin module as defined in :attr:`attr_pythoncompat` if available, otherwise
defaults to ``>=2.7,<3``.
Returns:
str: Python compatibility string of the plugin
"""
return self._get_instance_attribute(self.__class__.attr_pythoncompat,
default=">=2.7,<3",
incl_metadata=True)
@property
def hooks(self):
"""
@@ -528,7 +561,8 @@ class PluginInfo(object):
filter(lambda x: isinstance(x, ast.Name), node.targets)))
for key in (self.__class__.attr_name, self.__class__.attr_version, self.__class__.attr_author,
self.__class__.attr_description, self.__class__.attr_url, self.__class__.attr_license):
self.__class__.attr_description, self.__class__.attr_url, self.__class__.attr_license,
self.__class__.attr_pythoncompat):
for a in reversed(assignments):
targets = extract_target_ids(a)
if key in targets:
@@ -840,6 +874,11 @@ class PluginManager(object):
self.logger.warning("Plugin {} is blacklisted.".format(plugin))
plugin.blacklisted = True
python_version = get_python_version_string()
if not is_python_compatible(plugin.pythoncompat) and not plugin.bundled:
self.logger.warning("Plugin {} is not compatible to Python {} (compatibility string: {}).".format(plugin, python_version, plugin.pythoncompat))
plugin.incompatible = True
if not plugin.validate("before_import", additional_validators=self.plugin_validators):
return plugin
@@ -1369,7 +1408,7 @@ class PluginManager(object):
def log_all_plugins(self, show_bundled=True, bundled_str=(" (bundled)", ""), show_location=True,
location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!", "#"),
location_str=" = {location}", show_enabled=True, enabled_str=(" ", "!", "#", "*"),
only_to_handler=None):
all_plugins = list(self.enabled_plugins.values()) + list(self.disabled_plugins.values())
@@ -1390,8 +1429,10 @@ class PluginManager(object):
show_enabled=show_enabled,
enabled_strs=enabled_str),
sorted(self.plugins.values(), key=lambda x: unicode(x).lower())))
_log("{count} plugin(s) registered with the system:\n{plugins}".format(count=len(all_plugins),
plugins=formatted_plugins))
legend = "Prefix legend: {1} = disabled, {2} = blacklisted, {3} = incompatible".format(*enabled_str)
_log("{count} plugin(s) registered with the system:\n{plugins}\n{legend}".format(count=len(all_plugins),
plugins=formatted_plugins,
legend=legend))
def get_plugin(self, identifier, require_enabled=True):
"""
@@ -0,0 +1,117 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
import octoprint.plugin
import logging
from octoprint.util.version import get_octoprint_version_string, is_released_octoprint_version
from flask import jsonify
from flask_babel import gettext
SENTRY_URL_SERVER = "https://827d1f11ccda4b31b924f29aaacab493@sentry.io/1373987"
SENTRY_URL_COREUI = "https://30bdc39d2248444c8bc01484f38c9444@sentry.io/1374096"
SETTINGS_DEFAULTS = dict(enabled=False,
enabled_unreleased=False,
unique_id=None,
url_server=SENTRY_URL_SERVER,
url_coreui=SENTRY_URL_COREUI)
class ErrorTrackingPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SimpleApiPlugin):
def get_template_configs(self):
return [
dict(type="settings",
name=gettext("Error Tracking"),
template="errortracking_settings.jinja2",
custom_bindings=False),
dict(type="generic", template="errortracking_javascripts.jinja2")
]
def get_template_vars(self):
enabled = self._settings.get_boolean(["enabled"])
enabled_unreleased = self._settings.get_boolean(["enabled_unreleased"])
return dict(enabled=_is_enabled(enabled, enabled_unreleased),
unique_id=self._settings.get(["unique_id"]),
url_coreui=self._settings.get(["url_coreui"]))
def get_assets(self):
return dict(js=["js/sentry.min.js", "js/errortracking.js"])
def get_settings_defaults(self):
return SETTINGS_DEFAULTS
def on_settings_save(self, data):
old_enabled = _is_enabled(self._settings.get_boolean(["enabled"]),
self._settings.get_boolean(["enabled_unreleased"]))
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
enabled = _is_enabled(self._settings.get_boolean(["enabled"]),
self._settings.get_boolean(["enabled_unreleased"]))
if old_enabled != enabled:
_enable_errortracking()
def on_api_get(self, request):
return jsonify(**self.get_template_vars())
_enabled = False
def _enable_errortracking():
# this is a bit hackish, but we want to enable error tracking as early in the platform lifecycle as possible
# and hence can't wait until our implementation is initialized and injected with settings
from octoprint.settings import settings
global _enabled
if _enabled:
return
version = get_octoprint_version_string()
s = settings()
plugin_defaults = dict(plugins=dict(errortracking=SETTINGS_DEFAULTS))
enabled = s.getBoolean(["plugins", "errortracking", "enabled"], defaults=plugin_defaults)
enabled_unreleased = s.getBoolean(["plugins", "errortracking", "enabled_unreleased"], defaults=plugin_defaults)
url_server = s.get(["plugins", "errortracking", "url_server"], defaults=plugin_defaults)
unique_id = s.get(["plugins", "errortracking", "unique_id"], defaults=plugin_defaults)
if unique_id is None:
import uuid
unique_id = str(uuid.uuid4())
s.set(["plugins", "errortracking", "unique_id"], unique_id, defaults=plugin_defaults)
s.save()
if _is_enabled(enabled, enabled_unreleased):
import sentry_sdk
sentry_sdk.init(url_server,
release=version)
with sentry_sdk.configure_scope() as scope:
scope.user = dict(id=unique_id)
logging.getLogger("octoprint.plugin.errortracking").info("Initialized error tracking")
_enabled = True
def _is_enabled(enabled, enabled_unreleased):
return enabled and (enabled_unreleased or is_released_octoprint_version())
def __plugin_enable__():
_enable_errortracking()
__plugin_name__ = "Error Tracking"
__plugin_author__ = "Gina Häußge"
__plugin_implementation__ = ErrorTrackingPlugin()
@@ -0,0 +1,103 @@
$(function() {
function ErrorTrackingViewModel(parameters) {
var self = this;
self.settings = parameters[0];
self.loginState = parameters[1];
var notification = undefined;
var performCheck = function() {
if (!self.loginState.isAdmin()) return;
// already enabled?
if (self.settings.settings.plugins.errortracking.enabled()) return;
// RC release channel?
var releaseChannel = self.settings.settings.plugins.softwareupdate.octoprint_release_channel();
if (releaseChannel === "rc/maintenance" || releaseChannel === "rc/devel") {
if (notification !== undefined) return;
// ignored?
try {
var ignoredString = localStorage["plugin.errortracking.notification_ignored"];
var ignored = false;
if (ignoredString) {
ignored = JSON.parse(ignoredString);
}
if (ignored) return;
} catch (ex) {
log.error("Error while reading plugin.errortracking.notification_ignored from local storage");
}
// show notification
notification = new PNotify({
title: gettext("Enable error reporting?"),
text: gettext("<p>It looks like you are tracking an OctoPrint RC release channel. It " +
"would be great if you would enable error reporting so that any kind of errors that occur " +
"with an RC can be looked into more easily. Thank you!</p>" +
"<p><small>You can find more information on error reporting " +
"under Settings > Error Tracking</small></p>"),
hide: false,
confirm: {
confirm: true,
buttons: [{
text: gettext("Ignore"),
click: function() {
notification.remove();
notification = undefined;
new PNotify({
text: gettext("You can still enable error tracking via \"Settings\" > \"Error Tracking\"")
});
if (Modernizr.localstorage) {
localStorage["plugin.errortracking.notification_ignored"] = JSON.stringify(true);
}
}
}, {
text: gettext("Enable"),
addClass: "btn-primary",
click: function() {
self.settings.saveData({
plugins: {
errortracking: {
enabled: true
}
}
}).done(function() {
notification.remove();
notification = undefined;
location.reload(true);
});
}
}]
},
buttons: {
closer: false,
sticker: false
}
});
// not an RC release channel, close notification
} else if (notification !== undefined) {
notification.remove();
notification = undefined;
}
};
var subbed = false;
self.onStartup = self.onUserLoggedIn = self.onUserLoggedOut = function() {
performCheck();
if (self.settings && self.settings.settings && self.settings.settings.plugins && self.settings.settings.plugins.softwareupdate && !subbed) {
subbed = true;
self.settings.settings.plugins.softwareupdate.octoprint_release_channel.subscribe(performCheck);
}
};
}
OCTOPRINT_VIEWMODELS.push({
construct: ErrorTrackingViewModel,
dependencies: ["settingsViewModel", "loginStateViewModel"]
});
});
@@ -0,0 +1,3 @@
/*! @sentry/browser 4.5.1 (6a390acf) | https://github.com/getsentry/sentry-javascript */
var Sentry=function(t){"use strict";var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function s(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(s,a)}u((r=r.apply(t,e||[])).next())})}function a(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function u(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function c(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function l(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(c(arguments[e]));return t}function p(t){switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}}function f(t){return"[object ErrorEvent]"===Object.prototype.toString.call(t)}function h(t){return"[object DOMError]"===Object.prototype.toString.call(t)}function d(t){return void 0===t}function v(t){return"function"==typeof t}function g(t){return"[object String]"===Object.prototype.toString.call(t)}function y(t){return"[object Object]"===Object.prototype.toString.call(t)}function m(t){return t!=t}function b(){return"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}}function E(){var t=b(),e=t.crypto||t.msCrypto;if(void 0!==e&&e.getRandomValues){var n=new Uint16Array(8);e.getRandomValues(n),n[3]=4095&n[3]|16384,n[4]=16383&n[4]|32768;var r=function(t){for(var e=t.toString(16);e.length<4;)e="0"+e;return e};return r(n[0])+r(n[1])+r(n[2])+r(n[3])+r(n[4])+r(n[5])+r(n[6])+r(n[7])}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function x(t){var e,n,r,o,i,s=[];if(!t||!t.tagName)return"";if(s.push(t.tagName.toLowerCase()),t.id&&s.push("#"+t.id),(e=t.className)&&g(e))for(n=e.split(/\s+/),i=0;i<n.length;i++)s.push("."+n[i]);var a=["type","name","title","alt"];for(i=0;i<a.length;i++)r=a[i],(o=t.getAttribute(r))&&s.push("["+r+'="'+o+'"]');return s.join("")}function _(t){if(!t)return{};var e=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!e)return{};var n=e[6]||"",r=e[8]||"";return{host:e[4],path:e[5],protocol:e[2],relative:e[5]+n+r}}function S(t){if(t.message)return t.message;if(t.exception&&t.exception.values&&t.exception.values[0]){var e=t.exception.values[0];return e.type&&e.value?e.type+": "+e.value:e.type||e.value||t.event_id||"<unknown>"}return t.event_id||"<unknown>"}function w(t){var e=b();if(!("console"in e))return t();var n=e.console,r={};["debug","info","warn","error","log"].forEach(function(t){t in e.console&&n[t].__sentry__&&(r[t]=n[t].__sentry_wrapped__,n[t]=n[t].__sentry_original__)});var o=t();return Object.keys(r).forEach(function(t){n[t]=r[t]}),o}function k(t,e){return void 0===e&&(e=0),0!==e&&g(t)?t.length<=e?t:t.substr(0,e)+"...":t}function O(t,e){if(!Array.isArray(t))return"";for(var n=[],r=0;r<t.length;r++){var o=t[r];try{n.push(String(o))}catch(t){n.push("[value cannot be serialized]")}}return n.join(e)}function j(t,e){return!(Line truncated
//# sourceMappingURL=bundle.min.js.map
@@ -0,0 +1,24 @@
<script type="text/javascript">
var ERRORTRACKING_ENABLED = {% if plugin_errortracking_enabled -%} true; {% else %} false; {%- endif %}
var ERRORTRACKING_ENABLE = function() {
var errortracking_url_coreui = "{{ plugin_errortracking_url_coreui }}";
var errortracking_unique_id = "{{ plugin_errortracking_unique_id }}";
Sentry.init({
dsn: errortracking_url_coreui,
release: VERSION
});
Sentry.configureScope(function (scope) {
scope.setUser({"id": errortracking_unique_id});
});
ERRORTRACKING_ENABLED = true;
log.info("Initialized error tracking");
};
$(function() {
if (ERRORTRACKING_ENABLED) {
ERRORTRACKING_ENABLE();
}
});
</script>
@@ -0,0 +1,42 @@
<h3>{{ _('Error Tracking') }}</h3>
{% trans %}
<p>
Error tracking will cause any logged exceptions in the server and the browser interface to be sent
to OctoPrint's <a href="https://sentry.io/" target="_blank" rel="noopener noreferer">Sentry instance</a>.
</p>
<p>
By enabling it you help to gather detailed information on the cause of bugs or other issues. This is especially valuable
on release candidates, which is why this plugin will also prompt you to enable error tracking if it detects that
you are subscribed to an RC release channel.
</p>
<p>
Please enable this if you are running a release candidate, or are prompted to do so while debugging an issue that you reported.
</p>
{% endtrans %}
<form class="form-horizontal">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.errortracking.enabled"> {{ _('Enable error tracking') }}
</label>
<span class="help-block">{{ _('Please reload the page after enabling/disabling & saving') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label" title="{{ _('Random unique instance ID') }}">{{ _('Instance ID') }}</label>
<div class="controls">
<span style="padding-top: 5px; margin-bottom: 5px; display: inline-block" data-bind="text: settings.plugins.errortracking.unique_id() || 'N/A'"></span>
</div>
</div>
</form>
{% trans %}
<p>
The Error Tracking plugin is using a Sentry instance kindly provided by
<a href="https://sentry.io/" target="_blank" rel="noopener noreferer">sentry.io</a>. For information on their service
please refer to their <a href="https://sentry.io/security/" target="_blank" rel="noopener noreferer">Security & Compliance documentation</a>
and their <a href="https://sentry.io/privacy/" target="_blank" rel="noopener noreferer">Privacy Policy</a>.
</p>
{% endtrans %}
@@ -16,7 +16,7 @@ from octoprint.access import ADMIN_GROUP
from octoprint.access.permissions import Permissions
from octoprint.util import to_bytes
from octoprint.util.pip import LocalPipCaller
from octoprint.util.version import get_octoprint_version_string, get_octoprint_version, is_octoprint_compatible
from octoprint.util.version import get_octoprint_version_string, get_octoprint_version, is_octoprint_compatible, is_python_compatible
from octoprint.util.platform import get_os, is_os_compatible
from octoprint.events import Events
@@ -46,7 +46,8 @@ def map_repository_entry(entry):
result["is_compatible"] = dict(
octoprint=True,
os=True
os=True,
python=True
)
if "compatibility" in entry:
@@ -58,6 +59,12 @@ def map_repository_entry(entry):
entry["compatibility"]["os"], (list, tuple)) and len(entry["compatibility"]["os"]):
result["is_compatible"]["os"] = is_os_compatible(entry["compatibility"]["os"])
if "python" in entry["compatibility"] and entry["compatibility"]["python"] is not None and isinstance(entry["compatibility"]["python"], basestring):
result["is_compatible"]["python"] = is_python_compatible(entry["compatibility"]["python"])
else:
# we default to only assume py2 compatiblity for now
result["is_compatible"]["python"] = is_python_compatible(">=2.7,<3")
return result
@@ -1 +1 @@
table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
table td.settings_plugin_plugin_manager_plugins_name,table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}table td.settings_plugin_plugin_manager_plugins_actions,table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}table td.settings_plugin_plugin_manager_plugins_actions a,table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}table td.settings_plugin_plugin_manager_plugins_actions a.disabled,table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:300px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:300px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
@@ -56,7 +56,7 @@ $(function() {
return !self.installed(plugin);
},
"filter_incompatible": function(plugin) {
return plugin.is_compatible.octoprint && plugin.is_compatible.os;
return plugin.is_compatible.octoprint && plugin.is_compatible.os && plugin.is_compatible.python;
}
},
"title",
@@ -622,7 +622,7 @@ $(function() {
};
self.isCompatible = function(data) {
return data.is_compatible.octoprint && data.is_compatible.os;
return data.is_compatible.octoprint && data.is_compatible.os && data.is_compatible.python;
};
self.installButtonText = function(data) {
@@ -53,7 +53,8 @@ table {
}
}
#settings_plugin_pluginmanager_repositorydialog_unavailable {
#settings_plugin_pluginmanager_repositorydialog_unavailable,
#settings_plugin_pluginmanager_repositorydialog_empty {
overflow: hidden;
width: 100%;
height: 300px;
@@ -154,7 +154,7 @@
<input type="text" class="input-block search-query" data-bind="value: repositorySearchQuery, valueUpdate: 'input'" placeholder="{{ _('Search...') }}">
</form>
<div data-bind="visible: repositoryAvailable()">
<div data-bind="visible: repositoryAvailable() && repositoryplugins.paginatedItems().length > 0">
<div id="settings_plugin_pluginmanager_repositorydialog_list" data-bind="foreach: repositoryplugins.paginatedItems">
<div class="entry">
<div class="row-fluid">
@@ -187,6 +187,13 @@
</p>
</div>
</div>
<div id="settings_plugin_pluginmanager_repositorydialog_empty" data-bind="visible: repositoryAvailable() && repositoryplugins.paginatedItems().length === 0">
<div>
<p>
<strong>{{ _('It looks like there are no compatible plugins available') }}</strong>
</p>
</div>
</div>
<h4>{{ _('... from URL') }}</h4>
@@ -9,7 +9,8 @@ import octoprint.plugin
from octoprint.events import Events
from octoprint.access import USER_GROUP
from octoprint.access.permissions import Permissions
from octoprint.util.version import get_comparable_version
from .checks.firmware_unsafe import FirmwareUnsafeChecks
import flask
from flask_babel import gettext
@@ -25,58 +26,10 @@ Learn more at https://faq.octoprint.org/warning-{warning_type}
"""
# Anet A8
ANETA8_M115_TEST = ("aneta8", lambda name, data: name and name.lower().startswith("anet_a8_"))
# Anycubic MEGA
ANYCUBIC_AUTHOR1 = "| Author: (Jolly, xxxxxxxx.CO.)".lower()
ANYCUBIC_AUTHOR2 = "| Author: (**Jolly, xxxxxxxx.CO.**)".lower()
ANYCUBIC_RECEIVED_TEST = ("anycubic", lambda line: line and (ANYCUBIC_AUTHOR1 in line.lower() or ANYCUBIC_AUTHOR2 in line.lower()))
# Creality CR-10s
CR10S_AUTHOR = " | Author: (CR-10Slanguage)".lower()
CR10S_RECEIVED_TEST = ("cr10s", lambda line: line and CR10S_AUTHOR in line.lower())
# Creality Ender 3
ENDER3_AUTHOR = " | Author: (Ender3)".lower()
ENDER3_RECEIVED_TEST = ("ender3", lambda line: line and ENDER3_AUTHOR in line.lower())
# iMe on Micro3D
IME_M115_TEST = ("ime", lambda name, data: name and name.lower().startswith("ime"))
# Malyan M200 aka Monoprice Select Mini, versions less than 4.0
MALYANM200_M115_TEST = ("malyan_m200", lambda name, data: name and name.lower().startswith("malyan") and data.get("MODEL") == "M200" and get_comparable_version(data.get("VER", "0")) < get_comparable_version("4.0"))
# Stock Micro3D
MICRO3D_M115_TEST = ("micro3d", lambda name, data: name and name.lower().startswith("micro3d"))
# Any Repetier versions < 0.92
REPETIER_BEFORE_092_M115_TEST = ("repetier_before_092", lambda name, data: name and name.lower().startswith("repetier") and extract_repetier_version(name) is not None and extract_repetier_version(name) < get_comparable_version("0.92"))
# THERMAL_PROTECTION capability reported as disabled
THERMAL_PROTECTION_CAP_TEST = ("capability", lambda cap, enabled: cap == "THERMAL_PROTECTION" and not enabled)
SAFETY_CHECKS = {
"firmware-unsafe": dict(m115=(ANETA8_M115_TEST, IME_M115_TEST, MALYANM200_M115_TEST, MICRO3D_M115_TEST,
REPETIER_BEFORE_092_M115_TEST),
received=(ANYCUBIC_RECEIVED_TEST, CR10S_RECEIVED_TEST, ENDER3_RECEIVED_TEST),
cap=(THERMAL_PROTECTION_CAP_TEST,),
message=gettext("Your printer's firmware is known to lack mandatory safety features (e.g. "
"thermal runaway protection). This is a fire risk."))
"firmware-unsafe": FirmwareUnsafeChecks.as_dict()
}
def extract_repetier_version(name):
"""
Extracts the Repetier version number from the firmware name.
Example: "Repetier_0.91" => 0.91
"""
version = None
if "_" in name:
_, version = name.split("_", 1)
version = get_comparable_version(version, base=True)
return version
class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.EventHandlerPlugin,
octoprint.plugin.SimpleApiPlugin,
@@ -111,6 +64,8 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
def on_event(self, event, payload):
if event == Events.DISCONNECTED:
self._reset_warnings()
self._reset_state()
self._reset_checks()
##~~ SimpleApiPlugin API
@@ -154,20 +109,35 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
changes = False
for warning_type, check_data in SAFETY_CHECKS.items():
checks = check_data.get(check_type)
checks = check_data.get("checks")
message = check_data.get("message")
if not checks or not message:
continue
for check_name, check in checks:
if check(*args, **kwargs):
for check in checks:
if not check.active:
# skip non active checks
continue
method = getattr(check, check_type, None)
if not callable(method):
# skip uncallable checks
continue
# execute method
try:
method(*args, **kwargs)
except:
self._logger.exception("There was an error running method {} on check {!r}".format(check_type, check))
continue
# check if now triggered
if check.triggered:
self._register_warning(warning_type, message)
# noinspection PyUnresolvedReferences
self._event_bus.fire(Events.PLUGIN_PRINTER_SAFETY_CHECK_WARNING, dict(check_type=check_type,
check_name=check_name,
self._event_bus.fire(Events.PLUGIN_PRINTER_SAFETY_CHECK_WARNING, dict(check_name=check.name,
warning_type=warning_type))
changes = True
break
@@ -183,6 +153,18 @@ class PrinterSafetyCheckPlugin(octoprint.plugin.AssetPlugin,
self._warnings.clear()
self._ping_clients()
def _reset_state(self):
self._scan_received = True
def _reset_checks(self):
for warning_type, check_data in SAFETY_CHECKS.items():
checks = check_data.get("checks")
if not checks:
continue
for check in checks:
check.reset()
def _log_to_terminal(self, message):
if self._printer:
lines = message.split("\n")
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
class Check(object):
name = None
def __init__(self):
self._active = True
self._triggered = False
def received(self, line):
"""Called when receiving a new line from the printer"""
pass
def m115(self, name, data):
"""Called when receiving the response to an M115 from the printer"""
pass
def cap(self, cap, enabled):
"""Called when receiving a capability report line"""
pass
@property
def active(self):
"""Whether this check is still active"""
return self._active
@property
def triggered(self):
"""Whether the check has been triggered"""
return self._triggered
def reset(self):
self._active = True
self._triggered = False
class AuthorCheck(Check):
authors = ()
AUTHOR = "| Author: ".lower()
def received(self, line):
if not line:
return
lower_line = line.lower()
if self.AUTHOR in lower_line:
self._triggered = any(map(lambda x: x in lower_line, self.authors))
self._active = False
@@ -0,0 +1,180 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
from flask_babel import gettext
from octoprint.util.version import get_comparable_version
from . import Check, AuthorCheck
class FirmwareUnsafeChecks(object):
@classmethod
def as_dict(cls):
return dict(checks=(AnetA8Check(), AnycubicCheck(), CrealityCR10sCheck(), CrealityEnder3Check(),
MalyanM200Check(), Micro3DIMECheck(), Micro3DStockCheck(), RepetierBefore092Check(),
ThermalProtectionCapCheck()),
message=gettext("Your printer's firmware is known to lack mandatory safety features (e.g. "
"thermal runaway protection). This is a fire risk."))
class AnetA8Check(Check):
"""
Anet A8 stock firmware
Identified through firmware name "ANET_A8_".
"""
name = "anet_a8"
def m115(self, name, data):
self._triggered = name and name.lower().startswith("anet_a8_")
self._active = False
class AnycubicCheck(Check):
"""
Anycubic MEGA stock firmware
Identified through "Author: (Jolly, xxxxxxxx.CO.)" or "| Author: (**Jolly, xxxxxxxx.CO.**)" in startup messages
combined with "echo:Vx.y.z" in startup messages, with x.y.z < 1.1.2.
"""
name = "anycubic"
AUTHOR = "| Author: ".lower()
VERSION = "echo:V"
CRITICAL_AUTHOR1 = "| Author: (Jolly, xxxxxxxx.CO.)".lower()
CRITICAL_AUTHOR2 = "| Author: (**Jolly, xxxxxxxx.CO.**)".lower()
FIXED_VERSION = get_comparable_version("1.1.2")
def __init__(self):
Check.__init__(self)
self._author_matches = None
self._version_matches = None
def received(self, line):
if not line:
return
lower_line = line.lower()
if self.AUTHOR in lower_line:
self._author_matches = self.CRITICAL_AUTHOR1 in lower_line or self.CRITICAL_AUTHOR2 in lower_line
elif line.startswith(self.VERSION):
self._version_matches = self._broken_version(line)
else:
return
self._evaluate()
def _broken_version(self, line):
version_str = line[len(self.VERSION):]
version = get_comparable_version(version_str, base=True)
if version is not None and version <= self.FIXED_VERSION:
return True
else:
return False
def _evaluate(self):
if self._author_matches is None or self._version_matches is None:
return
self._triggered = self._author_matches and self._version_matches
self._active = False
def reset(self):
Check.reset(self)
self._author_matches = None
self._version_matches = None
class CrealityCR10sCheck(AuthorCheck):
"""
Creality CR10s
Identified through " | Author: (CR-10Slanguage)" in startup messages.
"""
name = "creality_cr10s"
authors = (" | Author: (CR-10Slanguage)".lower(),)
class CrealityEnder3Check(AuthorCheck):
"""
Creality Ender3
Identified through " | Author: (Ender3)" in startup messages.
"""
name = "creality_ender3"
authors = (" | Author: (Ender3)".lower(),)
class MalyanM200Check(Check):
"""
Malyan M200 stock firmware prior to version 4.0
Identified through firmware name "Malyan*", model "M200" and version < 4.0.
"""
name = "malyan_m200"
FIXED_VERSION = get_comparable_version("4.0")
def m115(self, name, data):
self._triggered = name and name.lower().startswith("malyan") and data.get("MODEL") == "M200" and get_comparable_version(data.get("VER", "0")) < self.FIXED_VERSION
self._active = False
class Micro3DIMECheck(Check):
"""
Micro3D with IME firmware
Identified through firmware name "iME*".
"""
name = "micro3d_ime"
def m115(self, name, data):
self._triggered = name and name.lower().startswith("ime")
self._active = False
class Micro3DStockCheck(Check):
"""
Micro3D with IME firmware
Identified through firmware name "Micro3D*".
"""
name = "micro3d"
def m115(self, name, data):
self._triggered = name and name.lower().startswith("micro3d")
self._active = False
class RepetierBefore092Check(Check):
"""
Repetier firmware prior to version 0.92
Identified through firmware name "Repetier_x.y.z" with x.y.z < 0.92
"""
name = "repetier_before_092"
FIXED_VERSION = get_comparable_version("0.92")
def m115(self, name, data):
if name and name.lower().startswith("repetier"):
version = self._extract_repetier_version(name)
self._triggered = version is not None and version < self.FIXED_VERSION
self._active = False
def _extract_repetier_version(self, name):
"""
Extracts the Repetier version number from the firmware name.
Example: "Repetier_0.91" => 0.91
"""
version = None
if "_" in name:
_, version = name.split("_", 1)
version = get_comparable_version(version, base=True)
return version
class ThermalProtectionCapCheck(Check):
"""
Firmware reporting disabled THERMAL_PROTECTION capability
"""
name = "capability"
def cap(self, cap, enabled):
if cap == "THERMAL_PROTECTION":
self._triggered = not enabled
self._active = False
@@ -30,7 +30,7 @@ from octoprint.server import VERSION, REVISION, BRANCH
from octoprint.access import USER_GROUP, ADMIN_GROUP
from octoprint.access.permissions import Permissions
from octoprint.util import dict_merge, to_unicode
from octoprint.util.version import get_comparable_version
from octoprint.util.version import get_comparable_version, get_python_version_string
from octoprint.util.pip import LocalPipCaller
import octoprint.settings
@@ -195,13 +195,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
return self._configured_checks
def _check_environment(self):
from platform import python_version
import pkg_resources
local_pip = LocalPipCaller()
# check python and setuptools version
versions = dict(python=python_version(),
versions = dict(python=get_python_version_string(),
setuptools=pkg_resources.get_distribution("setuptools").version,
pip=local_pip.version_string)
supported = get_comparable_version(versions["python"]) >= get_comparable_version(MINIMUM_PYTHON) \
+1 -1
View File
@@ -197,7 +197,7 @@ def index():
default_additional_etag = [enable_accesscontrol,
enable_gcodeviewer,
enable_timelapse]
enable_timelapse] + sorted(["{}:{}".format(k, v) for k, v in _plugin_vars.items()])
def get_preemptively_cached_view(key, view, data=None, additional_request_data=None, additional_unless=None):
if (data is None and additional_request_data is None) or g.locale is None:
+2 -1
View File
@@ -309,7 +309,8 @@ default_settings = {
"section_printer", "serial", "printerprofiles", "temperatures", "terminalfilters", "gcodescripts",
"section_features", "features", "webcam", "accesscontrol", "gcodevisualizer", "api", "plugin_appkeys",
"section_octoprint", "server", "folders", "appearance", "plugin_logging", "plugin_pluginmanager",
"plugin_softwareupdate", "plugin_announcements", "plugin_backup", "plugin_tracking", "plugin_pi_support"
"plugin_softwareupdate", "plugin_announcements", "plugin_backup", "plugin_tracking", "plugin_errortracking",
"plugin_pi_support"
],
"usersettings": ["access", "interface"],
"wizard": ["access"],
@@ -569,7 +569,9 @@ $(function() {
output.push(gettext("Filament") + ": " + layer.filament[0].toFixed(2) + "mm");
} else {
for (var i = 0; i < layer.filament.length; i++) {
output.push(gettext("Filament") + " (" + gettext("Tool") + " " + i + "): " + layer.filament[i].toFixed(2) + "mm");
if (layer.filament[i] !== undefined) {
output.push(gettext("Filament") + " (" + gettext("Tool") + " " + i + "): " + layer.filament[i].toFixed(2) + "mm");
}
}
}
}
@@ -71,12 +71,18 @@ $(function() {
self.titlePrintButton = ko.observable(self.TITLE_PRINT_BUTTON_UNPAUSED);
self.titlePauseButton = ko.observable(self.TITLE_PAUSE_BUTTON_UNPAUSED);
self.estimatedPrintTimeString = ko.pureComputed(function() {
var estimatedPrintTimeStringHlpr = function (fmt) {
if (self.lastPrintTime())
return self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime(self.lastPrintTime()) : formatDuration(self.lastPrintTime());
return fmt(self.lastPrintTime());
if (self.estimatedPrintTime())
return self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime(self.estimatedPrintTime()) : formatDuration(self.estimatedPrintTime());
return fmt(self.estimatedPrintTime());
return "-";
}
self.estimatedPrintTimeString = ko.pureComputed(function() {
return estimatedPrintTimeStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
});
self.estimatedPrintTimeExactString = ko.pureComputed(function() {
return estimatedPrintTimeStringHlpr(formatDuration);
});
self.byteString = ko.pureComputed(function() {
if (!self.filesize())
@@ -94,7 +100,7 @@ $(function() {
return "-";
return formatDuration(self.printTime());
});
self.printTimeLeftString = ko.pureComputed(function() {
var printTimeLeftStringHlpr = function (fmt) {
if (self.printTimeLeft() === undefined) {
if (!self.printTime() || !(self.isPrinting() || self.isPaused())) {
return "-";
@@ -102,8 +108,14 @@ $(function() {
return gettext("Still stabilizing...");
}
} else {
return self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime(self.printTimeLeft()) : formatDuration(self.printTimeLeft());
return fmt(self.printTimeLeft());
}
}
self.printTimeLeftString = ko.pureComputed(function() {
return printTimeLeftStringHlpr(self.settings.appearance_fuzzyTimes() ? formatFuzzyPrintTime : formatDuration);
});
self.printTimeLeftExactString = ko.pureComputed(function() {
return printTimeLeftStringHlpr(formatDuration);
});
self.printTimeLeftOriginString = ko.pureComputed(function() {
var value = self.printTimeLeftOrigin();
+2 -2
View File
@@ -10,10 +10,10 @@
<!-- ko foreach: filament -->
<span data-bind="text: 'Filament (' + name() + '): ', title: 'Filament usage for ' + name()"></span><strong data-bind="text: formatFilament(data())"></strong><br>
<!-- /ko -->
<span title="{{ _('Estimated total print time based on analysis of the file or past prints') }}">{{ _('Approx. Total Print Time') }}</span>: <strong data-bind="text: estimatedPrintTimeString"></strong><br>
<span title="{{ _('Estimated total print time based on analysis of the file or past prints') }}">{{ _('Approx. Total Print Time') }}</span>: <strong data-bind="text: estimatedPrintTimeString, attr: {title: estimatedPrintTimeExactString}"></strong><br>
<hr>
<span title="{{ _('Total print time so far') }}">{{ _('Print Time') }}</span>: <strong data-bind="text: printTimeString"></strong><br>
<span title="{{ _('Estimated time until the print job is done. This is only an estimate and accuracy depends heavily on various factors!') }}">{{ _('Print Time Left') }}</span>: <strong data-bind="text: printTimeLeftString"></strong> <span id="state_printtimeleft_popover" style="display: none" data-bind="visible: printTimeLeftOrigin, attr: {title: printTimeLeftOriginString}, css: printTimeLeftOriginClass">&#9679;</span><br>
<span title="{{ _('Estimated time until the print job is done. This is only an estimate and accuracy depends heavily on various factors!') }}">{{ _('Print Time Left') }}</span>: <strong data-bind="text: printTimeLeftString, attr: {title: printTimeLeftExactString}"></strong> <span id="state_printtimeleft_popover" style="display: none" data-bind="visible: printTimeLeftOrigin, attr: {title: printTimeLeftOriginString}, css: printTimeLeftOriginClass">&#9679;</span><br>
<span title="{{ _('Bytes printed vs total bytes of file') }}">{{ _('Printed') }}</span>: <strong data-bind="text: byteString"></strong><br>
+31
View File
@@ -118,10 +118,41 @@ def is_octoprint_compatible(*compatibility_entries, **kwargs):
return True
def get_python_version_string():
from platform import python_version
version_string = python_version()
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
if version_string.endswith("+"):
version_string = python_version[:-1]
return version_string
def get_python_version():
return get_comparable_version(get_python_version_string())
def is_python_compatible(compat, **kwargs):
if not compat:
return True
python_version = kwargs.get("python_version")
if python_version is None:
python_version = get_python_version_string()
s = pkg_resources.Requirement.parse("Python" + compat)
return python_version in s
def get_comparable_version(version_string, base=False):
if "-" in version_string:
version_string = version_string[:version_string.find("-")]
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
if version_string.endswith("+"):
version_string = version_string[:-1]
version = pkg_resources.parse_version(version_string)
# A leading v is common in github release tags and old setuptools doesn't remove it.
@@ -7,3 +7,4 @@ def callback(*args, **kwargs):
__plugin_hooks__ = {
"some.ordered.callback": (callback, 100)
}
__plugin_pythoncompat__ = ">=2.7,<4"
+2 -1
View File
@@ -13,4 +13,5 @@ class TestSecondaryDeprecatedAssetPlugin(octoprint.plugin.AssetPlugin):
__plugin_name__ = "Deprecated Plugin"
__plugin_description__ = "Test deprecated plugin"
__plugin_implementations__ = [TestDeprecatedAssetPlugin(), TestSecondaryDeprecatedAssetPlugin()]
__plugin_implementations__ = [TestDeprecatedAssetPlugin(), TestSecondaryDeprecatedAssetPlugin()]
__plugin_pythoncompat__ = ">=2.7,<4"
+1
View File
@@ -12,3 +12,4 @@ __plugin_hooks__ = {
'octoprint.core.startup': hook_startup,
'some.ordered.callback': hook_startup
}
__plugin_pythoncompat__ = ">=2.7,<4"
@@ -19,3 +19,4 @@ class TestMixedPlugin(octoprint.plugin.StartupPlugin, octoprint.plugin.SettingsP
__plugin_name__ = "Mixed Plugin"
__plugin_description__ = "Test mixed plugin"
__plugin_implementation__ = TestMixedPlugin()
__plugin_pythoncompat__ = ">=2.7,<4"
@@ -7,3 +7,4 @@ def callback(*args, **kwargs):
__plugin_hooks__ = {
"some.ordered.callback": (callback, 10)
}
__plugin_pythoncompat__ = ">=2.7,<4"
+2 -1
View File
@@ -10,4 +10,5 @@ class TestSettingsPlugin(octoprint.plugin.SettingsPlugin):
__plugin_name__ = "Settings Plugin"
__plugin_description__ = "Test settings plugin"
__plugin_implementation__ = TestSettingsPlugin()
__plugin_implementation__ = TestSettingsPlugin()
__plugin_pythoncompat__ = ">=2.7,<4"
+2
View File
@@ -15,3 +15,5 @@ class TestStartupPlugin(octoprint.plugin.StartupPlugin):
__plugin_name__ = "Startup Plugin"
__plugin_description__ = "Test startup plugin"
__plugin_implementation__ = TestStartupPlugin()
__plugin_pythoncompat__ = ">=2.7,<4"