Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2017-12-12 13:09:41 +01:00
commit b36a776f51
35 files changed
+624 -282

No files matched your search

+3 -3
View File
@@ -22,10 +22,10 @@ maintenance 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
fix/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
improve/.* 1.3.7 99e1c3ac007a0eee9d6f908e598c6b029f3ae40c pep440-dev
# staging/maintenance is currently the branch for preparation of 1.3.6rc3
# staging/maintenance is currently the branch for preparation of 1.3.6rc4
# so is regressionfix/...
staging/maintenance 1.3.6rc3 3f4a70cf92a7d9081932850be1ea9fb298f0e3f7 pep440-dev
regressionfix/.* 1.3.6rc3 3f4a70cf92a7d9081932850be1ea9fb298f0e3f7 pep440-dev
staging/maintenance 1.3.6rc4 a8747f7e36a03ff2449b62cdf68b8a26a6fa61b3 pep440-dev
regressionfix/.* 1.3.6rc4 a8747f7e36a03ff2449b62cdf68b8a26a6fa61b3 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
+17 -22
View File
@@ -1,6 +1,6 @@
# OctoPrint Changelog
## 1.3.6rc2 (2017-12-05)
## 1.3.6 (2017-12-12)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
@@ -8,26 +8,7 @@ A change to solve issues with plugins bundling JS assets that cause interference
If you happen to run into any such issues, you can switch back to the old way of bundling JS assets via the newly introduced "Settings > Feature > Enable legacy plugin asset bundling" toggle (check it, save the settings, restart the server). This is provided to allow for a minimally invasive adjustment period until affected plugins have been updated.
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
### Bug fixes
* [#2262](https://github.com/foosel/OctoPrint/issues/2262) - Fixed a bug causing `Error:checksum mismatch, Last Line: ...` errors from the firmware to be handled incorrectly.
* [#2267](https://github.com/foosel/OctoPrint/issues/2267) - Fixed a bug causing the GCODE viewer to not get properly initialized due to a JS error on load if "Also show next layer" was selected.
* [#2268](https://github.com/foosel/OctoPrint/issues/2268) - Fixed a bug causing a display error with the temperature offsets. If one offset was changed, all others seemed to revert back to 0.
* Fixed ordering of plugin assets, should be alphabetical based on the plugin identifier.
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.6rc1...1.3.6rc2))
## 1.3.6rc1 (2017-12-01)
### Note for upgraders and plugin authors: Change in the bundling of JS assets can lead to issues in plugins
A change to solve issues with plugins bundling JS assets that cause interference with other plugins (e.g. through the declaration of `"use strict"`) and in general to add better isolation and error handling might cause errors for some plugins that go beyond your run-off-the-mill view model and also implicitly declare new globals.
If you happen to run into any such issues, you can switch back to the old way of bundling JS assets via the newly introduced "Settings > Feature > Enable legacy plugin asset bundling" toggle (check it, save the settings, restart the server). This is provided to allow for a minimally invasive adjustment period until affected plugins have been updated.
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
You can find out more about the change, how to know if a plugin is even affected and what do about it [on the OctoBlog](https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/).
### Improvements
@@ -86,6 +67,7 @@ You can find out more about the change, how to know if a plugin is even affected
* Docs: Added information on how to run the test suite.
* Various refactorings
* Various documentation updates
* Fetch plugin blacklist (and also announcements, plugin notices and plugin repository) via https instead of http.
### Bug fixes
@@ -108,6 +90,9 @@ You can find out more about the change, how to know if a plugin is even affected
* [#2226](https://github.com/foosel/OctoPrint/issues/2226) - Handle `No Line Number with checksum, Last Line: ...` errors from the firmware.
* [#2233](https://github.com/foosel/OctoPrint/pull/2233) - Respond with `411 Length Required` when content length is missing on file uploads.
* [#2242](https://github.com/foosel/OctoPrint/issues/2242) - Fixed an issue where print time left could show "1 days" instead of "1 day".
* [#2262](https://github.com/foosel/OctoPrint/issues/2262) (regression) - Fixed a bug causing `Error:checksum mismatch, Last Line: ...` errors from the firmware to be handled incorrectly.
* [#2267](https://github.com/foosel/OctoPrint/issues/2267) (regression) - Fixed a bug causing the GCODE viewer to not get properly initialized due to a JS error on load if "Also show next layer" was selected.
* [#2268](https://github.com/foosel/OctoPrint/issues/2268) (regression) - Fixed a bug causing a display error with the temperature offsets. If one offset was changed, all others seemed to revert back to 0.
* Fixed cleanup of unrendered timelapses with certain names.
* Fixed a caching issue with the file list API and the slicing API.
* Fixed initial sizing of the temperature graph.
@@ -125,8 +110,18 @@ You can find out more about the change, how to know if a plugin is even affected
* Virtual printer: Fix resend simuation.
* Docs: Fixed CSS of line numbered listings.
* Docs: Updated mermaid to fix a deprecation warning.
* Fixed ordering of plugin assets, should be alphabetical based on the plugin identifier. (regression)
* Fixed an issue causing redundant software update configuration settings to be written to `config.yaml`, in turn causing issues when downgrading to <1.3.5. (regression)
* Fixed an issue detecting whether the installed version is a release version or a development version. (regression)
([Commits](https://github.com/foosel/OctoPrint/compare/1.3.5...1.3.6rc1))
### More Information
* [Commits](https://github.com/foosel/OctoPrint/compare/1.3.5...1.3.6)
* Release Candidates:
* [1.3.5rc1](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc1)
* [1.3.5rc2](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc2)
* [1.3.5rc3](https://github.com/foosel/OctoPrint/releases/tag/1.3.6rc3)
* A special **Thank you!** to everyone who reported back on these release candidates this time: [andrivet](https://github.com/andrivet), [b-morgan](https://github.com/b-morgan), [bjarchi](https://github.com/bjarchi), [chippypilot](https://github.com/chippypilot), [ChrisHeerschap](https://github.com/ChrisHeerschap), [cosmith71](https://github.com/cosmith71), [Crowlord](https://github.com/Crowlord), [ctgreybeard](https://github.com/ctgreybeard), [fiveangle](https://github.com/fiveangle), [goeland86](https://github.com/goeland86), [jbjones27](https://github.com/jbjones27), [jneilliii](https://github.com/jneilliii), [JohnOCFII](https://github.com/JohnOCFII), [Kunsi](https://github.com/Kunsi), [Lordxv](https://github.com/Lordxv), [malnvenshorn](https://github.com/malnvenshorn), [mcp5500](https://github.com/mcp5500), [ntoff](https://github.com/ntoff), [ripp2003](https://github.com/ripp2003) and [schorsch3000](https://github.com/schorsch3000)
## 1.3.5 (2017-10-16)
+5 -5
View File
@@ -5,14 +5,14 @@
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).
Its website can be found at [octoprint.org](http://octoprint.org).
Its website can be found at [octoprint.org](https://octoprint.org/?utm_source=github&utm_medium=readme).
The documentation is located at [docs.octoprint.org](http://docs.octoprint.org).
The official plugin repository can be reached at [plugins.octoprint.org](http://plugins.octoprint.org).
The official plugin repository can be reached at [plugins.octoprint.org](https://plugins.octoprint.org/?utm_source=github&utm_medium=readme).
OctoPrint's development wouldn't be possible without the [financial support by its community](http://octoprint.org/support-octoprint/).
If you enjoy OctoPrint, please consider becoming a regular supporter!
**OctoPrint's development wouldn't be possible without the [financial support by its community](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
If you enjoy OctoPrint, please consider becoming a regular supporter!**
![Screenshot](http://i.imgur.com/dF3noFp.png)
@@ -29,7 +29,7 @@ Contributions of all kinds are welcome, not only in the form of code but also wi
[official documentation](http://docs.octoprint.org/) or [the public wiki](https://github.com/foosel/OctoPrint/wiki), support
of other users in the [bug tracker](https://github.com/foosel/OctoPrint/issues),
[the Mailinglist](https://groups.google.com/group/octoprint) or
[the G+ Community](https://plus.google.com/communities/102771308349328485741) and also [financially](http://octoprint.org/support-octoprint/).
[the G+ Community](https://plus.google.com/communities/102771308349328485741) and also [financially](https://octoprint.org/support-octoprint/?utm_source=github&utm_medium=readme).
If you think something is bad about OctoPrint or its documentation the way it is, please help
in any way to make it better instead of just complaining about it -- this is an Open Source Project
+2 -3
View File
@@ -36,7 +36,6 @@ thanks to everyone who contributed!
* Kazuhiro Ogura
* Makespace Madrid
* Marcus Ackermann
* Mark Qvist
* Mark Walker
* Michael Aumock
* Miles Flavel
@@ -46,7 +45,7 @@ thanks to everyone who contributed!
* Patrick McGinnis
* Peter Schmehl
* PRINT3Dforum.com
* Robert Gusek
* Randy C. Will
* Roger Strolz
* Roy Cortes
* Samer Najia
@@ -59,4 +58,4 @@ thanks to everyone who contributed!
* Timeshell.ca
* Trent Shumay
and 1144 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
and 1062 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel)!
@@ -60,27 +60,27 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
description="Important announcements about OctoPrint.",
priority=1,
type="rss",
url="http://octoprint.org/feeds/important.xml"),
url="https://octoprint.org/feeds/important.xml"),
_releases=dict(name="Release Announcements",
description="Announcements of new releases and release candidates of OctoPrint.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/releases.xml"),
url="https://octoprint.org/feeds/releases.xml"),
_blog=dict(name="On the OctoBlog",
description="Development news, community spotlights, OctoPrint On Air episodes and more from the official OctoBlog.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/octoblog.xml"),
url="https://octoprint.org/feeds/octoblog.xml"),
_plugins=dict(name="New Plugins in the Repository",
description="Announcements of new plugins released on the official Plugin Repository.",
priority=2,
type="rss",
url="http://plugins.octoprint.org/feed.xml"),
url="https://plugins.octoprint.org/feed.xml"),
_octopi=dict(name="OctoPi News",
description="News around OctoPi, the Raspberry Pi image including OctoPrint.",
priority=2,
type="rss",
url="http://octoprint.org/feeds/octopi.xml")),
url="https://octoprint.org/feeds/octopi.xml")),
enabled_channels=[],
forced_channels=["_important"],
channel_order=["_important", "_releases", "_blog", "_plugins", "_octopi"],
@@ -6,7 +6,7 @@
normal operation, allowing you to uninstall or update them to a newer version.
{% endtrans %}</p>
<p>{% trans url="http://plugins.octoprint.org/blacklist/" %}
<p>{% trans url="https://plugins.octoprint.org/blacklist/" %}
By default, OctoPrint will use the blacklist hosted at <code>plugins.octoprint.org/blacklist.json</code> which you
can also take a look at in a more human readable format <a href="{{ url }}" target="_blank">here</a>.
{% endtrans %}</p>
@@ -5,7 +5,7 @@
<p>Version <span class="plugin_octopi_support_version">{{ plugin_octopi_support_version }}</span></p>
<ul>
<li>Website: <a href="http://octoprint.org/download/" target="_blank" rel="noreferrer noopener">octoprint.org/download</a> &amp; <a href="https://octopi.octoprint.org" target="_blank" rel="noreferrer noopener">octopi.octoprint.org</a></li>
<li>Website: <a href="https://octoprint.org/download/" target="_blank" rel="noreferrer noopener">octoprint.org/download</a> &amp; <a href="https://octopi.octoprint.org" target="_blank" rel="noreferrer noopener">octopi.octoprint.org</a></li>
<li>Source Code: <a href="https://github.com/guysoft/OctoPi" target="_blank" rel="noreferrer noopener">github.com/guysoft/OctoPi</a></li>
</ul>
@@ -117,9 +117,9 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
def get_settings_defaults(self):
return dict(
repository="http://plugins.octoprint.org/plugins.json",
repository="https://plugins.octoprint.org/plugins.json",
repository_ttl=24*60,
notices="http://plugins.octoprint.org/notices.json",
notices="https://plugins.octoprint.org/notices.json",
notices_ttl=6*60,
pip_args=None,
pip_force_user=False,
@@ -196,8 +196,8 @@ $(function() {
return;
}
var restartSpec = _.filter(lastResponse.core, function(spec) { return spec.action === "restart" });
self.restartCommandSpec = restartSpec !== undefined && restartSpec.length > 0 ? restartSpec[0] : undefined;
var restartSpec = _.filter(lastResponse.core, function(spec) { return spec.action == "restart" });
self.restartCommandSpec = restartSpec != undefined && restartSpec.length > 0 ? restartSpec[0] : undefined;
});
self.notifications = [];
@@ -207,9 +207,9 @@ $(function() {
self.noticeCountText = ko.pureComputed(function() {
var count = self.noticeCount();
if (count === 0) {
if (count == 0) {
return gettext("There are no plugin notices. Great!");
} else if (count === 1) {
} else if (count == 1) {
return gettext("There is a plugin notice for one of your installed plugins.");
} else {
return _.sprintf(gettext("There are %(count)d plugin notices for one or more of your installed plugins."), {count: count});
@@ -224,15 +224,15 @@ $(function() {
var command = self._getToggleCommand(data);
var not_safemode_victim = !data.safe_mode_victim || data.safe_mode_enabled;
var not_blacklisted = !data.blacklisted;
return self.enableManagement() && (command === "disable" || (not_safemode_victim && not_blacklisted)) && data.key !== 'pluginmanager';
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
};
self.enableUninstall = function(data) {
return self.enableManagement()
&& (data.origin !== "entry_point" || self.pipAvailable())
&& (data.origin != "entry_point" || self.pipAvailable())
&& data.managable
&& !data.bundled
&& data.key !== 'pluginmanager'
&& data.key != 'pluginmanager'
&& !data.pending_uninstall;
};
@@ -299,7 +299,7 @@ $(function() {
maxNumberOfFiles: 1,
autoUpload: false,
add: function(e, data) {
if (data.files.length === 0) {
if (data.files.length == 0) {
return false;
}
@@ -341,7 +341,7 @@ $(function() {
self.performRepositorySearch = function() {
var query = self.repositorySearchQuery();
if (query !== undefined && query.trim() !== "") {
if (query !== undefined && query.trim() != "") {
query = query.toLocaleLowerCase();
self.repositoryplugins.changeSearchFunction(function(entry) {
return entry && (entry["title"].toLocaleLowerCase().indexOf(query) > -1 || entry["description"].toLocaleLowerCase().indexOf(query) > -1);
@@ -447,7 +447,7 @@ $(function() {
return;
}
if (data.key === "pluginmanager") return;
if (data.key == "pluginmanager") return;
var onSuccess = function() {
self.requestData();
@@ -461,7 +461,7 @@ $(function() {
})
};
if (self._getToggleCommand(data) === "enable") {
if (self._getToggleCommand(data) == "enable") {
if (data.safe_mode_victim && !data.safe_mode_enabled) return;
OctoPrint.plugins.pluginmanager.enable(data.key)
.done(onSuccess)
@@ -582,7 +582,7 @@ $(function() {
}
if (data.bundled) return;
if (data.key === "pluginmanager") return;
if (data.key == "pluginmanager") return;
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: data.name}));
@@ -633,7 +633,7 @@ $(function() {
self.savePluginSettings = function() {
var repository = self.config_repositoryUrl();
if (repository !== undefined && repository.trim() === "") {
if (repository != undefined && repository.trim() == "") {
repository = null;
}
@@ -645,7 +645,7 @@ $(function() {
}
var notices = self.config_noticesUrl();
if (notices !== undefined && notices.trim() === "") {
if (notices != undefined && notices.trim() == "") {
notices = null;
}
@@ -657,7 +657,7 @@ $(function() {
}
var pipArgs = self.config_pipAdditionalArgs();
if (pipArgs !== undefined && pipArgs.trim() === "") {
if (pipArgs != undefined && pipArgs.trim() == "") {
pipArgs = null;
}
@@ -709,7 +709,7 @@ $(function() {
};
if (response.result) {
if (action === "install" && response.plugin && response.plugin.blacklisted) {
if (action == "install" && response.plugin && response.plugin.blacklisted) {
notification = new PNotify({
title: titleSuccess,
text: textSuccess,
@@ -862,7 +862,7 @@ $(function() {
};
self.toggleButtonCss = function(data) {
var icon = self._getToggleCommand(data) === "enable" ? "fa fa-toggle-off" : "fa fa-toggle-on";
var icon = self._getToggleCommand(data) == "enable" ? "fa fa-toggle-off" : "fa fa-toggle-on";
var disabled = (self.enableToggle(data)) ? "" : " disabled";
return icon + disabled;
@@ -870,7 +870,7 @@ $(function() {
self.toggleButtonTitle = function(data) {
var command = self._getToggleCommand(data);
if (command === "enable") {
if (command == "enable") {
if (data.blacklisted) {
return gettext("Blacklisted");
} else if (data.safe_mode_victim && !data.safe_mode_enabled) {
@@ -884,7 +884,7 @@ $(function() {
};
self.showPluginNotifications = function(plugin) {
if (!plugin.notifications || plugin.notifications.length === 0) return;
if (!plugin.notifications || plugin.notifications.length == 0) return;
self._removeAllNoticeNotificationsForPlugin(plugin.key);
_.each(plugin.notifications, function(notification) {
@@ -893,7 +893,7 @@ $(function() {
};
self.showPluginNotificationsLinkText = function(plugins) {
if (!plugins.notifications || plugins.notifications.length === 0) return;
if (!plugins.notifications || plugins.notifications.length == 0) return;
var count = plugins.notifications.length;
var importantCount = _.filter(plugins.notifications, function(notification) { return notification.important }).length;
@@ -929,7 +929,7 @@ $(function() {
var text = "";
if (notification.versions && notification.versions.length > 0) {
var versions = _.map(notification.versions, function(v) { return (v === version) ? "<strong>" + v + "</strong>" : v; }).join(", ");
var versions = _.map(notification.versions, function(v) { return (v == version) ? "<strong>" + v + "</strong>" : v; }).join(", ");
text += "<small>" + _.sprintf(gettext("Affected versions: %(versions)s"), {versions: versions}) + "</small>";
} else {
text += "<small>" + gettext("Affected versions: all") + "</small>";
@@ -1005,7 +1005,7 @@ $(function() {
self._isNoticeNotificationHidden = function(key, date) {
if (!self.hiddenNoticeNotifications[key]) return false;
return _.any(_.map(self.hiddenNoticeNotifications[key], function(d) { return date === d; }));
return _.any(_.map(self.hiddenNoticeNotifications[key], function(d) { return date == d; }));
};
var noticeLocalStorageKey = "plugin.pluginmanager.seen_notices";
@@ -1039,7 +1039,7 @@ $(function() {
if (!Modernizr.localstorage)
return false;
if (localStorage[noticeLocalStorageKey] === undefined)
if (localStorage[noticeLocalStorageKey] == undefined)
return false;
var knownData = JSON.parse(localStorage[noticeLocalStorageKey]);
@@ -1094,7 +1094,7 @@ $(function() {
};
self.onDataUpdaterPluginMessage = function(plugin, data) {
if (plugin !== "pluginmanager") {
if (plugin != "pluginmanager") {
return;
}
@@ -1108,21 +1108,21 @@ $(function() {
var messageType = data.type;
if (messageType === "loglines" && self.working()) {
if (messageType == "loglines" && self.working()) {
_.each(data.loglines, function(line) {
self.loglines.push(self._preprocessLine(line));
});
self._scrollWorkingOutputToEnd();
} else if (messageType === "result") {
} else if (messageType == "result") {
var titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError;
var action = data.action;
var name = "Unknown";
if (action === "install") {
if (action == "install") {
var unknown = false;
if (data.hasOwnProperty("plugin")) {
if (data.plugin === "unknown") {
if (data.plugin == "unknown") {
unknown = true;
} else {
name = data.plugin.name;
@@ -1172,13 +1172,13 @@ $(function() {
if (data.hasOwnProperty("reason")) {
if (data.was_reinstalled) {
if (sourceType === "path") {
if (sourceType == "path") {
textError = _.sprintf(gettext("Reinstalling the plugin from file failed: %(reason)s"), {reason: data.reason});
} else {
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
}
} else {
if (sourceType === "path") {
if (sourceType == "path") {
textError = _.sprintf(gettext("Installing the plugin from file failed: %(reason)s"), {reason: data.reason});
} else {
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed: %(reason)s"), {reason: data.reason, source: source});
@@ -1186,13 +1186,13 @@ $(function() {
}
} else {
if (data.was_reinstalled) {
if (sourceType === "path") {
if (sourceType == "path") {
textError = gettext("Reinstalling the plugin from file failed, please see the log for details.");
} else {
textError = _.sprintf(gettext("Reinstalling the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
}
} else {
if (sourceType === "path") {
if (sourceType == "path") {
textError = gettext("Installing the plugin from file failed, please see the log for details.");
} else {
textError = _.sprintf(gettext("Installing the plugin from \"%(source)s\" failed, please see the log for details."), {source: source});
@@ -1200,7 +1200,7 @@ $(function() {
}
}
} else if (action === "uninstall") {
} else if (action == "uninstall") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
@@ -1218,7 +1218,7 @@ $(function() {
textError = gettext("Uninstalling the plugin failed, please see the log for details.");
}
} else if (action === "enable") {
} else if (action == "enable") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
@@ -1236,7 +1236,7 @@ $(function() {
textError = gettext("Toggling the plugin failed, please see the log for details.");
}
} else if (action === "disable") {
} else if (action == "disable") {
if (data.hasOwnProperty("plugin")) {
name = data.plugin.name;
}
@@ -133,7 +133,7 @@
{{ pluginmanager_safemode() }}
{{ pluginmanager_offline() }}
<h4 style="position: relative">
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='http://plugins.octoprint.org') }}
{{ _('... from the <a href="%(url)s" target="_blank">Plugin Repository</a>', url='https://plugins.octoprint.org') }}
<div class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="fa fa-wrench"></span>
@@ -306,30 +306,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if "notify_users" in data:
self._settings.set_boolean(["notify_users"], data["notify_users"])
checks = self._get_configured_checks()
if "octoprint" in checks:
check = checks["octoprint"]
update_type = check.get("type", None)
update_method = self._get_update_method("octoprint", check)
checkout_folder = check.get("checkout_folder", None)
update_folder = check.get("update_folder", None)
prerelease = check.get("prerelease", False)
prerelease_channel = check.get("prerelease_channel", None)
else:
update_type = update_method = checkout_folder = update_folder = prerelease_channel = None
prerelease = False
defaults = dict(
plugins=dict(softwareupdate=dict(
checks=dict(
octoprint=dict(
type=update_type,
method=update_method,
checkout_folder=checkout_folder,
update_folder=update_folder,
prerelease=prerelease,
prerelease_channel=prerelease_channel
)
octoprint=self.get_settings_defaults()["checks"]["octoprint"]
)
))
)
@@ -338,7 +318,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if "octoprint_checkout_folder" in data:
self._settings.set(["checks", "octoprint", "checkout_folder"], data["octoprint_checkout_folder"], defaults=defaults, force=True)
if update_folder and data["octoprint_checkout_folder"]:
if self._settings.get(["checks", "octoprint", "update_folder"]) and data["octoprint_checkout_folder"]:
self._settings.set(["checks", "octoprint", "update_folder"], None, defaults=defaults, force=True)
updated_octoprint_check_config = True
@@ -346,13 +326,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
octoprint_type = data["octoprint_type"]
if octoprint_type == "github_release":
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
self._settings.set(["checks", "octoprint", "method"], "pip", defaults=defaults)
updated_octoprint_check_config = True
elif octoprint_type == "git_commit":
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "method"], "update_script", defaults=defaults, force=True)
self._settings.set(["checks", "octoprint", "type"], octoprint_type, defaults=defaults)
self._settings.set(["checks", "octoprint", "method"], "update_script", defaults=defaults)
updated_octoprint_check_config = True
if "octoprint_release_channel" in data:
@@ -995,6 +975,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if target == "octoprint":
from flask_babel import gettext
from octoprint.util.version import is_released_octoprint_version, is_stable_octoprint_version
result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
if result["displayName"] is None:
# displayName missing or set to None
@@ -1012,16 +994,16 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
stable_branch = check["stable_branch"]["branch"]
if "prerelease_branches" in check:
release_branches += [x["branch"] for x in check["prerelease_branches"]]
result["released_version"] = not release_branches or BRANCH in release_branches
result["released_version"] = is_released_octoprint_version()
if check["type"] in self.COMMIT_TRACKING_TYPES:
result["current"] = REVISION if REVISION else "unknown"
else:
result["current"] = VERSION
if check["type"] == "github_release" and (check.get("prerelease", None) or BRANCH != stable_branch):
# we are tracking github releases and are either also tracking prerelease OR are currently installed
# from something that is not the stable (master) branch => we need to change some parameters
if check["type"] == "github_release" and (check.get("prerelease", None) or not is_stable_octoprint_version()):
# we are tracking github releases and are either also tracking prerelease OR are currently running
# a non stable version => we need to change some parameters
# we compare versions fully, not just the base so that we see a difference
# between RCs + stable for the same version release
@@ -1041,17 +1023,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
result["update_branch"] = check.get("update_branch", stable_branch)
if check.get("update_script", None):
# we force an exact version
# we force an exact version & python unequality check, to be able to downgrade
result["force_exact_version"] = True
if BRANCH != result.get("prerelease_channel"):
# we force python unequality check here because that will also allow us to
# downgrade on a prerelease channel change (rc/devel => rc/maintenance)
#
# we detect channel changes by comparing the current branch with the target
# branch of the release channel - unequality means we might have to handle
# a downgrade
result["release_compare"] = "python_unequal"
result["release_compare"] = "python_unequal"
elif check.get("pip", None):
# we force python unequality check for pip installs, to be able to downgrade
@@ -14,7 +14,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.checkEntries = function(entries, force, opts) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
var params = arguments[0];
entries = params.entries;
force = params.force;
@@ -22,7 +22,7 @@
}
entries = entries || [];
if (typeof entries === "string") {
if (typeof entries == "string") {
entries = [entries];
}
@@ -37,7 +37,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.check = function(force, opts) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
var params = arguments[0];
force = params.force;
opts = params.opts;
@@ -47,7 +47,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.update = function(entries, force, opts) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
var params = arguments[0];
entries = params.entries;
force = params.force;
@@ -55,7 +55,7 @@
}
entries = entries || [];
if (typeof entries === "string") {
if (typeof entries == "string") {
entries = [entries];
}
@@ -67,7 +67,7 @@
};
OctoPrintSoftwareUpdateClient.prototype.updateAll = function(force, opts) {
if (arguments.length === 1 && _.isObject(arguments[0])) {
if (arguments.length == 1 && _.isObject(arguments[0])) {
var params = arguments[0];
force = params.force;
opts = params.opts;
@@ -551,7 +551,7 @@ $(function() {
});
self._updateClicked = false;
} else {
self.forceUpdate = (force === true);
self.forceUpdate = (force == true);
self.confirmationDialog.modal("show");
}
@@ -88,7 +88,7 @@ class VirtualPrinter(object):
self._lastX = 0.0
self._lastY = 0.0
self._lastZ = 0.0
self._lastE = 0.0
self._lastE = [0.0] * self.extruderCount
self._lastF = 200
self._unitModifier = 1
@@ -428,7 +428,19 @@ class VirtualPrinter(object):
self._deleteSdFile(filename)
def _gcode_M114(self, data):
output = "X:{} Y:{} Z:{} E:{} Count: A:{} B:{} C:{}".format(self._lastX, self._lastY, self._lastZ, self._lastE, int(self._lastX*100), int(self._lastY*100), int(self._lastZ*100))
if settings().getBoolean(["devel", "virtualPrinter", "reprapfwM114"]):
output = "X:{} Y:{} Z:{} {}".format(self._lastX,
self._lastY,
self._lastZ,
" ".join(["E{}:{}".format(num, self._lastE[self.currentExtruder]) for num in range(self.extruderCount)]))
else:
output = "X:{} Y:{} Z:{} E:{} Count: A:{} B:{} C:{}".format(self._lastX,
self._lastY,
self._lastZ,
self._lastE[self.currentExtruder],
int(self._lastX*100),
int(self._lastY*100),
int(self._lastZ*100))
if not self._okBeforeCommandOutput:
ok = self._ok()
if ok:
@@ -482,7 +494,7 @@ class VirtualPrinter(object):
if self._lastZ is not None:
self._lastZ *= 2.54
if self._lastE is not None:
self._lastE *= 2.54
self._lastE = [e * 2.54 if e is not None else None for e in self._lastE]
def _gcode_G21(self, data):
self._unitModifier = 1.0
@@ -493,7 +505,7 @@ class VirtualPrinter(object):
if self._lastZ is not None:
self._lastZ /= 2.54
if self._lastE is not None:
self._lastE /= 2.54
self._lastE = [e / 2.54 if e is not None else None for e in self._lastE]
def _gcode_G90(self, data):
self._relative = False
@@ -894,15 +906,16 @@ class VirtualPrinter(object):
if matchE is not None:
try:
e = float(matchE.group(1))
if self._relative or self._lastE is None:
lastE = self._lastE[self.currentExtruder]
if self._relative or lastE is None:
duration = max(duration, e * self._unitModifier / speedE * 60.0)
else:
duration = max(duration, (e - self._lastE) * self._unitModifier / speedE * 60.0)
duration = max(duration, (e - lastE) * self._unitModifier / speedE * 60.0)
if self._relative and self._lastE is not None:
self._lastE += e
if self._relative and lastE is not None:
self._lastE[self.currentExtruder] += e
else:
self._lastE = e
self._lastE[self.currentExtruder] = e
except:
pass
@@ -922,7 +935,7 @@ class VirtualPrinter(object):
matchE = re.search("E([0-9.]+)", line)
if matchX is None and matchY is None and matchZ is None and matchE is None:
self._lastX = self._lastY = self._lastZ = self._lastE = 0
self._lastX = self._lastY = self._lastZ = self._lastE[self.currentExtruder] = 0
else:
if matchX is not None:
try:
@@ -941,7 +954,7 @@ class VirtualPrinter(object):
pass
if matchE is not None:
try:
self._lastE = float(matchE.group(1))
self._lastE[self.currentExtruder] = float(matchE.group(1))
except:
pass
+2 -1
View File
@@ -159,7 +159,7 @@ default_settings = {
},
"pluginBlacklist": {
"enabled": None,
"url": "http://plugins.octoprint.org/blacklist.json",
"url": "https://plugins.octoprint.org/blacklist.json",
"ttl": 15 * 60 # 15 min
},
"diskspace": {
@@ -367,6 +367,7 @@ default_settings = {
"repetierStyleResends": False,
"okBeforeCommandOutput": False,
"smoothieTemperatureReporting": False,
"reprapfwM114": False,
"extendedSdFileList": False,
"throttle": 0.01,
"sendWait": True,
@@ -50,7 +50,7 @@ $(function() {
});
self.webcamRatioClass = ko.pureComputed(function() {
if (self.settings.webcam_streamRatio() === "4:3") {
if (self.settings.webcam_streamRatio() == "4:3") {
return "ratio43";
} else {
return "ratio169";
@@ -156,7 +156,7 @@ $(function() {
if (control.hasOwnProperty("children")) {
control.children = ko.observableArray(self._processControls(control.children));
if (!control.hasOwnProperty("layout") || !(control.layout === "vertical" || control.layout === "horizontal" || control.layout === "horizontal_grid")) {
if (!control.hasOwnProperty("layout") || !(control.layout == "vertical" || control.layout == "horizontal" || control.layout == "horizontal_grid")) {
control.layout = "vertical";
}
@@ -371,23 +371,23 @@ $(function() {
};
self._enableWebcam = function() {
if (OctoPrint.coreui.selectedTab !== "#control" || !OctoPrint.coreui.browserTabVisible) {
if (OctoPrint.coreui.selectedTab != "#control" || !OctoPrint.coreui.browserTabVisible) {
return;
}
if (self.webcamDisableTimeout !== undefined) {
if (self.webcamDisableTimeout != undefined) {
clearTimeout(self.webcamDisableTimeout);
}
var webcamImage = $("#webcam_image");
var currentSrc = webcamImage.attr("src");
// safari bug doesn't release the mjpeg stream, so we just set it up the once
if (OctoPrint.coreui.browser.safari && currentSrc !== undefined) {
if (OctoPrint.coreui.browser.safari && currentSrc != undefined) {
return;
}
var newSrc = self.settings.webcam_streamUrl();
if (currentSrc !== newSrc) {
if (currentSrc != newSrc) {
if (newSrc.lastIndexOf("?") > -1) {
newSrc += "&";
} else {
@@ -416,9 +416,9 @@ $(function() {
};
self.onTabChange = function (current, previous) {
if (current === "#control") {
if (current == "#control") {
self._enableWebcam();
} else if (previous === "#control") {
} else if (previous == "#control") {
self._disableWebcam();
}
};
+28 -28
View File
@@ -194,7 +194,7 @@ $(function() {
});
self._retrieveBedDimensions = function(currentProfileData) {
if (currentProfileData === undefined) {
if (currentProfileData == undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@@ -202,7 +202,7 @@ $(function() {
var x = undefined, y = undefined, r = undefined, circular = false, centeredOrigin = false;
var formFactor = currentProfileData.volume.formFactor();
if (formFactor === "circular") {
if (formFactor == "circular") {
r = currentProfileData.volume.width() / 2;
circular = true;
centeredOrigin = true;
@@ -210,7 +210,7 @@ $(function() {
x = currentProfileData.volume.width();
y = currentProfileData.volume.depth();
if (currentProfileData.volume.origin) {
centeredOrigin = currentProfileData.volume.origin() === "center";
centeredOrigin = currentProfileData.volume.origin() == "center";
}
}
@@ -227,7 +227,7 @@ $(function() {
};
self._retrieveToolOffsets = function(currentProfileData) {
if (currentProfileData === undefined) {
if (currentProfileData == undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@@ -246,7 +246,7 @@ $(function() {
};
self._retrieveAxesConfiguration = function(currentProfileData) {
if (currentProfileData === undefined) {
if (currentProfileData == undefined) {
currentProfileData = self.settings.printerProfiles.currentProfileData();
}
@@ -380,7 +380,7 @@ $(function() {
self.loadFile = function(path, date){
self.enableReload(false);
self.needsLoad = false;
if (self.status === "idle" && self.errorCount < 3) {
if (self.status == "idle" && self.errorCount < 3) {
self.status = "request";
OctoPrint.files.download("local", path)
.done(function(response, rstatus) {
@@ -408,10 +408,10 @@ $(function() {
GCODE.renderer.clear();
GCODE.gCodeReader.loadFile(par);
if (self.layerSlider !== undefined) {
if (self.layerSlider != undefined) {
self.layerSlider.slider("disable");
}
if (self.layerCommandSlider !== undefined) {
if (self.layerCommandSlider != undefined) {
self.layerCommandSlider.slider("disable");
}
};
@@ -436,10 +436,10 @@ $(function() {
GCODE.renderer.render(cmdIndex.layer, 0, cmdIndex.cmd);
GCODE.ui.updateLayerInfo(cmdIndex.layer);
if (self.layerSlider !== undefined) {
if (self.layerSlider != undefined) {
self.layerSlider.slider("setValue", cmdIndex.layer);
}
if (self.layerCommandSlider !== undefined) {
if (self.layerCommandSlider != undefined) {
self.layerCommandSlider.slider("setValue", [0, cmdIndex.cmd]);
}
};
@@ -461,17 +461,17 @@ $(function() {
self.currentlyPrinting = data.state.flags && (data.state.flags.printing || data.state.flags.paused);
if(self.loadedFilepath
&& self.loadedFilepath === data.job.file.path
&& self.loadedFileDate === data.job.file.date) {
&& self.loadedFilepath == data.job.file.path
&& self.loadedFileDate == data.job.file.date) {
if (OctoPrint.coreui.browserTabVisible && self.tabActive && self.currentlyPrinting && self.renderer_syncProgress() && !self.waitForApproval()) {
self._renderPercentage(data.progress.completion);
}
self.errorCount = 0
} else {
self.clear();
if (data.job.file.path && data.job.file.origin !== "sdcard"
&& self.status !== "request"
&& (!self.waitForApproval() || self.selectedFile.path() !== data.job.file.path || self.selectedFile.date() !== data.job.file.date)) {
if (data.job.file.path && data.job.file.origin != "sdcard"
&& self.status != "request"
&& (!self.waitForApproval() || self.selectedFile.path() != data.job.file.path || self.selectedFile.date() != data.job.file.date)) {
self.selectedFile.path(data.job.file.path);
self.selectedFile.date(data.job.file.date);
self.selectedFile.size(data.job.file.size);
@@ -511,7 +511,7 @@ $(function() {
self._onModelLoaded = function(model) {
if (!model) {
self.ui_modelInfo("");
if (self.layerSlider !== undefined) {
if (self.layerSlider != undefined) {
self.layerSlider.slider("disable");
self.layerSlider.slider("setMax", 1);
self.layerSlider.slider("setValue", 0);
@@ -531,7 +531,7 @@ $(function() {
self.ui_modelInfo(output.join("<br>"));
self.maxLayer = model.layersPrinted - 1;
if (self.layerSlider !== undefined) {
if (self.layerSlider != undefined) {
self.layerSlider.slider("enable");
self.layerSlider.slider("setMax", self.maxLayer);
self.layerSlider.slider("setValue", 0);
@@ -545,7 +545,7 @@ $(function() {
self._onLayerSelected = function(layer) {
if (!layer) {
self.ui_layerInfo("");
if (self.layerCommandSlider !== undefined) {
if (self.layerCommandSlider != undefined) {
self.layerCommandSlider.slider("disable");
self.layerCommandSlider.slider("setMax", 1);
self.layerCommandSlider.slider("setValue", [0, 1]);
@@ -559,8 +559,8 @@ $(function() {
output.push(gettext("Layer number") + ": " + (layer.number + 1));
output.push(gettext("Layer height") + " (mm): " + layer.height);
output.push(gettext("GCODE commands") + ": " + layer.commands);
if (layer.filament !== undefined) {
if (layer.filament.length === 1) {
if (layer.filament != undefined) {
if (layer.filament.length == 1) {
output.push(gettext("Filament") + ": " + layer.filament[0].toFixed(2) + "mm");
} else {
for (var i = 0; i < layer.filament.length; i++) {
@@ -572,7 +572,7 @@ $(function() {
self.ui_layerInfo(output.join("<br>"));
if (self.layerCommandSlider !== undefined) {
if (self.layerCommandSlider != undefined) {
self.layerCommandSlider.slider("enable");
self.layerCommandSlider.slider("setMax", layer.commands - 1);
self.layerCommandSlider.slider("setValue", [0, layer.commands - 1]);
@@ -587,11 +587,11 @@ $(function() {
if (!options) return;
for (var opt in options) {
if (opt === "zoomInOnModel" && options[opt] !== self.renderer_zoomOnModel()) {
if (opt == "zoomInOnModel" && options[opt] != self.renderer_zoomOnModel()) {
self.renderer_zoomOnModel(false);
} else if (opt === "centerViewport" && options[opt] !== self.renderer_centerViewport()) {
} else if (opt == "centerViewport" && options[opt] != self.renderer_centerViewport()) {
self.renderer_centerViewport(false);
} else if (opt === "moveModel" && options[opt] !== self.renderer_centerModel()) {
} else if (opt == "moveModel" && options[opt] != self.renderer_centerModel()) {
self.renderer_centerModel(false);
}
}
@@ -601,7 +601,7 @@ $(function() {
if (self.currentlyPrinting && self.renderer_syncProgress()) self.renderer_syncProgress(false);
var value = event.value;
if (self.currentLayer !== undefined && self.currentLayer === value) return;
if (self.currentLayer !== undefined && self.currentLayer == value) return;
self.currentLayer = value;
GCODE.ui.changeSelectedLayer(value);
@@ -641,7 +641,7 @@ $(function() {
if (self.currentlyPrinting && self.renderer_syncProgress()) self.renderer_syncProgress(false);
var tuple = event.value;
if (self.currentCommand !== undefined && self.currentCommand[0] === tuple[0] && self.currentCommand[1] === tuple[1]) return;
if (self.currentCommand !== undefined && self.currentCommand[0] == tuple[0] && self.currentCommand[1] == tuple[1]) return;
self.currentCommand = tuple;
GCODE.ui.changeSelectedCommands(self.layerSlider.slider("getValue"), tuple[0], tuple[1]);
@@ -656,14 +656,14 @@ $(function() {
};
self.onTabChange = function(current, previous) {
self.tabActive = current === "#gcode";
self.tabActive = current == "#gcode";
if (self.tabActive && self.needsLoad) {
self.loadFile(self.selectedFile.path(), self.selectedFile.date());
}
};
self.shiftLayer = function(value){
if (value !== self.currentLayer) {
if (value != self.currentLayer) {
self.layerSlider.slider('setValue', value);
value = self.layerSlider.slider('getValue');
//This sets the scroll bar to the appropriate position.
@@ -98,7 +98,7 @@ $(function() {
self.login = function(u, p, r) {
var username = u || self.loginUser();
var password = p || self.loginPass();
var remember = (r !== undefined ? r : self.loginRemember());
var remember = (r != undefined ? r : self.loginRemember());
return OctoPrint.browser.login(username, password, remember)
.done(function(response) {
@@ -51,7 +51,7 @@ $(function() {
self.volumeOrigin = ko.observable();
self.volumeFormFactor.subscribe(function(value) {
if (value === "circular") {
if (value == "circular") {
self.volumeOrigin("center");
}
});
@@ -123,10 +123,10 @@ $(function() {
data = placeholder;
}
var validCharacters = (data && (data === self._sanitize(data)));
var validCharacters = (data && (data == self._sanitize(data)));
var existingProfile = self.profiles.getItem(function(item) {return item.id === data});
return !data || !validCharacters || (self.isNew() && existingProfile !== undefined);
var existingProfile = self.profiles.getItem(function(item) {return item.id == data});
return !data || !validCharacters || (self.isNew() && existingProfile != undefined);
});
self.identifierInvalidText = ko.pureComputed(function() {
@@ -136,7 +136,7 @@ $(function() {
if (!self.identifier() && !self.identifierPlaceholder()) {
return gettext("Identifier must be set");
} else if (self.identifier() !== self._sanitize(self.identifier())) {
} else if (self.identifier() != self._sanitize(self.identifier())) {
return gettext("Invalid characters, only a-z, A-Z, 0-9, -, ., _, ( and ) are allowed")
} else {
return gettext("A profile with such an identifier already exists");
@@ -170,9 +170,9 @@ $(function() {
};
var keys = [];
if (formFactor === "rectangular") {
if (formFactor == "rectangular") {
keys = ["lowerleft", "center"];
} else if (formFactor === "circular") {
} else if (formFactor == "circular") {
keys = ["center"];
}
@@ -312,7 +312,7 @@ $(function() {
}
}
if (profile.volume.formFactor === "circular") {
if (profile.volume.formFactor == "circular") {
profile.volume.depth = profile.volume.width;
}
@@ -320,7 +320,7 @@ $(function() {
};
self.defaultBoundingBox = function(width, depth, height, origin) {
if (origin === "center") {
if (origin == "center") {
var halfWidth = width / 2.0;
var halfDepth = depth / 2.0;
@@ -519,7 +519,7 @@ $(function() {
})
.fail(function(xhr) {
var text;
if (xhr.status === 409) {
if (xhr.status == 409) {
text = gettext("Cannot delete the default profile or the currently active profile.");
} else {
text = gettext("There was unexpected error while removing the printer profile, please consult the logs.");
@@ -534,7 +534,7 @@ $(function() {
};
self.updateProfile = function(profile, callback) {
if (profile === undefined) {
if (profile == undefined) {
profile = self.editor.toProfileData();
}
@@ -16,7 +16,7 @@ $(function() {
self.isSdReady = ko.observable(undefined);
self.enablePrint = ko.pureComputed(function() {
return self.isOperational() && self.isReady() && !self.isPrinting() && self.loginState.isUser() && self.filename() !== undefined;
return self.isOperational() && self.isReady() && !self.isPrinting() && self.loginState.isUser() && self.filename() != undefined;
});
self.enablePause = ko.pureComputed(function() {
return self.isOperational() && (self.isPrinting() || self.isPaused()) && self.loginState.isUser();
@@ -77,7 +77,7 @@ $(function() {
return formatDuration(self.printTime());
});
self.printTimeLeftString = ko.pureComputed(function() {
if (self.printTimeLeft() === undefined) {
if (self.printTimeLeft() == undefined) {
if (!self.printTime() || !(self.isPrinting() || self.isPaused())) {
return "-";
} else {
@@ -156,9 +156,9 @@ $(function() {
return "-";
var type = timelapse["type"];
if (type === "zchange") {
if (type == "zchange") {
return gettext("On Z Change");
} else if (type === "timed") {
} else if (type == "timed") {
return gettext("Timed") + " (" + timelapse["options"]["interval"] + " " + gettext("sec") + ")";
} else {
return "-";
@@ -197,7 +197,7 @@ $(function() {
self.isReady(data.flags.ready);
self.isSdReady(data.flags.sdReady);
if (self.isPaused() !== prevPaused) {
if (self.isPaused() != prevPaused) {
if (self.isPaused()) {
self.titlePrintButton(self.TITLE_PRINT_BUTTON_PAUSED);
self.titlePauseButton(self.TITLE_PAUSE_BUTTON_PAUSED);
@@ -214,7 +214,7 @@ $(function() {
self.filepath(data.file.path);
self.filesize(data.file.size);
self.filedisplay(data.file.display);
self.sd(data.file.origin === "sdcard");
self.sd(data.file.origin == "sdcard");
} else {
self.filename(undefined);
self.filepath(undefined);
@@ -227,7 +227,7 @@ $(function() {
self.lastPrintTime(data.lastPrintTime);
var result = [];
if (data.filament && typeof(data.filament) === "object" && _.keys(data.filament).length > 0) {
if (data.filament && typeof(data.filament) == "object" && _.keys(data.filament).length > 0) {
var keys = _.keys(data.filament);
keys.sort();
_.each(keys, function(key) {
@@ -38,7 +38,7 @@ $(function() {
});
self.enableTranslationUpload = ko.pureComputed(function() {
var name = self.translationUploadFilename();
return name !== undefined && name.trim() !== "" && !self.invalidTranslationArchive();
return name !== undefined && name.trim() != "" && !self.invalidTranslationArchive();
});
self.translations = new ItemListHelper(
@@ -415,7 +415,7 @@ $(function() {
autoUpload: false,
headers: OctoPrint.getRequestHeaders(),
add: function(e, data) {
if (data.files.length === 0) {
if (data.files.length == 0) {
return false;
}
@@ -444,14 +444,14 @@ $(function() {
self.settingsDialog.on('show', function(event) {
OctoPrint.coreui.settingsOpen = true;
if (event.target.id === "settings_dialog") {
if (event.target.id == "settings_dialog") {
self.requestTranslationData();
callViewModels(allViewModels, "onSettingsShown");
}
});
self.settingsDialog.on('hidden', function(event) {
OctoPrint.coreui.settingsOpen = false;
if (event.target.id === "settings_dialog") {
if (event.target.id == "settings_dialog") {
callViewModels(allViewModels, "onSettingsHidden");
}
});
@@ -525,11 +525,11 @@ $(function() {
self.requestData = function(local) {
// handle old parameter format
var callback = undefined;
if (arguments.length === 2 || _.isFunction(local)) {
if (arguments.length == 2 || _.isFunction(local)) {
var exc = new Error();
log.warn("The callback parameter of SettingsViewModel.requestData is deprecated, the method now returns a promise, please use that instead. Stacktrace:", (exc.stack || exc.stacktrace || "<n/a>"));
if (arguments.length === 2) {
if (arguments.length == 2) {
callback = arguments[0];
local = arguments[1];
} else {
@@ -626,8 +626,8 @@ $(function() {
var translations = [];
_.each(translationsByLocale, function(item) {
item["packs"].sort(function(a, b) {
if (a.identifier === "_core") return -1;
if (b.identifier === "_core") return 1;
if (a.identifier == "_core") return -1;
if (b.identifier == "_core") return 1;
if (a.display < b.display) return -1;
if (a.display > b.display) return 1;
@@ -640,7 +640,7 @@ $(function() {
};
self.languagePackDisplay = function(item) {
return item.display + ((item.english !== undefined) ? ' (' + item.english + ')' : '');
return item.display + ((item.english != undefined) ? ' (' + item.english + ')' : '');
};
self.languagePacksAvailable = ko.pureComputed(function() {
@@ -657,7 +657,7 @@ $(function() {
*/
self.getLocalData = function() {
var data = {};
if (self.settings !== undefined) {
if (self.settings != undefined) {
data = ko.mapping.toJS(self.settings);
}
@@ -665,8 +665,8 @@ $(function() {
var specialMappings = {
feature: {
externalHeatupDetection: function() { return !self.feature_disableExternalHeatupDetection()},
alwaysSendChecksum: function() { return self.feature_sendChecksum() === "always"},
neverSendChecksum: function() { return self.feature_sendChecksum() === "never"}
alwaysSendChecksum: function() { return self.feature_sendChecksum() == "always"},
neverSendChecksum: function() { return self.feature_sendChecksum() == "never"}
},
serial: {
additionalPorts : function() { return commentableLinesToArray(self.serial_additionalPorts()) },
@@ -707,7 +707,7 @@ $(function() {
// process all key-value-pairs here
_.forOwn(data, function(value, key) {
var observable = key;
if (keyPrefix !== undefined) {
if (keyPrefix != undefined) {
observable = keyPrefix + "_" + observable;
}
@@ -717,7 +717,7 @@ $(function() {
} else if (_.isPlainObject(value)) {
// value is another object, we'll dive deeper
var subresult = mapFromObservables(value, (mapping && mapping[key]) ? mapping[key] : undefined, observable);
if (subresult !== undefined) {
if (subresult != undefined) {
// we only set something on our result if we got something back
result[key] = subresult;
flag = true;
@@ -801,7 +801,7 @@ $(function() {
// process all key-value-pairs here
_.forOwn(data, function(value, key) {
var observable = key;
if (keyPrefix !== undefined) {
if (keyPrefix != undefined) {
observable = keyPrefix + "_" + observable;
}
@@ -832,16 +832,16 @@ $(function() {
} else {
options = {
success: successCallback,
sending: (setAsSending === true)
sending: (setAsSending == true)
}
}
self.settingsDialog.trigger("beforeSave");
self.sawUpdateEventWhileSending = false;
self.sending(data === undefined || options.sending || false);
self.sending(data == undefined || options.sending || false);
if (data === undefined) {
if (data == undefined) {
// we also only send data that actually changed when no data is specified
data = getOnlyChangedData(self.getLocalData(), self.lastReceivedSettings);
}
@@ -920,7 +920,7 @@ $(function() {
};
self.selectTab = function(tab) {
if (tab !== undefined) {
if (tab != undefined) {
if (!_.startsWith(tab, "#")) {
tab = "#" + tab;
}
@@ -41,10 +41,10 @@ $(function() {
};
self.profilesForSlicer = function(key) {
if (key === undefined) {
if (key == undefined) {
key = self.slicer();
}
if (key === undefined || !self.data.hasOwnProperty(key)) {
if (key == undefined || !self.data.hasOwnProperty(key)) {
return;
}
var slicer = self.data[key];
@@ -53,7 +53,7 @@ $(function() {
self.profiles.removeAll();
_.each(_.values(slicer.profiles), function(profile) {
var name = profile.displayName;
if (name === undefined) {
if (name == undefined) {
name = profile.key;
}
@@ -77,7 +77,7 @@ $(function() {
};
self.metadataForSlicer = function(key) {
if (key === undefined || !self.data.hasOwnProperty(key)) {
if (key == undefined || !self.data.hasOwnProperty(key)) {
return;
}
@@ -100,7 +100,7 @@ $(function() {
var containsSlicer = function(key) {
return _.any(slicers, function(slicer) {
return slicer.key === key;
return slicer.key == key;
});
};
@@ -134,7 +134,7 @@ $(function() {
}
var filename = file;
if (filename.lastIndexOf("/") !== 0) {
if (filename.lastIndexOf("/") != 0) {
path = path || filename.substr(0, filename.lastIndexOf("/"));
filename = filename.substr(filename.lastIndexOf("/") + 1);
}
@@ -173,10 +173,10 @@ $(function() {
};
self.enableSliceButton = ko.pureComputed(function() {
return self.destinationFilename() !== undefined
&& self.destinationFilename().trim() !== ""
&& self.slicer() !== undefined
&& self.profile() !== undefined
return self.destinationFilename() != undefined
&& self.destinationFilename().trim() != ""
&& self.slicer() != undefined
&& self.profile() != undefined
&& (!(self.printerState.isPrinting() || self.printerState.isPaused()) || !self.slicerSameDevice());
});
@@ -227,7 +227,7 @@ $(function() {
self.slicers.removeAll();
_.each(_.values(data), function(slicer) {
var name = slicer.displayName;
if (name === undefined) {
if (name == undefined) {
name = slicer.key;
}
@@ -276,13 +276,13 @@ $(function() {
destination: destinationFilename
};
if (self.path !== undefined) {
if (self.path != undefined) {
data["path"] = self.path;
}
if (self.afterSlicing() === "print") {
if (self.afterSlicing() == "print") {
data["print"] = true;
} else if (self.afterSlicing() === "select") {
} else if (self.afterSlicing() == "select") {
data["select"] = true;
}
@@ -57,7 +57,7 @@ $(function() {
var regex = self.filterRegex();
var lineVisible = function(entry) {
return regex === undefined || !entry.line.match(regex);
return regex == undefined || !entry.line.match(regex);
};
var filtered = false;
@@ -90,7 +90,7 @@ $(function() {
var regex = self.filterRegex();
var lineVisible = function(entry) {
return regex === undefined || !entry.line.match(regex);
return regex == undefined || !entry.line.match(regex);
};
var lines = self.log();
@@ -204,7 +204,7 @@ $(function() {
if (!self.terminalLogDuringPrinting() && self.isPrinting()) {
var last = self.plainLogLines()[self.plainLogLines().length - 1];
var disabled = "--- client too slow, log output disabled while printing ---";
if (last !== disabled) {
if (last != disabled) {
self.plainLogLines.push(disabled);
}
return;
@@ -225,7 +225,7 @@ $(function() {
}
var newLog = self.log().concat(_.map(newData, function(line) { return self._toInternalFormat(line) }));
if (newData.length !== data.length) {
if (newData.length != data.length) {
var cutoff = "--- too many lines to buffer, cut off ---";
newLog.push(self._toInternalFormat(cutoff, "cut"));
}
@@ -245,7 +245,7 @@ $(function() {
};
self._toInternalFormat = function(line, type) {
if (type === undefined) {
if (type == undefined) {
type = "line";
}
return {line: escapeUnprintableCharacters(line), type: type}
@@ -263,7 +263,7 @@ $(function() {
self.updateFilterRegex = function() {
var filterRegexStr = self.activeFilters().join("|").trim();
if (filterRegexStr === "") {
if (filterRegexStr == "") {
self.filterRegex(undefined);
} else {
self.filterRegex(new RegExp(filterRegexStr));
@@ -356,10 +356,10 @@ $(function() {
self.handleKeyDown = function(event) {
var keyCode = event.keyCode;
if (keyCode === 38 || keyCode === 40) {
if (keyCode === 38 && self.cmdHistory.length > 0 && self.cmdHistoryIdx > 0) {
if (keyCode == 38 || keyCode == 40) {
if (keyCode == 38 && self.cmdHistory.length > 0 && self.cmdHistoryIdx > 0) {
self.cmdHistoryIdx--;
} else if (keyCode === 40 && self.cmdHistoryIdx < self.cmdHistory.length - 1) {
} else if (keyCode == 40 && self.cmdHistoryIdx < self.cmdHistory.length - 1) {
self.cmdHistoryIdx++;
}
@@ -378,7 +378,7 @@ $(function() {
};
self.handleKeyUp = function(event) {
if (event.keyCode === 13) {
if (event.keyCode == 13) {
self.sendCommand();
}
@@ -387,7 +387,7 @@ $(function() {
};
self.onAfterTabChange = function(current, previous) {
self.tabActive = current === "#term";
self.tabActive = current == "#term";
self.updateOutput();
};
@@ -54,7 +54,7 @@ $(function() {
});
self.editorPasswordMismatch = ko.pureComputed(function() {
return self.editorPassword() !== self.editorRepeatedPassword();
return self.editorPassword() != self.editorRepeatedPassword();
});
self.requestData = function() {
@@ -185,7 +185,7 @@ $(function() {
throw OctoPrint.InvalidArgumentError("user must be set");
}
if (user.name === self.loginState.username()) {
if (user.name == self.loginState.username()) {
// we do not allow to delete ourselves
new PNotify({
title: gettext("Not possible"),
@@ -25,7 +25,7 @@ $(function() {
self.access_apikey(undefined);
self.interface_language("_default");
if (newUser !== undefined) {
if (newUser != undefined) {
self.access_apikey(newUser.apikey);
if (newUser.settings.hasOwnProperty("interface") && newUser.settings.interface.hasOwnProperty("language")) {
self.interface_language(newUser.settings.interface.language);
@@ -34,13 +34,13 @@ $(function() {
});
self.passwordMismatch = ko.pureComputed(function() {
return self.access_password() !== self.access_repeatedPassword();
return self.access_password() != self.access_repeatedPassword();
});
self.show = function(user) {
if (!CONFIG_ACCESS_CONTROL) return;
if (user === undefined) {
if (user == undefined) {
user = self.loginState.currentUser();
}
@@ -72,13 +72,13 @@ $(function() {
return false;
},
onTabShow: function(tab, navigation, index) {
if (index < 0 || tab.length === 0) {
if (index < 0 || tab.length == 0) {
return true;
}
var total = self.wizardDialog.bootstrapWizard("navigationLength");
if (index === total) {
if (index == total) {
self.wizardDialog.find(".button-next").hide();
self.wizardDialog.find(".button-finish").show().removeClass("disabled");
} else {
@@ -87,17 +87,17 @@ $(function() {
}
var active = tab[0].id;
if (active !== undefined) {
if (active != undefined) {
callViewModels(allViewModels, "onAfterWizardTabChange", [active]);
}
},
onTabChange: function(tab, navigation, index, nextTabIndex, nextTab) {
var current, next;
if (index === undefined || index < 0 ||
nextTabIndex === undefined || nextTabIndex < 0 ||
index === nextTabIndex ||
tab.length === 0 || nextTab.length === 0) {
if (index == undefined || index < 0 ||
nextTabIndex == undefined || nextTabIndex < 0 ||
index == nextTabIndex ||
tab.length == 0 || nextTab.length == 0) {
// let's ignore that nonsense
return;
}
@@ -105,7 +105,7 @@ $(function() {
current = tab[0].id;
next = nextTab[0].id;
if (current !== undefined && next !== undefined) {
if (current != undefined && next != undefined) {
var result = true;
callViewModels(allViewModels, "onBeforeWizardTabChange", function(method) {
// we want to continue evaluating even if result becomes false
@@ -145,7 +145,7 @@ $(function() {
// first, or it won't happen after the reload flag has been
// set once due to the || making further evaluation unnecessary
// then
reload = (method() === "reload") || reload;
reload = (method() == "reload") || reload;
});
self.finishWizard()
.done(function() {
@@ -5,14 +5,14 @@
<p>Version <span class="version">{{ display_version }}</span></p>
<ul>
<li>Website: <a href="http://octoprint.org" target="_blank" rel="noreferrer noopener">octoprint.org</a></li>
<li>Website: <a href="https://octoprint.org" target="_blank" rel="noreferrer noopener">octoprint.org</a></li>
<li>Source Code: <a href="https://github.com/foosel/OctoPrint" target="_blank" rel="noreferrer noopener">github.com/foosel/OctoPrint</a></li>
<li>Documentation: <a href="http://docs.octoprint.org" target="_blank" rel="noreferrer noopener">docs.octoprint.org</a></li>
</ul>
<p>
<strong>Development of OctoPrint wouldn't be possible without <a href="javascript:void(0)" data-bind="click: function() { showTab('{{ templates.about.entries.supporters[1]._div }}'); }">its supporters</a>.</strong><br>
If you enjoy OctoPrint, please consider <a href="http://octoprint.org/support-octoprint/" target="_blank" rel="noreferrer noopener">supporting its ongoing development</a>.
If you enjoy OctoPrint, please consider <a href="https://octoprint.org/support-octoprint/?utm_source=octoprint&utm_medium=about_dialog" target="_blank" rel="noreferrer noopener">supporting its ongoing development</a>.
</p>
<p>
@@ -3,7 +3,7 @@
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: feature_legacyPluginAssets" id="settings-legacyPluginAssets"> {{ _('Enable legacy plugin asset bundling') }} <span class="label label-info">Compatibility</span>
<span class="help-block">{% trans url="http://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/" %}
<span class="help-block">{% trans url="https://octoprint.org/blog/2017/12/01/heads-up-plugin-authors/" %}
Enable this, save and restart your server if you are running into issues with plugins with OctoPrint
1.3.6 or later that used to work with OctoPrint up to version 1.3.5. See <a href="{{ url }}">here</a>
for details on why this is happening. Note that this legacy flag will be removed in a future
@@ -17,7 +17,7 @@
<h4>{{ _('If you enjoy OctoPrint...') }}</h4>
<span style="display: inline-block; float: left; font-size: 4em; margin-right: .3em"><img src="{{ url_for('static', filename='img/tentacle-56x56.png') }}"></span>
<p>{% trans url='http://octoprint.org/support-octoprint/' %}
<p>{% trans url='https://octoprint.org/support-octoprint/?utm_source=octoprint&utm_medium=first_run_wizard' %}
Please consider to <strong><a href="{{ url }}" target="_blank">support OctoPrint's ongoing development</a></strong>,
which can only continue with funding by users like you! You can also find this link in the "About" dialog.<br>
<strong>Thank you!</strong>
+1 -1
View File
@@ -114,7 +114,7 @@
<li><small>{{ _('OctoPrint') }} <span class="version">{{ display_version|e }}</span></small></li>
</ul>
<ul id="footer_links" class="pull-right">
<li><a href="http://octoprint.org" target="_blank" rel="noreferrer noopener"><i class="fa fa-home"></i> {{ _('Homepage') }}</a></li>
<li><a href="https://octoprint.org" target="_blank" rel="noreferrer noopener"><i class="fa fa-home"></i> {{ _('Homepage') }}</a></li>
<li><a href="https://github.com/foosel/OctoPrint/" target="_blank" rel="noreferrer noopener"><i class="fa fa-github"></i> {{ _('Source') }}</a></li>
<li><a href="http://docs.octoprint.org" target="_blank" rel="noreferrer noopener"><i class="fa fa-book"></i> {{ _('Docs') }}</a></li>
<li><a href="https://github.com/foosel/OctoPrint/issues" target="_blank" rel="noreferrer noopener"><i class="fa fa-flag"></i> {{ _('Issues') }}</a></li>
@@ -4,7 +4,7 @@
with normal operation.
{% endtrans %}</p>
<p>{% trans url="http://plugins.octoprint.org/blacklist/" %}
<p>{% trans url="https://plugins.octoprint.org/blacklist/" %}
By default, OctoPrint will use the blacklist hosted at <code>plugins.octoprint.org/blacklist.json</code> which you
can also take a look at in a more human readable format <a href="{{ url }}" target="_blank">here</a>.
{% endtrans %}</p>
+81
View File
@@ -1136,6 +1136,87 @@ class RepeatedTimer(threading.Thread):
if callable(self.on_finish):
self.on_finish()
class ResettableTimer(threading.Thread):
"""
This class represents an action that should be run after a specified amount of time. It is similar to python's
own :class:`threading.Timer` class, with the addition of being able to reset the counter to zero.
ResettableTimers are started, as with threads, by calling their ``start()`` method. The timer can be stopped (in
between runs) by calling the :func:`cancel` method. Resetting the counter can be done with the :func:`reset` method.
For example:
.. code-block:: python
def hello():
print("Ran hello() at {}").format(time.time())
t = ResettableTimers(60.0, hello)
t.start()
print("Started at {}").format(time.time())
time.sleep(30)
t.reset()
print("Reset at {}").format(time.time())
Arguments:
interval (float or callable): The interval before calling ``function``, in seconds. Can also be a callable
returning the interval to use, in case the interval is not static.
function (callable): The function to call.
args (list or tuple): The arguments for the ``function`` call. Defaults to an empty list.
kwargs (dict): The keyword arguments for the ``function`` call. Defaults to an empty dict.
on_cancelled (callable): Callback to call when the timer finishes due to being cancelled.
on_reset (callable): Callback to call when the timer is reset.
"""
def __init__(self, interval, function, args=None, kwargs=None, on_reset=None, on_cancelled=None):
threading.Thread.__init__(self)
self._event = threading.Event()
self._mutex = threading.Lock()
self.is_reset = True
if args is None:
args = []
if kwargs is None:
kwargs = dict()
self.interval = interval
self.function = function
self.args = args
self.kwargs = kwargs
self.on_cancelled = on_cancelled
self.on_reset = on_reset
def run(self):
while self.is_reset:
with self._mutex:
self.is_reset = False
self._event.wait(self.interval)
if not self._event.isSet():
self.function(*self.args, **self.kwargs)
with self._mutex:
self._event.set()
def cancel(self):
with self._mutex:
self._event.set()
if callable(self.on_cancelled):
self.on_cancelled()
def reset(self, interval=None):
with self._mutex:
if interval:
self.interval = interval
self.is_reset = True
self._event.set()
self._event.clear()
if callable(self.on_reset):
self.on_reset()
class CountedEvent(object):
+90 -26
View File
@@ -118,7 +118,7 @@ Groups will be as follows:
* ``target``: new target temperature (float)
"""
regex_position = re.compile("X:(?P<x>{float})\s*Y:(?P<y>{float})\s*Z:(?P<z>{float})\s*E:(?P<e>{float})".format(float=regex_float_pattern))
regex_position = re.compile("X:(?P<x>{float})\s*Y:(?P<y>{float})\s*Z:(?P<z>{float})\s*((E:(?P<e>{float}))|(?P<es>(E\d+:{float}\s*)+))".format(float=regex_float_pattern))
"""Regex for matching position reporting.
Groups will be as follows:
@@ -126,7 +126,17 @@ Groups will be as follows:
* ``x``: X coordinate
* ``y``: Y coordinate
* ``z``: Z coordinate
* ``e``: E coordinate
* ``e``: E coordinate if present, or
* ``es``: multiple E coordinates if present, to be parsed further with regex_e_positions
"""
regex_e_positions = re.compile("E(?P<id>\d+):(?P<value>{float})".format(float=regex_float_pattern))
"""Regex for matching multiple E coordinates in a position report.
Groups will be as follows:
* ``id``: id of the extruder or which the position is reported
* ``value``: reported position value
"""
regex_firmware_splitter = re.compile("\s*([A-Z0-9_]+):")
@@ -219,29 +229,39 @@ gcodeToEvent = {
}
class PositionRecord(object):
_standard_attrs = {"x", "y", "z", "e", "f", "t"}
@classmethod
def valid_e(cls, attr):
if not attr.startswith("e"):
return False
try:
int(attr[1:])
except:
return False
return True
def __init__(self, *args, **kwargs):
self.x = kwargs.get("x")
self.y = kwargs.get("y")
self.z = kwargs.get("z")
self.e = kwargs.get("e")
self.f = kwargs.get("f")
self.t = kwargs.get("t")
attrs = self._standard_attrs | set([key for key in kwargs if self.valid_e(key)])
for attr in attrs:
setattr(self, attr, kwargs.get(attr))
def copy_from(self, other):
self.x = other.x
self.y = other.y
self.z = other.z
self.e = other.e
self.f = other.f
self.t = other.t
# make sure all standard attrs and attrs from other are set
attrs = self._standard_attrs | set([key for key in dir(other) if self.valid_e(key)])
for attr in attrs:
setattr(self, attr, getattr(other, attr))
# delete attrs other doesn't have
attrs = set([key for key in dir(self) if self.valid_e(key)]) - attrs
for attr in attrs:
delattr(self, attr)
def as_dict(self):
return dict(x=self.x,
y=self.y,
z=self.z,
e=self.e,
t=self.t,
f=self.f)
attrs = self._standard_attrs | set([key for key in dir(self) if self.valid_e(key)])
return dict((attr, getattr(self, attr)) for attr in attrs)
class TemperatureRecord(object):
def __init__(self):
@@ -1307,17 +1327,26 @@ class MachineCom(object):
# position report processing
if 'X:' in line and 'Y:' in line and 'Z:' in line:
match = regex_position.search(line)
if match:
parsed = parse_position_line(line)
if parsed:
# we don't know T or F when printing from SD since
# there's no way to query it from the firmware and
# no way to track it ourselves when not streaming
# the file - this all sucks sooo much
self.last_position.valid = True
self.last_position.x = float(match.group("x"))
self.last_position.y = float(match.group("y"))
self.last_position.z = float(match.group("z"))
self.last_position.e = float(match.group("e"))
self.last_position.x = parsed.get("x")
self.last_position.y = parsed.get("y")
self.last_position.z = parsed.get("z")
if "e" in parsed:
self.last_position.e = parsed.get("e")
else:
# multiple extruder coordinates provided, find current one
self.last_position.e = parsed.get("e{}".format(self._currentTool)) if not self.isSdFileSelected() else None
for key in [key for key in parsed if key.startswith("e") and len(key) > 1]:
setattr(self.last_position, key, parsed.get(key))
self.last_position.t = self._currentTool if not self.isSdFileSelected() else None
self.last_position.f = self._currentF if not self.isSdFileSelected() else None
@@ -3475,6 +3504,41 @@ def parse_resend_line(line):
return None
def parse_position_line(line):
"""
Parses the provided M114 response line and returns the parsed coordinates.
Args:
line (str): the line to parse
Returns:
dict or None: the parsed coordinates, or None if no coordinates could be parsed
"""
match = regex_position.search(line)
if match is not None:
result = dict(x=float(match.group("x")),
y=float(match.group("y")),
z=float(match.group("z")))
if match.group("e") is not None:
# report contains only one E
result["e"] = float(match.group("e"))
elif match.group("es") is not None:
# report contains individual entries for multiple extruders ("E0:... E1:... E2:...")
es = match.group("es")
for m in regex_e_positions.finditer(es):
result["e{}".format(m.group("id"))] = float(m.group("value"))
else:
# apparently no E at all, should never happen but let's still handle this
return None
return result
return None
def gcode_command_for_cmd(cmd):
"""
Tries to parse the provided ``cmd`` and extract the GCODE command identifier from it (e.g. "G0" for "G0 X10.0").
+57
View File
@@ -46,6 +46,63 @@ def get_octoprint_version(base=False):
return octoprint_version
def is_released_octoprint_version(version=None):
"""
>>> import pkg_resources
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.6rc3"))
True
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.6rc3.dev2+g1234"))
False
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.6"))
True
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.6.post1+g1234"))
True
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.6.post1.dev0+g1234"))
False
>>> is_released_octoprint_version(version=pkg_resources.parse_version("1.3.7.dev123+g23545"))
False
"""
if version is None:
version = get_octoprint_version()
if isinstance(version, tuple):
# old setuptools
return "*@" not in version
else:
# new setuptools
return "dev" not in version.public
def is_stable_octoprint_version(version=None):
"""
>>> import pkg_resources
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.6rc3"))
False
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.6rc3.dev2+g1234"))
False
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.6"))
True
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.6.post1+g1234"))
True
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.6.post1.dev0+g1234"))
False
>>> is_stable_octoprint_version(version=pkg_resources.parse_version("1.3.7.dev123+g23545"))
False
"""
if version is None:
version = get_octoprint_version()
if not is_released_octoprint_version(version=version):
return False
if isinstance(version, tuple):
return "*a" not in version and "*b" not in version and "*c" not in version
else:
return not version.is_prerelease
def is_octoprint_compatible(*compatibility_entries, **kwargs):
"""
Tests if the current ``octoprint_version`` is compatible to any of the provided ``compatibility_entries``.
+99
View File
@@ -297,3 +297,102 @@ class TestCommHelpers(unittest.TestCase):
from octoprint.util.comm import parse_resend_line
result = parse_resend_line(line)
self.assertEqual(expected, result)
@data(
# Marlin
("ok X:62.417 Y:64.781 Z:0.2 E:2.72328 Count: A:6241 B:6478 C:20", dict(x=62.417,
y=64.781,
z=0.2,
e=2.72328)),
("X:62.417 Y:64.781 Z:0.2 E:2.72328 Count: A:6241 B:6478 C:20", dict(x=62.417,
y=64.781,
z=0.2,
e=2.72328)),
# RepRapFirmware
("X:96.99 Y:88.31 Z:0.30 E0:0.0 E1:0.0 E2:0.0 E3:0.0 E4:0.0 E5:0.0", dict(x=96.99,
y=88.31,
z=0.3,
e0=0.0,
e1=0.0,
e2=0.0,
e3=0.0,
e4=0.0,
e5=0.0)),
# invalid
("", None),
("X:62.417 Y:64.781 Z:0.2", None)
)
@unpack
def test_parse_position_line(self, line, expected):
from octoprint.util.comm import parse_position_line
result = parse_position_line(line)
if expected is None:
self.assertIsNone(result)
else:
self.assertDictEqual(expected, result)
class TestPositionRecord(unittest.TestCase):
def test_as_dict_regular(self):
coords = dict(x=1, y=2, z=3, e=4)
position = self._create_position(**coords)
expected = dict(coords)
expected.update(dict(f=None, t=None))
self.assertDictEqual(position.as_dict(), expected)
def test_as_dict_extra_e(self):
coords = dict(x=1, y=2, z=3, e0=4, e1=5)
position = self._create_position(**coords)
expected = dict(coords)
expected.update(dict(e=None, f=None, t=None))
self.assertDictEqual(position.as_dict(), expected)
def test_copy_from_regular(self):
coords = dict(x=1, y=2, z=3, e=4)
position1 = self._create_position(**coords)
position2 = self._create_position()
position2.copy_from(position1)
expected = dict(coords)
expected.update(dict(f=None, t=None))
self.assertDictEqual(position2.as_dict(), expected)
def test_copy_from_extra_e(self):
coords = dict(x=1, y=2, z=3, e0=4, e1=5)
position1 = self._create_position(**coords)
position2 = self._create_position()
position2.copy_from(position1)
expected = dict(coords)
expected.update(dict(e=None, f=None, t=None))
self.assertDictEqual(position2.as_dict(), expected)
def test_copy_from_extra_e_changed(self):
coords1 = dict(x=1, y=2, z=3, e0=4, e1=5)
position1 = self._create_position(**coords1)
coords2 = dict(x=2, y=4, z=6, e0=8, e1=10, e2=12)
position2 = self._create_position(**coords2)
expected_before = dict(coords2)
expected_before.update(dict(e=None, f=None, t=None))
self.assertDictEqual(position2.as_dict(), expected_before)
position2.copy_from(position1)
expected_after = dict(coords1)
expected_after.update(dict(e=None, f=None, t=None))
self.assertDictEqual(position2.as_dict(), expected_after)
def _create_position(self, **kwargs):
from octoprint.util.comm import PositionRecord
return PositionRecord(**kwargs)
+59
View File
@@ -0,0 +1,59 @@
# coding=utf-8
from __future__ import absolute_import, division, print_function
__author__ = "Gina Häußge <osd@foosel.net>"
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
import unittest
import mock
import time
from octoprint.util import ResettableTimer
class ResettableTimerTest(unittest.TestCase):
def setUp(self):
pass
def test_function(self):
timer_task = mock.MagicMock()
timer = ResettableTimer(10, timer_task)
timer.start()
# wait for it
timer.join()
self.assertEqual(1, timer_task.call_count)
def test_reset_callback(self):
timer_task = mock.MagicMock()
on_reset_cb = mock.MagicMock()
timer = ResettableTimer(10, timer_task, on_reset=on_reset_cb)
timer.start()
timer.reset()
# wait for it
timer.join()
self.assertEqual(1, timer_task.call_count)
self.assertEqual(1, on_reset_cb.call_count)
def test_canceled_callback(self):
timer_task = mock.MagicMock()
on_cancelled_cb = mock.MagicMock()
timer = ResettableTimer(10, timer_task, on_cancelled=on_cancelled_cb)
timer.start()
time.sleep(5)
timer.cancel()
time.sleep(10)
self.assertEqual(0, timer_task.call_count)
self.assertEqual(1, on_cancelled_cb.call_count)