Merge branch 'maintenance' into devel
# Conflicts: # src/octoprint/server/util/__init__.py
This commit is contained in:
commit
dc19ad4c4c
27 files changed
+599
-105
No files matched your search
+3
-3
@@ -24,10 +24,10 @@ maintenance 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
fix/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
improve/.* 1.3.10 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.7rc5
|
||||
# staging/maintenance is currently the branch for preparation of 1.3.9rc2
|
||||
# so is regressionfix/...
|
||||
staging/maintenance 1.3.9rc2 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
regressionfix/.* 1.3.9rc2 fdf0f75ffa5731fee406c6e761e84a9d2b47aa43 pep440-dev
|
||||
staging/maintenance 1.3.9rc3 fd94fc94a09dd91deeb2f59a6b3b00b37eb1f145 pep440-dev
|
||||
regressionfix/.* 1.3.9rc3 fd94fc94a09dd91deeb2f59a6b3b00b37eb1f145 pep440-dev
|
||||
|
||||
# every other branch is a development branch and thus gets resolved to 1.4.0-dev for now
|
||||
.* 1.4.0 7f5d03d0549bcbd26f40e7e4a3297ea5204fb1cc pep440-dev
|
||||
@@ -1,5 +1,20 @@
|
||||
# OctoPrint Changelog
|
||||
|
||||
## 1.3.9rc2 (2018-07-06)
|
||||
|
||||
### Improvements
|
||||
|
||||
* Add sanity check for disabled plugin list (see also [#2687 (comment)](https://github.com/foosel/OctoPrint/issues/2687#issuecomment-399797596)).
|
||||
* Improve logging of exceptions triggered inside the state update worker (see also [#2715](https://github.com/foosel/OctoPrint/issues/2715)).
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* [#2715](https://github.com/foosel/OctoPrint/issues/2715) (regression) - Fix broken estimator initialization on SD print start and resulting crash of the state update worker.
|
||||
|
||||
### More information
|
||||
|
||||
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.9rc1...1.3.9rc2)
|
||||
|
||||
## 1.3.9rc1 (2018-06-20)
|
||||
|
||||
### Note for upgraders running NGINX as reverse proxy: Be sure to configure HTTP protocol version 1.1
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
# OctoPrint
|
||||
|
||||
[](https://badge.fury.io/gh/foosel%2FOctoPrint)
|
||||
|
||||

|
||||
[](https://travis-ci.org/foosel/OctoPrint)
|
||||
[](https://discourse.octoprint.org)
|
||||
[](https://chat.octoprint.org)
|
||||
[](https://twitter.com/OctoPrint3d)
|
||||
|
||||
|
||||
OctoPrint provides a snappy web interface for controlling consumer 3D printers. It is Free Software
|
||||
and released under the [GNU Affero General Public License V3](http://www.gnu.org/licenses/agpl.html).
|
||||
@@ -9,6 +15,8 @@ Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=gi
|
||||
|
||||
The community forum is available at [discourse.octoprint.org](https://discourse.octoprint.org/?utm_source=github&utm_medium=readme).
|
||||
|
||||
The official IRC channel is [#octoprint on freenode](https://chat.octoprint.org). Its logs can be found [here](https://freenode.logbot.info/octoprint).
|
||||
|
||||
The FAQ can be accessed by following [faq.octoprint.org](https://faq.octoprint.org/?utm_source=github&utm_medium=readme).
|
||||
|
||||
The documentation is located at [docs.octoprint.org](http://docs.octoprint.org).
|
||||
|
||||
+4
-3
@@ -1,7 +1,7 @@
|
||||
# Supporters
|
||||
|
||||
Development of this version of OctoPrint wouldn't have been possible without
|
||||
[financial support by the community](http://octoprint.org/support-octoprint/) -
|
||||
[the financial support by the community](https://octoprint.org/support-octoprint/) -
|
||||
thanks to everyone who contributed!
|
||||
|
||||
## Patreon Patrons
|
||||
@@ -30,10 +30,12 @@ thanks to everyone who contributed!
|
||||
* Jeremiah Avery
|
||||
* Josh Daniels
|
||||
* Joshua Wills
|
||||
* Justin Kaufman
|
||||
* Kaile Riser
|
||||
* Kale Stedman
|
||||
* Kazuhiro Ogura
|
||||
* Kodama Inc.
|
||||
* Lewis Newby
|
||||
* LulzBot®
|
||||
* Makespace Madrid
|
||||
* Mark Walker
|
||||
@@ -51,11 +53,10 @@ thanks to everyone who contributed!
|
||||
* Samer Najia
|
||||
* Simon Hallam
|
||||
* Stefan Krister
|
||||
* Stephane Schittly
|
||||
* Sven Mueller
|
||||
* Symbiotic Devices
|
||||
* Thomas Hatley
|
||||
* Timothy D Hoogland
|
||||
* Trent Shumay
|
||||
|
||||
and 1334 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
and 1332 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
|
||||
@@ -82,7 +82,6 @@ def run_server(basedir, configfile, host, port, debug, allow_root, logging_confi
|
||||
ignore_blacklist=ignore_blacklist,
|
||||
after_safe_mode=log_startup,
|
||||
after_environment_detector=log_register_rollover)
|
||||
|
||||
settings, _, safe_mode, event_manager, connectivity_checker, plugin_manager, environment_detector = components
|
||||
|
||||
except FatalStartupError as e:
|
||||
|
||||
@@ -298,7 +298,7 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
- * **Key**
|
||||
* **Description**
|
||||
- * ``estimatedPrintTime``
|
||||
* Estimated time the file take to print, in minutes
|
||||
* Estimated time the file take to print, in seconds
|
||||
- * ``filament``
|
||||
* Substructure describing estimated filament usage. Keys are ``tool0`` for the first extruder, ``tool1`` for
|
||||
the second and so on. For each tool extruded length and volume (based on diameter) are provided.
|
||||
|
||||
@@ -1986,7 +1986,7 @@ class SlicerPlugin(OctoPrintPlugin):
|
||||
For jobs that finished successfully, ``result`` should be a :class:`dict` containing additional information
|
||||
about the slicing job under the following keys:
|
||||
|
||||
_analysis
|
||||
analysis
|
||||
Analysis result of the generated machine code as returned by the slicer itself. This should match the
|
||||
data structure described for the analysis queue of the matching machine code format, e.g.
|
||||
:class:`~octoprint.filemanager.analysis.GcodeAnalysisQueue` for GCODE files.
|
||||
|
||||
@@ -477,6 +477,11 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._plugin_manager.log_all_plugins()
|
||||
|
||||
self._logger.info("The plugin was installed successfully: {}, version {}".format(new_plugin.name, new_plugin.version))
|
||||
self._event_bus.fire("plugin_pluginmanager_installplugin", dict(id=new_plugin.key,
|
||||
version=new_plugin.version,
|
||||
source=source,
|
||||
source_type=source_type))
|
||||
|
||||
result = dict(result=True,
|
||||
source=source,
|
||||
source_type=source_type,
|
||||
@@ -567,6 +572,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
|
||||
self._plugin_manager.reload_plugins()
|
||||
|
||||
self._event_bus.fire("plugin_pluginmanager_uninstallplugin", dict(id=plugin.key,
|
||||
version=plugin.version))
|
||||
|
||||
result = dict(result=True,
|
||||
needs_restart=needs_restart,
|
||||
needs_refresh=needs_refresh,
|
||||
@@ -685,12 +693,15 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
if strip:
|
||||
lines = map(lambda x: x.strip(), lines)
|
||||
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(type="loglines", loglines=[dict(line=line, stream=stream) for line in lines]))
|
||||
self._plugin_manager.send_plugin_message(self._identifier, dict(type="loglines",
|
||||
loglines=[dict(line=line, stream=stream) for line in lines]))
|
||||
for line in lines:
|
||||
self._console_logger.debug(u"{prefix} {line}".format(**locals()))
|
||||
|
||||
def _mark_plugin_enabled(self, plugin, needs_restart=False):
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"]))
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"],
|
||||
validator=lambda x: isinstance(x, list),
|
||||
fallback=[]))
|
||||
if plugin.key in disabled_list:
|
||||
disabled_list.remove(plugin.key)
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
@@ -704,8 +715,13 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
elif not plugin.enabled and plugin.key not in self._pending_enable:
|
||||
self._pending_enable.add(plugin.key)
|
||||
|
||||
self._event_bus.fire("plugin_pluginmanager_enableplugin", dict(id=plugin.key,
|
||||
version=plugin.version))
|
||||
|
||||
def _mark_plugin_disabled(self, plugin, needs_restart=False):
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"]))
|
||||
disabled_list = list(self._settings.global_get(["plugins", "_disabled"],
|
||||
validator=lambda x: isinstance(x, list),
|
||||
fallback=[]))
|
||||
if not plugin.key in disabled_list:
|
||||
disabled_list.append(plugin.key)
|
||||
self._settings.global_set(["plugins", "_disabled"], disabled_list)
|
||||
@@ -719,6 +735,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
elif (plugin.enabled or plugin.forced_disabled or getattr(plugin, "safe_mode_victim", False)) and plugin.key not in self._pending_disable:
|
||||
self._pending_disable.add(plugin.key)
|
||||
|
||||
self._event_bus.fire("plugin_pluginmanager_disableplugin", dict(id=plugin.key,
|
||||
version=plugin.version))
|
||||
|
||||
def _fetch_all_data(self, async=False):
|
||||
def run():
|
||||
self._repository_available = self._fetch_repository_from_disk()
|
||||
|
||||
@@ -80,7 +80,7 @@ def perform_update(target, check, target_version, log_cb=None, online=True, forc
|
||||
install_arg = check["pip"].format(target_version=target_version, target=target_version)
|
||||
|
||||
logger.debug(u"Target: %s, executing pip install %s" % (target, install_arg))
|
||||
pip_args = ["install", install_arg]
|
||||
pip_args = ["install", install_arg, "--no-cache-dir"]
|
||||
pip_kwargs = dict()
|
||||
if pip_working_directory is not None:
|
||||
pip_kwargs.update(cwd=pip_working_directory)
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
# 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) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
from flask.ext.babel import gettext
|
||||
|
||||
import requests
|
||||
import hashlib
|
||||
import logging
|
||||
|
||||
# noinspection PyCompatibility
|
||||
import concurrent.futures
|
||||
|
||||
from octoprint.util import RepeatedTimer
|
||||
from octoprint.util.version import get_octoprint_version_string
|
||||
from octoprint.events import Events
|
||||
|
||||
TRACKING_URL = "https://tracking.octoprint.org/track/{id}/{event}/?{args}"
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
octoprint.plugin.EnvironmentDetectionPlugin,
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.AssetPlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin):
|
||||
|
||||
def __init__(self):
|
||||
self._environment = None
|
||||
self._url = None
|
||||
self._ping_worker = None
|
||||
self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
def initialize(self):
|
||||
self._init_tracking()
|
||||
|
||||
##~~ SettingsPlugin
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(enabled=None,
|
||||
unique_id=None,
|
||||
server=TRACKING_URL,
|
||||
ping=15*60)
|
||||
|
||||
def on_settings_save(self, data):
|
||||
enabled = self._settings.get([b"enabled"])
|
||||
|
||||
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||
|
||||
if enabled is None and self._settings.get([b"enabled"]):
|
||||
# tracking was just enabled, let's init it and send a startup event
|
||||
self._init_tracking()
|
||||
self._track_startup()
|
||||
|
||||
##~~ EnvironmentDetectionPlugin
|
||||
|
||||
def on_environment_detected(self, environment, *args, **kwargs):
|
||||
self._environment = environment
|
||||
|
||||
##~~ StartupPlugin
|
||||
|
||||
def on_after_startup(self):
|
||||
self._track_startup()
|
||||
|
||||
ping = self._settings.get_int(["ping"])
|
||||
if ping:
|
||||
self._ping_worker = RepeatedTimer(ping, self._track_ping)
|
||||
self._ping_worker.start()
|
||||
|
||||
##~~ EventHandlerPlugin
|
||||
|
||||
def on_event(self, event, payload):
|
||||
if event.startswith("plugin_pluginmanager_"):
|
||||
self._track_plugin_event(event, payload)
|
||||
elif event in (Events.PRINT_STARTED, Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED):
|
||||
self._track_printjob_event(event, payload)
|
||||
|
||||
##~~ TemplatePlugin
|
||||
|
||||
def get_template_configs(self):
|
||||
return [
|
||||
dict(type="settings", name=gettext("Anonymous Usage Tracking"), template="tracking_settings.jinja2", custom_bindings=False),
|
||||
dict(type="wizard", name=gettext("Anonymous Usage Tracking"), template="tracking_wizard.jinja2", custom_bindings=True, mandatory=True)
|
||||
]
|
||||
|
||||
##~~ AssetPlugin
|
||||
|
||||
def get_assets(self):
|
||||
return dict(js=["js/tracking.js"])
|
||||
|
||||
##~~ WizardPlugin
|
||||
|
||||
def is_wizard_required(self):
|
||||
return self._settings.get([b"enabled"]) is None
|
||||
|
||||
##~~ helpers
|
||||
|
||||
def _init_tracking(self):
|
||||
if not self._settings.get_boolean([b"enabled"]):
|
||||
return
|
||||
self._init_id()
|
||||
self._logger.info("Initialized anonymous tracking")
|
||||
|
||||
def _init_id(self):
|
||||
if self._settings.get_boolean([b"enabled"]) and not self._settings.get([b"unique_id"]):
|
||||
import uuid
|
||||
self._settings.set([b"unique_id"], str(uuid.uuid4()))
|
||||
self._settings.save()
|
||||
|
||||
def _track_startup(self):
|
||||
self._track("startup",
|
||||
version=get_octoprint_version_string(),
|
||||
os=self._environment[b"os"][b"id"])
|
||||
|
||||
def _track_ping(self):
|
||||
self._track("ping")
|
||||
|
||||
def _track_plugin_event(self, event, payload):
|
||||
if event.endswith("_installplugin"):
|
||||
self._track("install_plugin", plugin=payload.get(b"id"), plugin_version=payload.get(b"version"))
|
||||
elif event.endswith("_uninstallplugin"):
|
||||
self._track("uninstall_plugin", plugin=payload.get(b"id"), plugin_version=payload.get(b"version"))
|
||||
elif event.endswith("_enableplugin"):
|
||||
self._track("enable_plugin", plugin=payload.get(b"id"), plugin_version=payload.get(b"version"))
|
||||
elif event.endswith("_disableplugin"):
|
||||
self._track("disable_plugin", plugin=payload.get(b"id"), plugin_version=payload.get(b"version"))
|
||||
|
||||
def _track_printjob_event(self, event, payload):
|
||||
sha = hashlib.sha1()
|
||||
sha.update(payload.get("name"))
|
||||
|
||||
event = None
|
||||
args = dict(origin=payload.get(b"origin"), file=sha.hexdigest())
|
||||
|
||||
if event == Events.PRINT_STARTED:
|
||||
event = "print_started"
|
||||
elif event == Events.PRINT_DONE:
|
||||
try:
|
||||
elapsed = int(payload.get(b"time"))
|
||||
except ValueError:
|
||||
elapsed = "unknown"
|
||||
args[b"elapsed"] = elapsed
|
||||
event = "print_done"
|
||||
elif event == Events.PRINT_FAILED:
|
||||
event = "print_failed"
|
||||
elif event == Events.PRINT_CANCELLED:
|
||||
event = "print_cancelled"
|
||||
|
||||
if event is not None:
|
||||
self._track(event, **args)
|
||||
|
||||
def _track(self, event, **kwargs):
|
||||
if not self._settings.get_boolean([b"enabled"]):
|
||||
return
|
||||
|
||||
self._executor.submit(self._do_track, event, **kwargs)
|
||||
|
||||
def _do_track(self, event, **kwargs):
|
||||
server = self._settings.get([b"server"])
|
||||
url = server.format(id=self._settings.get([b"unique_id"]),
|
||||
event=event,
|
||||
args="&".join(map(lambda x: "{}={}".format(x[0], x[1]), kwargs.items())))
|
||||
|
||||
headers = {"User-Agent": "OctoPrint/{}".format(get_octoprint_version_string())}
|
||||
try:
|
||||
requests.get(url,
|
||||
timeout=3.1,
|
||||
headers=headers)
|
||||
self._logger.debug("Sent tracking event to {}".format(url))
|
||||
except:
|
||||
if self._logger.isEnabledFor(logging.DEBUG):
|
||||
self._logger.exception("Error while sending event to anonymous usage tracking".format(url))
|
||||
else:
|
||||
pass
|
||||
|
||||
__plugin_name__ = "Anonymous Usage Tracking"
|
||||
__plugin_description__ = "Anonymous version and usage tracking, see homepage for details on what gets tracked"
|
||||
__plugin_homepage__ = "https://tracking.octoprint.org"
|
||||
__plugin_author__ = "Gina Häußge"
|
||||
|
||||
__plugin_implementation__ = TrackingPlugin()
|
||||
@@ -0,0 +1,85 @@
|
||||
$(function() {
|
||||
function TrackingViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.settingsViewModel = parameters[0];
|
||||
|
||||
self.setup = ko.observable(false);
|
||||
|
||||
self.decision = ko.observable();
|
||||
self.required = false;
|
||||
self.active = false;
|
||||
|
||||
self.enableTracking = function() {
|
||||
self.settingsViewModel.settings.plugins.tracking.enabled(true);
|
||||
self.decision(true);
|
||||
self._sendData();
|
||||
};
|
||||
|
||||
self.disableTracking = function() {
|
||||
self.settingsViewModel.settings.plugins.tracking.enabled(false);
|
||||
self.decision(false);
|
||||
self._sendData();
|
||||
};
|
||||
|
||||
self.onBeforeWizardTabChange = function(next, current) {
|
||||
if (!self.required) return true;
|
||||
|
||||
if (!current || !_.startsWith(current, "wizard_plugin_tracking") || self.setup()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self._showDecisionNeededDialog();
|
||||
return false;
|
||||
};
|
||||
|
||||
self.onBeforeWizardFinish = function() {
|
||||
if (!self.required) return true;
|
||||
|
||||
if (self.setup()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self._showDecisionNeededDialog();
|
||||
return false;
|
||||
};
|
||||
|
||||
self.onWizardPreventSettingsRefreshDialog = function() {
|
||||
return self.active;
|
||||
};
|
||||
|
||||
self.onWizardDetails = function(response) {
|
||||
self.required = response && response.tracking && response.tracking.required;
|
||||
};
|
||||
|
||||
self._showDecisionNeededDialog = function() {
|
||||
showMessageDialog({
|
||||
title: gettext("Please set up anonymous usage tracking"),
|
||||
message: gettext("You haven't yet decided on whether to enable or disable anonymous usage tracking. You need to either enable or disable it before continuing.")
|
||||
});
|
||||
};
|
||||
|
||||
self._sendData = function() {
|
||||
var data = {
|
||||
plugins: {
|
||||
tracking: {
|
||||
enabled: self.settingsViewModel.settings.plugins.tracking.enabled()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.active = true;
|
||||
self.settingsViewModel.saveData(data)
|
||||
.done(function() {
|
||||
self.setup(true);
|
||||
self.active = false;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
TrackingViewModel,
|
||||
["settingsViewModel"],
|
||||
"#wizard_plugin_tracking"
|
||||
]);
|
||||
});
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{% trans %}
|
||||
<p>
|
||||
Anonymous usage tracking 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.
|
||||
</p>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
{% endtrans %}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<p>{% trans %}
|
||||
For details on what gets tracked, please refer to <a href="https://tracking.octoprint.org" target="_blank" rel="noopener noreferrer">tracking.octoprint.org</a>
|
||||
and also the <a href="https://tracking.octoprint.org/privacy" target="_blank" rel="noopener noreferrer">Privacy Policy at tracking.octoprint.org</a>.
|
||||
{% endtrans %}</p>
|
||||
@@ -0,0 +1,21 @@
|
||||
<h3>{{ _('Anonymous Usage Tracking') }}</h3>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDescription.jinja2" %}
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: settings.plugins.tracking.enabled"> {{ _('Enable anonymous usage tracking') }}
|
||||
</label>
|
||||
</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.tracking.unique_id() || 'N/A'"></span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDetails.jinja2" %}
|
||||
@@ -0,0 +1,19 @@
|
||||
<h3>{{ _('Configure Anonymous Usage Tracking') }}</h3>
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDescription.jinja2" %}
|
||||
|
||||
{% include "snippets/plugins/tracking/trackingDetails.jinja2" %}
|
||||
|
||||
<div class="row-fluid">
|
||||
<a href="#" class="btn btn-danger span6" data-bind="click: function() { if(!setup()){disableTracking()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Disable Anonymous Usage Tracking') }}</a>
|
||||
<a href="#" class="btn btn-primary span6" data-bind="click: function() { if(!setup()){enableTracking()}}, enable: !setup(), css: {disabled: setup()}">{{ _('Enable Anonymous Usage Tracking') }}</a>
|
||||
</div>
|
||||
|
||||
<div class="tracking_decision" style="display: none" data-bind="visible: setup()">
|
||||
<div class="text-center" style="display: none" data-bind="visible: decision()">{% trans %}
|
||||
Anonymous Usage Tracking is <strong class="text-success">enabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
<div class="text-center" style="display: none" data-bind="visible: !decision()">{% trans %}
|
||||
Anonymous Usage Tracking is <strong class="text-danger">disabled</strong>.
|
||||
{% endtrans %}</div>
|
||||
</div>
|
||||
@@ -82,6 +82,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._selectedFile = None
|
||||
|
||||
self._estimator_factory = PrintTimeEstimator
|
||||
self._estimator = None
|
||||
analysis_queue_hooks = plugin_manager().get_hooks("octoprint.printer.estimation.factory")
|
||||
for name, hook in analysis_queue_hooks.items():
|
||||
try:
|
||||
@@ -134,7 +135,17 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
eventManager().subscribe(Events.METADATA_ANALYSIS_FINISHED, self._on_event_MetadataAnalysisFinished)
|
||||
eventManager().subscribe(Events.METADATA_STATISTICS_UPDATED, self._on_event_MetadataStatisticsUpdated)
|
||||
|
||||
def _create_estimator(self, job_type):
|
||||
def _create_estimator(self, job_type=None):
|
||||
if job_type is None:
|
||||
with self._selectedFileMutex:
|
||||
if self._selectedFile is None:
|
||||
return
|
||||
|
||||
if self._selectedFile["sd"]:
|
||||
job_type = "sdcard"
|
||||
else:
|
||||
job_type = "local"
|
||||
|
||||
self._estimator = self._estimator_factory(job_type)
|
||||
|
||||
#~~ handling of PrinterCallbacks
|
||||
@@ -499,12 +510,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
if self._selectedFile is None:
|
||||
return
|
||||
|
||||
if self._selectedFile["sd"]:
|
||||
job_type = "sdcard"
|
||||
else:
|
||||
job_type = "local"
|
||||
|
||||
self._create_estimator(job_type)
|
||||
self._fileManager.delete_recovery_data()
|
||||
|
||||
self._lastProgressReport = None
|
||||
@@ -754,6 +759,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
cleanedPrintTime = self._comm.getCleanedPrintTime()
|
||||
|
||||
printTimeLeft = printTimeLeftOrigin = None
|
||||
estimator = self._estimator
|
||||
if progress is not None:
|
||||
progress_int = int(progress * 100)
|
||||
if self._lastProgressReport != progress_int:
|
||||
@@ -766,7 +772,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
elif progress == 1.0:
|
||||
printTimeLeft = 0
|
||||
printTimeLeftOrigin = None
|
||||
else:
|
||||
elif estimator is not None:
|
||||
statisticalTotalPrintTime = None
|
||||
statisticalTotalPrintTimeType = None
|
||||
with self._selectedFileMutex:
|
||||
@@ -775,11 +781,11 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
statisticalTotalPrintTime = self._selectedFile["estimatedPrintTime"]
|
||||
statisticalTotalPrintTimeType = self._selectedFile.get("estimatedPrintTimeType", None)
|
||||
|
||||
printTimeLeft, printTimeLeftOrigin = self._estimator.estimate(progress,
|
||||
printTime,
|
||||
cleanedPrintTime,
|
||||
statisticalTotalPrintTime,
|
||||
statisticalTotalPrintTimeType)
|
||||
printTimeLeft, printTimeLeftOrigin = estimator.estimate(progress,
|
||||
printTime,
|
||||
cleanedPrintTime,
|
||||
statisticalTotalPrintTime,
|
||||
statisticalTotalPrintTimeType)
|
||||
|
||||
return self._dict(completion=progress * 100 if progress is not None else None,
|
||||
filepos=filepos,
|
||||
@@ -1036,14 +1042,19 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
else:
|
||||
eventManager().fire(Events.FILE_DESELECTED)
|
||||
|
||||
self._create_estimator()
|
||||
|
||||
self._setJobData(full_path, size, sd, user=user)
|
||||
self._stateMonitor.set_state(self._dict(text=self.get_state_string(), flags=self._getStateFlags()))
|
||||
|
||||
self._create_estimator()
|
||||
|
||||
if self._printAfterSelect:
|
||||
self._printAfterSelect = False
|
||||
self.start_print(pos=self._posAfterSelect, user=user)
|
||||
|
||||
def on_comm_print_job_started(self, suppress_script=False):
|
||||
self._stateMonitor.trigger_progress_update()
|
||||
payload = self._payload_for_print_job_event()
|
||||
if payload:
|
||||
eventManager().fire(Events.PRINT_STARTED, payload)
|
||||
@@ -1310,20 +1321,23 @@ class StateMonitor(object):
|
||||
self._change_event.set()
|
||||
|
||||
def _work(self):
|
||||
while True:
|
||||
self._change_event.wait()
|
||||
try:
|
||||
while True:
|
||||
self._change_event.wait()
|
||||
|
||||
now = time.time()
|
||||
delta = now - self._last_update
|
||||
additional_wait_time = self._interval - delta
|
||||
if additional_wait_time > 0:
|
||||
time.sleep(additional_wait_time)
|
||||
now = time.time()
|
||||
delta = now - self._last_update
|
||||
additional_wait_time = self._interval - delta
|
||||
if additional_wait_time > 0:
|
||||
time.sleep(additional_wait_time)
|
||||
|
||||
with self._state_lock:
|
||||
data = self.get_current_data()
|
||||
self._update_callback(data)
|
||||
self._last_update = time.time()
|
||||
self._change_event.clear()
|
||||
with self._state_lock:
|
||||
data = self.get_current_data()
|
||||
self._update_callback(data)
|
||||
self._last_update = time.time()
|
||||
self._change_event.clear()
|
||||
except:
|
||||
logging.getLogger(__name__).exception("Looks like something crashed inside the state update worker. Please report this on the OctoPrint issue tracker (make sure to include logs!)")
|
||||
|
||||
def get_current_data(self):
|
||||
with self._progress_lock:
|
||||
|
||||
@@ -92,6 +92,7 @@ def getSettings():
|
||||
"name": s.get(["appearance", "name"]),
|
||||
"color": s.get(["appearance", "color"]),
|
||||
"colorTransparent": s.getBoolean(["appearance", "colorTransparent"]),
|
||||
"colorIcon": s.getBoolean(["appearance", "colorIcon"]),
|
||||
"defaultLanguage": s.get(["appearance", "defaultLanguage"]),
|
||||
"showFahrenheitAlso": s.getBoolean(["appearance", "showFahrenheitAlso"])
|
||||
},
|
||||
@@ -378,6 +379,7 @@ def _saveSettings(data):
|
||||
if "name" in data["appearance"]: s.set(["appearance", "name"], data["appearance"]["name"])
|
||||
if "color" in data["appearance"]: s.set(["appearance", "color"], data["appearance"]["color"])
|
||||
if "colorTransparent" in data["appearance"]: s.setBoolean(["appearance", "colorTransparent"], data["appearance"]["colorTransparent"])
|
||||
if "colorIcon" in data["appearance"]: s.setBoolean(["appearance", "colorIcon"], data["appearance"]["colorIcon"])
|
||||
if "defaultLanguage" in data["appearance"]: s.set(["appearance", "defaultLanguage"], data["appearance"]["defaultLanguage"])
|
||||
if "showFahrenheitAlso" in data["appearance"]: s.setBoolean(["appearance", "showFahrenheitAlso"], data["appearance"]["showFahrenheitAlso"])
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def enforceApiKeyRequestHandler():
|
||||
|
||||
apikey = get_api_key(_flask.request)
|
||||
|
||||
if apikey is None and settings().getBoolean(["api", "keyEnforced"]):
|
||||
if not apikey and settings().getBoolean(["api", "keyEnforced"]):
|
||||
return _flask.make_response("No API key provided", 403)
|
||||
|
||||
if apikey != octoprint.server.UI_API_KEY and not settings().getBoolean(["api", "enabled"]):
|
||||
|
||||
+16
-10
@@ -279,6 +279,7 @@ default_settings = {
|
||||
"name": "",
|
||||
"color": "default",
|
||||
"colorTransparent": False,
|
||||
"colorIcon": True,
|
||||
"defaultLanguage": "_default",
|
||||
"showFahrenheitAlso": False,
|
||||
"components": {
|
||||
@@ -1429,17 +1430,22 @@ class Settings(object):
|
||||
#~~ getter
|
||||
|
||||
def get(self, path, **kwargs):
|
||||
error_on_path = kwargs.get("error_on_path", False)
|
||||
new_kwargs = dict(kwargs)
|
||||
if "error_on_path" in new_kwargs:
|
||||
del new_kwargs["error_on_path"]
|
||||
error_on_path = kwargs.pop("error_on_path", False)
|
||||
validator = kwargs.pop("validator", None)
|
||||
fallback = kwargs.pop("fallback", None)
|
||||
|
||||
try:
|
||||
return self._get_value(path, **new_kwargs)
|
||||
except NoSuchSettingsPath:
|
||||
if error_on_path:
|
||||
raise
|
||||
return None
|
||||
def process():
|
||||
try:
|
||||
return self._get_value(path, **kwargs)
|
||||
except NoSuchSettingsPath:
|
||||
if error_on_path:
|
||||
raise
|
||||
return None
|
||||
|
||||
result = process()
|
||||
if callable(validator) and not validator(result):
|
||||
result = fallback
|
||||
return result
|
||||
|
||||
def getInt(self, path, **kwargs):
|
||||
minimum = kwargs.pop("min", None)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="svg8868" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 107.1 107.1" style="enable-background:new 0 0 107.1 107.1;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#13C100;}
|
||||
.st1{fill:#169300;}
|
||||
</style>
|
||||
<title>mask-theme</title>
|
||||
<g id="g19353">
|
||||
<g id="g19426">
|
||||
<g id="g4632-4">
|
||||
<path id="path3017-3" class="st0" d="M56.7,4.7c-14.4,0.3-27.4,5.5-39.2,16c-7,5.7-12.3,13.2-15.4,21.6
|
||||
c-2.5,11.4-2.7,23.3-0.6,34.8c1.3,7.1,4,15.4,8.1,25.2h28.8c-1.5-4.8-3.5-9.4-5.8-13.8C24.8,74,23,59.8,27.4,46.2
|
||||
c1.7-4.3,3.9-8.4,6.6-12.1c1.1-1.5,2.3-2.8,3.7-4c1.8-2,6-4.6,12.6-7.9c2.6-1.3,5.5-2.3,8.4-2.9c0.4-0.1,2.8-0.5,7.1-1
|
||||
c2.8-0.3,6.7,0.1,11.6,1.5c3.8,1,7.3,2.5,10.6,4.6c3,2.1,5.7,4.6,8.2,7.3c0.6,0.6,1.1,1.3,1.5,2c0.8,1,2,2.5,3.4,4.5
|
||||
c0.7,0.4,1.2,1,1.5,1.8c0.3,0.3,0.5,0.5,0.8,0.8c0.8,1.1,1.5,2.2,2.2,3.2c0.5,0.8,0.9,1.7,1.3,2.6c0.5-3.3,0.3-6.8-0.6-10
|
||||
c-1.2-4.9-2.7-8.2-4.3-10.4c-3.5-4.2-5.5-6.8-6.4-7.6c-0.2-0.3-2.1-1.6-5.7-4.2c-3.2-2.3-6.6-4.2-10.2-5.6
|
||||
C72.3,5.9,64.5,4.5,56.7,4.7z"/>
|
||||
<path id="path3101-9" class="st1" d="M68,18.2c-0.8,0-1.6,0-2.3,0.1c-4.3,0.5-6.8,0.8-7.2,1c-2.9,0.6-5.7,1.5-8.4,2.9
|
||||
C43.6,25.5,39.4,28,37.6,30c-1.4,1.2-2.6,2.5-3.7,4c-2.7,3.8-4.9,7.9-6.5,12.2C23,59.8,24.8,74,32.6,88.5c2.3,4.4,4.2,9,5.8,13.8
|
||||
h29.1c-1.3-3.7-2.9-7.3-4.8-10.7c-1.7-3.3-3.6-6.7-5.8-10.2c0,0,0-0.1,0-0.1c0,0,0,0,0,0c-0.3-0.6-0.6-1.1-1.1-1.6l-0.6-0.8
|
||||
l-1.2-1.7c-0.5-0.9-1-1.8-1.4-2.5c-1.7-2.3-3-4.2-4-5.6c-0.9-1.5-1.8-2.9-2.6-4.3c-7.6-11.2-7-20.8,2-29c2.7-2.2,5.8-4,9.1-5.3
|
||||
c2.2-0.9,4.4-1.6,6.7-2.2c15.8-2.1,29.8,3.2,41.8,15.7c-0.7-1-1.4-2.1-2.2-3.2c-0.3-0.3-0.5-0.5-0.8-0.8
|
||||
c-0.3-0.7-0.8-1.4-1.5-1.7c-1.5-2-2.6-3.5-3.4-4.5c-0.4-0.7-0.9-1.4-1.5-2c-2.4-2.7-5.2-5.2-8.2-7.3c-3.3-2.1-6.8-3.7-10.6-4.6
|
||||
C74.3,18.9,71.2,18.4,68,18.2z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.0 KiB |
File renamed without changes.
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
@@ -1,10 +1,96 @@
|
||||
$(function() {
|
||||
var save = {};
|
||||
|
||||
// Using the theme color (for the top bar), also recolor the favicon tentacle.
|
||||
function themeFavicon(colorname) {
|
||||
save.colorName = colorname;
|
||||
|
||||
// the following is from an Apache licensed snippet:
|
||||
// http://blog.roomanna.com/09-24-2011/dynamically-coloring-a-favicon
|
||||
var link = document.querySelector("link[rel='shortcut icon']");
|
||||
if (!link) {
|
||||
link = document.createElement("link");
|
||||
link.setAttribute("rel", "shortcut icon");
|
||||
document.head.appendChild(link);
|
||||
}
|
||||
|
||||
// try to get the best quality ico possible; prefer svg, the apple-touch pngs are more difficult,
|
||||
// but all three of the others give a high-quality ico.
|
||||
var faviconUrl = document.querySelector("link[rel~='mask-icon-theme']").href
|
||||
|| link.href
|
||||
|| window.location.origin + "/favicon.ico";
|
||||
|
||||
function onImageLoaded() {
|
||||
var icosize = 256;
|
||||
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.width = icosize;
|
||||
canvas.height = icosize;
|
||||
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
function grayscale() {
|
||||
var imageData = context.getImageData(0, 0, canvas.width, canvas.height),
|
||||
pixels = imageData.data,
|
||||
i, l, r, g, b, a, luma;
|
||||
|
||||
for (i = 0, l = pixels.length; i < l; i += 4) {
|
||||
a = pixels[i + 3];
|
||||
if (a === 0) { continue; }
|
||||
|
||||
r = pixels[i];
|
||||
g = pixels[i + 1];
|
||||
b = pixels[i + 2];
|
||||
|
||||
luma = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
||||
|
||||
pixels[i] = pixels[i + 1] = pixels[i + 2] = luma;
|
||||
}
|
||||
|
||||
context.putImageData(imageData, 0, 0);
|
||||
}
|
||||
|
||||
function colorize(color, alpha) {
|
||||
context.globalCompositeOperation = "source-atop";
|
||||
context.globalAlpha = alpha;
|
||||
context.fillStyle = color;
|
||||
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||
context.globalCompositeOperation = "source-over";
|
||||
context.globalAlpha = 1.0;
|
||||
}
|
||||
|
||||
context.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
if (save.colorName !== "default") {
|
||||
grayscale();
|
||||
colorize(save.colorName, .3);
|
||||
}
|
||||
link.type = "image/x-icon";
|
||||
link.href = canvas.toDataURL();
|
||||
}
|
||||
|
||||
var img = document.createElement("img");
|
||||
img.addEventListener("load", onImageLoaded);
|
||||
img.src = faviconUrl;
|
||||
}
|
||||
|
||||
function AppearanceViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
self.name = parameters[0].appearance_name;
|
||||
self.color = parameters[0].appearance_color;
|
||||
self.colorTransparent = parameters[0].appearance_colorTransparent;
|
||||
self.colorIcon = parameters[0].appearance_colorIcon;
|
||||
|
||||
function updateIcon() {
|
||||
if (self.colorIcon()) {
|
||||
themeFavicon(self.color());
|
||||
} else {
|
||||
themeFavicon("default");
|
||||
}
|
||||
}
|
||||
self.color.subscribe(updateIcon);
|
||||
self.colorIcon.subscribe(updateIcon);
|
||||
updateIcon();
|
||||
|
||||
self.brand = ko.pureComputed(function() {
|
||||
if (self.name())
|
||||
|
||||
@@ -116,6 +116,7 @@ $(function() {
|
||||
self.appearance_name = ko.observable(undefined);
|
||||
self.appearance_color = ko.observable(undefined);
|
||||
self.appearance_colorTransparent = ko.observable();
|
||||
self.appearance_colorIcon = ko.observable();
|
||||
self.appearance_defaultLanguage = ko.observable();
|
||||
self.appearance_showFahrenheitAlso = ko.observable(undefined);
|
||||
|
||||
|
||||
@@ -15,7 +15,14 @@
|
||||
<div class="control-group" title="{{ _('For acrylic printers ;)') }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: appearance_colorTransparent"> {{ _('Transparent Color') }}
|
||||
<input type="checkbox" data-bind="checked: appearance_colorTransparent"> {{ _('Transparent color') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Also personalize the icon of the browser tab') }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: appearance_colorIcon"> {{ _('Colorize favicon (in supported browsers)') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
<title data-bind="text: title">OctoPrint</title>
|
||||
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='img/tentacle-32x32.png') }}">
|
||||
<link rel="mask-icon" href="{{ url_for('static', filename='img/favicon.svg') }}" color="#56BE37">
|
||||
<link rel="mask-icon" href="{{ url_for('static', filename='img/mask.svg') }}" color="#56BE37">
|
||||
<link rel="mask-icon-theme" href="{{ url_for('static', filename='img/mask-theme.svg') }}" color="#56BE37">
|
||||
<link rel="apple-touch-icon" sizes="114x114" href="{{ url_for('static', filename='img/apple-touch-icon-114x114.png') }}">
|
||||
<link rel="apple-touch-icon" sizes="144x144" href="{{ url_for('static', filename='img/apple-touch-icon-144x144.png') }}">
|
||||
|
||||
|
||||
@@ -405,15 +405,15 @@ def find_collision_free_name(filename, extension, existing_filenames, max_power=
|
||||
u'test_123.gco'
|
||||
>>> find_collision_free_name("test1234", "g o", [])
|
||||
u'test1234.g_o'
|
||||
>>> find_collision_free_name("test12345", "gco", ["test12~1.gco"])
|
||||
>>> find_collision_free_name("test12345", "gco", ["/test12~1.gco"])
|
||||
u'test12~2.gco'
|
||||
>>> many_files = ["test12~{}.gco".format(x) for x in range(10)[1:]]
|
||||
>>> many_files = ["/test12~{}.gco".format(x) for x in range(10)[1:]]
|
||||
>>> find_collision_free_name("test12345", "gco", many_files)
|
||||
u'test1~10.gco'
|
||||
>>> many_more_files = many_files + ["test1~{}.gco".format(x) for x in range(10, 99)]
|
||||
>>> many_more_files = many_files + ["/test1~{}.gco".format(x) for x in range(10, 99)]
|
||||
>>> find_collision_free_name("test12345", "gco", many_more_files)
|
||||
u'test1~99.gco'
|
||||
>>> many_more_files_plus_one = many_more_files + ["test1~99.gco"]
|
||||
>>> many_more_files_plus_one = many_more_files + ["/test1~99.gco"]
|
||||
>>> find_collision_free_name("test12345", "gco", many_more_files_plus_one)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
@@ -423,13 +423,15 @@ def find_collision_free_name(filename, extension, existing_filenames, max_power=
|
||||
|
||||
"""
|
||||
|
||||
if not isinstance(filename, unicode):
|
||||
filename = unicode(filename)
|
||||
if not isinstance(extension, unicode):
|
||||
extension = unicode(extension)
|
||||
filename = to_unicode(filename)
|
||||
extension = to_unicode(extension)
|
||||
|
||||
if filename.startswith(u"/"):
|
||||
filename = filename[1:]
|
||||
existing_filenames = [to_unicode(x[1:] if x.startswith("/") else x) for x in existing_filenames]
|
||||
|
||||
def make_valid(text):
|
||||
return re.sub(r"\s+", "_", text.translate({ord(i):None for i in ".\"/\\[]:;=,"})).lower()
|
||||
return re.sub(u"\s+", u"_", text.translate({ord(i):None for i in ".\"/\\[]:;=,"})).lower()
|
||||
|
||||
filename = make_valid(filename)
|
||||
extension = make_valid(extension)
|
||||
|
||||
+22
-44
@@ -1012,11 +1012,6 @@ class MachineCom(object):
|
||||
self._callback.on_comm_print_job_started()
|
||||
|
||||
if self.isSdFileSelected():
|
||||
interval = self._timeout_intervals.get("sdStatus", 1.0)
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
self._sd_status_timer = RepeatedTimer(interval, self._poll_sd_status, run_first=True)
|
||||
|
||||
if not external_sd:
|
||||
# make sure to ignore the "file selected" later on, otherwise we'll reset our progress data
|
||||
self._ignore_select = True
|
||||
@@ -1032,15 +1027,9 @@ class MachineCom(object):
|
||||
else:
|
||||
self._currentFile.pos = 0
|
||||
|
||||
def start_polling():
|
||||
self._sd_status_timer.start()
|
||||
|
||||
self.sendCommand("M24",
|
||||
on_sent=start_polling,
|
||||
part_of_job=True,
|
||||
tags=tags | {"trigger:comm.start_print",})
|
||||
else:
|
||||
self._sd_status_timer.start()
|
||||
else:
|
||||
if pos is not None and isinstance(pos, int) and pos > 0:
|
||||
self._currentFile.seek(pos)
|
||||
@@ -1155,6 +1144,7 @@ class MachineCom(object):
|
||||
elif check_timer:
|
||||
return
|
||||
|
||||
self._currentFile.done = True
|
||||
self._recordFilePosition()
|
||||
self._callback.on_comm_print_job_cancelled()
|
||||
|
||||
@@ -1205,11 +1195,6 @@ class MachineCom(object):
|
||||
self.sendCommand("M25", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # pause print
|
||||
self.sendCommand("M27", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # get current byte position in file
|
||||
self.sendCommand("M26 S0", part_of_job=True, tags=tags | {"trigger:comm.cancel",}) # reset position in file to byte 0
|
||||
if self._sd_status_timer is not None:
|
||||
try:
|
||||
self._sd_status_timer.cancel()
|
||||
except:
|
||||
pass
|
||||
|
||||
if self._log_position_on_cancel and not disable_log_position:
|
||||
self.sendCommand("M400",
|
||||
@@ -1885,17 +1870,19 @@ class MachineCom(object):
|
||||
total = int(match.group("total"))
|
||||
|
||||
if self.isSdPrinting() and current == total == 0:
|
||||
# apparently not SD printing - newer Marlin reports it like that for some reason
|
||||
# apparently not SD printing - some Marlin versions report it like that for some reason
|
||||
self.cancelPrint(external_sd=True)
|
||||
|
||||
elif self.isSdFileSelected():
|
||||
if not self.isSdPrinting() and current != total:
|
||||
if not self.isSdPrinting() and current != total and current > 0:
|
||||
self.startPrint(external_sd=True)
|
||||
|
||||
self._currentFile.pos = current
|
||||
if self._currentFile.size == 0:
|
||||
self._currentFile.size = total
|
||||
self._callback.on_comm_progress()
|
||||
|
||||
if not self._currentFile.done:
|
||||
self._callback.on_comm_progress()
|
||||
|
||||
elif 'Not SD printing' in line and self.isSdFileSelected() and self.isPrinting() and not self.isFinishing():
|
||||
# something went wrong, printer is reporting that we actually are not printing right now...
|
||||
@@ -1911,9 +1898,7 @@ class MachineCom(object):
|
||||
size = 0
|
||||
user = None
|
||||
|
||||
expected = False
|
||||
if self._sdFileToSelect:
|
||||
expected = True
|
||||
name = self._sdFileToSelect
|
||||
user = self._sdFileToSelectUser
|
||||
|
||||
@@ -1921,12 +1906,6 @@ class MachineCom(object):
|
||||
self._sdFileToSelectUser = None
|
||||
|
||||
self._currentFile = PrintingSdFileInformation(name, size, user=user)
|
||||
|
||||
if not expected:
|
||||
# It doesn't look like we expected this, so it might be that someone just started a print
|
||||
# job from SD via the printer's controller. Let's query the printing status and see if that's
|
||||
# indeed the case and if so switch states accordingly
|
||||
self.sendCommand("M27", tags={"trigger:unexpected_file_open"})
|
||||
elif 'File selected' in line:
|
||||
if self._ignore_select:
|
||||
self._ignore_select = False
|
||||
@@ -1945,12 +1924,6 @@ class MachineCom(object):
|
||||
self._currentFile.done = True
|
||||
self._currentFile.pos = 0
|
||||
|
||||
if self._sd_status_timer is not None:
|
||||
try:
|
||||
self._sd_status_timer.cancel()
|
||||
except:
|
||||
pass
|
||||
|
||||
self.sendCommand("M400", part_of_job=True)
|
||||
self._callback.on_comm_print_job_done()
|
||||
def finalize():
|
||||
@@ -2267,7 +2240,7 @@ class MachineCom(object):
|
||||
command or heating, no poll will be done.
|
||||
"""
|
||||
|
||||
if self.isOperational() and not self._sdstatus_autoreporting and not self._connection_closing and self.isSdPrinting() and not self._long_running_command and not self._dwelling_until and not self._heating:
|
||||
if self.isOperational() and not self._sdstatus_autoreporting and not self._connection_closing and self.isSdFileSelected() and not self._long_running_command and not self._dwelling_until and not self._heating:
|
||||
self.sendCommand("M27", cmd_type="sd_status_poll", tags={"trigger:comm.poll_sd_status"})
|
||||
|
||||
def _set_autoreport_temperature_interval(self, interval=None):
|
||||
@@ -2296,9 +2269,12 @@ class MachineCom(object):
|
||||
|
||||
def _onConnected(self):
|
||||
self._serial.timeout = settings().getFloat(["serial", "timeout", "communication"])
|
||||
self._temperature_timer = RepeatedTimer(self._getTemperatureTimerInterval, self._poll_temperature, run_first=True)
|
||||
self._temperature_timer = RepeatedTimer(self._get_temperature_timer_interval, self._poll_temperature, run_first=True)
|
||||
self._temperature_timer.start()
|
||||
|
||||
self._sd_status_timer = RepeatedTimer(self._get_sd_status_timer_interval, self._poll_sd_status, run_first=True)
|
||||
self._sd_status_timer.start()
|
||||
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
|
||||
self.resetLineNumbers(tags={"trigger:comm.on_connected",})
|
||||
@@ -2335,7 +2311,7 @@ class MachineCom(object):
|
||||
if self._busy_protocol_detected:
|
||||
self._set_busy_protocol_interval()
|
||||
|
||||
def _getTemperatureTimerInterval(self):
|
||||
def _get_temperature_timer_interval(self):
|
||||
busy_default = 4.0
|
||||
target_default = 2.0
|
||||
|
||||
@@ -2359,6 +2335,12 @@ class MachineCom(object):
|
||||
|
||||
return get("temperature", busy_default)
|
||||
|
||||
def _get_sd_status_timer_interval(self):
|
||||
interval = self._timeout_intervals.get("sdStatus", 1.0)
|
||||
if interval <= 0:
|
||||
interval = 1.0
|
||||
return interval
|
||||
|
||||
def _send_from_command_queue(self):
|
||||
# We loop here to make sure that if we do NOT send the first command
|
||||
# from the queue, we'll send the second (if there is one). We do not
|
||||
@@ -3636,6 +3618,10 @@ class PrintingFileInformation(object):
|
||||
def done(self):
|
||||
return self._done
|
||||
|
||||
@done.setter
|
||||
def done(self, value):
|
||||
self._done = value
|
||||
|
||||
class PrintingSdFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Encapsulates information regarding an ongoing print from SD.
|
||||
@@ -3650,14 +3636,6 @@ class PrintingSdFileInformation(PrintingFileInformation):
|
||||
def getFileLocation(self):
|
||||
return FileDestinations.SDCARD
|
||||
|
||||
@property
|
||||
def done(self):
|
||||
return self._done
|
||||
|
||||
@done.setter
|
||||
def done(self, value):
|
||||
self._done = value
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return self._size
|
||||
|
||||
Reference in new issue
Block a user