Merge branch 'maintenance' into devel
This commit is contained in:
commit
7f2eb470e4
33 files changed
+308
-141
No files matched your search
@@ -447,7 +447,7 @@ class PluginInfo(object):
|
||||
@property
|
||||
def hooks(self):
|
||||
"""
|
||||
Hooks provided by the plugin. Will be taken from the hooks attribute of the plugin module as defiend in
|
||||
Hooks provided by the plugin. Will be taken from the hooks attribute of the plugin module as defined in
|
||||
:attr:`attr_hooks` if available, otherwise an empty dictionary is returned.
|
||||
|
||||
Returns:
|
||||
|
||||
@@ -212,7 +212,7 @@ class DiscoveryPlugin(octoprint.plugin.StartupPlugin,
|
||||
|
||||
def zeroconf_unregister(self, reg_type, port=None):
|
||||
"""
|
||||
Unregisteres a previously registered Zeroconf/Bonjour/Avahi service identified by service and port.
|
||||
Unregisters a previously registered Zeroconf/Bonjour/Avahi service identified by service and port.
|
||||
|
||||
:param reg_type: the type of the service to be unregistered
|
||||
:param port: the port of the service to be unregistered, defaults to OctoPrint's (public) port if not given
|
||||
|
||||
@@ -197,7 +197,6 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
notices_ttl=6*60,
|
||||
pip_args=None,
|
||||
pip_force_user=False,
|
||||
confirm_uninstall=True,
|
||||
confirm_disable=False,
|
||||
dependency_links=False,
|
||||
hidden=[],
|
||||
@@ -298,6 +297,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
"uninstall": ["plugin"],
|
||||
"enable": ["plugin"],
|
||||
"disable": ["plugin"],
|
||||
"cleanup": ["plugin"],
|
||||
"refresh_repository": []
|
||||
}
|
||||
|
||||
@@ -384,7 +384,15 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
return make_response("Unknown plugin: %s" % plugin_name, 404)
|
||||
|
||||
plugin = self._plugin_manager.plugins[plugin_name]
|
||||
return self.command_uninstall(plugin)
|
||||
return self.command_uninstall(plugin, cleanup=data.get("cleanup", False))
|
||||
|
||||
elif command == "cleanup":
|
||||
plugin_name = data["plugin"]
|
||||
if not plugin_name in self._plugin_manager.plugins:
|
||||
return make_response("Unknown plugin: %s" % plugin_name, 404)
|
||||
|
||||
plugin = self._plugin_manager.plugins[plugin_name]
|
||||
return self.command_cleanup(plugin)
|
||||
|
||||
elif command == "enable" or command == "disable":
|
||||
plugin_name = data["plugin"]
|
||||
@@ -565,7 +573,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._send_result_notification("install", result)
|
||||
return jsonify(result)
|
||||
|
||||
def command_uninstall(self, plugin):
|
||||
def command_uninstall(self, plugin, cleanup=False):
|
||||
if plugin.key == "pluginmanager":
|
||||
return make_response("Can't uninstall Plugin Manager", 403)
|
||||
|
||||
@@ -614,7 +622,7 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
self._logger.warning("Trying to uninstall plugin {plugin} but origin is unknown ({plugin.origin.type})".format(**locals()))
|
||||
return make_response("Could not uninstall plugin, its origin is unknown")
|
||||
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin)
|
||||
needs_restart = self._plugin_manager.is_restart_needing_plugin(plugin) or cleanup
|
||||
needs_refresh = plugin.implementation and isinstance(plugin.implementation, octoprint.plugin.ReloadNeedingPlugin)
|
||||
needs_reconnect = self._plugin_manager.has_any_of_hooks(plugin, self._reconnect_hooks) and self._printer.is_operational()
|
||||
|
||||
@@ -654,6 +662,45 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
needs_reconnect=needs_reconnect,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
self._send_result_notification("uninstall", result)
|
||||
self._logger.info("Plugin {} uninstalled".format(plugin.key))
|
||||
|
||||
if cleanup:
|
||||
self.command_cleanup(plugin)
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
def command_cleanup(self, plugin):
|
||||
# delete plugin settings
|
||||
self._settings.global_set(["plugins", plugin.key], None)
|
||||
self._settings.save()
|
||||
message = "Cleaned up settings of plugin {}".format(plugin.key)
|
||||
self._log_stdout(message)
|
||||
self._logger.info(message)
|
||||
|
||||
# delete plugin data folder
|
||||
import os
|
||||
import shutil
|
||||
|
||||
result_data = True
|
||||
data_folder = os.path.join(self._settings.getBaseFolder("data"), plugin.key)
|
||||
if os.path.exists(data_folder):
|
||||
try:
|
||||
shutil.rmtree(data_folder)
|
||||
message = "Cleaned up data folder of plugin {}".format(plugin.key)
|
||||
self._log_stdout(message)
|
||||
self._logger.info(message)
|
||||
except:
|
||||
message = "Could not delete data folder of plugin {} at {}".format(plugin.key, data_folder)
|
||||
self._log_stderr(message)
|
||||
self._logger.exception(message)
|
||||
result_data = False
|
||||
|
||||
result = dict(result=result_data,
|
||||
needs_restart=True,
|
||||
plugin=self._to_external_plugin(plugin))
|
||||
self._send_result_notification("cleanup", result)
|
||||
self._logger.info("Plugin {} cleaned up".format(plugin.key))
|
||||
|
||||
return jsonify(result)
|
||||
|
||||
def command_toggle(self, plugin, command):
|
||||
|
||||
@@ -52,11 +52,25 @@
|
||||
return this.base.simpleApiCommand("pluginmanager", "install", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, opts) {
|
||||
OctoPrintPluginManagerClient.prototype.uninstall = function(plugin, cleanup, opts) {
|
||||
// backwards compatibility to former argument list (plugin, opts)
|
||||
if (arguments.length === 2 && typeof cleanup === "object") {
|
||||
opts = cleanup;
|
||||
cleanup = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
plugin: plugin,
|
||||
cleanup: !!cleanup
|
||||
};
|
||||
return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.cleanup = function(plugin, opts) {
|
||||
var data = {
|
||||
plugin: plugin
|
||||
};
|
||||
return this.base.simpleApiCommand("pluginmanager", "uninstall", data, opts);
|
||||
return this.base.simpleApiCommand("pluginmanager", "cleanup", data, opts);
|
||||
};
|
||||
|
||||
OctoPrintPluginManagerClient.prototype.enable = function(plugin, opts) {
|
||||
|
||||
@@ -186,6 +186,12 @@ $(function() {
|
||||
&& !data.pending_uninstall;
|
||||
};
|
||||
|
||||
self.enableCleanup = function(data) {
|
||||
return self.enableManagement()
|
||||
&& data.key !== 'pluginmanager'
|
||||
&& !data.pending_uninstall;
|
||||
};
|
||||
|
||||
self.enableRepoInstall = function(data) {
|
||||
return self.enableManagement() && self.pipAvailable() && !self.safeMode() && !self.throttled() && self.online() && self.isCompatible(data);
|
||||
};
|
||||
@@ -566,14 +572,14 @@ $(function() {
|
||||
}
|
||||
|
||||
if (data.bundled) return;
|
||||
if (data.key == "pluginmanager") return;
|
||||
if (data.key === "pluginmanager") return;
|
||||
|
||||
// defining actual uninstall logic as functor in order to handle
|
||||
// the confirm/no-confirm logic without duplication of logic
|
||||
var performUninstall = function() {
|
||||
var performUninstall = function(cleanup) {
|
||||
self._markWorking(gettext("Uninstalling plugin..."), _.sprintf(gettext("Uninstalling plugin \"%(name)s\""), {name: _.escape(data.name)}));
|
||||
|
||||
OctoPrint.plugins.pluginmanager.uninstall(data.key)
|
||||
OctoPrint.plugins.pluginmanager.uninstall(data.key, cleanup)
|
||||
.done(function() {
|
||||
self.requestData();
|
||||
})
|
||||
@@ -590,19 +596,56 @@ $(function() {
|
||||
});
|
||||
};
|
||||
|
||||
if (self.settingsViewModel.settings.plugins.pluginmanager.confirm_uninstall()) {
|
||||
// confirmation needed. Show confirmation dialog and call performUninstall if user clicks Yes
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: _.escape(data.name)}),
|
||||
cancel: gettext("Keep installed"),
|
||||
proceed: gettext("Uninstall"),
|
||||
onproceed: performUninstall,
|
||||
nofade: true
|
||||
});
|
||||
} else {
|
||||
// no confirmation needed, just go ahead and uninstall
|
||||
performUninstall();
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to uninstall the plugin \"%(name)s\""), {name: _.escape(data.name)}),
|
||||
cancel: gettext("Keep installed"),
|
||||
proceed: [
|
||||
gettext("Uninstall"),
|
||||
gettext("Uninstall & clean up data")
|
||||
],
|
||||
onproceed: function(button) {
|
||||
// buttons: 0=uninstall, 1=uninstall&cleanup
|
||||
performUninstall(button === 1)
|
||||
},
|
||||
nofade: true
|
||||
});
|
||||
};
|
||||
|
||||
self.cleanupPlugin = function(data) {
|
||||
if (!self.loginState.isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self.enableUninstall(data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.key === "pluginmanager") return;
|
||||
|
||||
var performCleanup = function() {
|
||||
self._markWorking(gettext("Cleaning up plugin data..."), _.sprintf(gettext("Cleaning up data of plugin \"%(name)s\""), {name: _.escape(data.name)}));
|
||||
|
||||
OctoPrint.plugins.pluginmanager.cleanup(data.key)
|
||||
.fail(function() {
|
||||
new PNotify({
|
||||
title: gettext("Something went wrong"),
|
||||
text: gettext("Please consult octoprint.log for details"),
|
||||
type: "error",
|
||||
hide: false
|
||||
});
|
||||
})
|
||||
.always(function() {
|
||||
self._markDone();
|
||||
})
|
||||
};
|
||||
|
||||
showConfirmationDialog({
|
||||
message: _.sprintf(gettext("You are about to cleanup the plugin data of \"%(name)s\". This operation cannot be reversed."), {name: _.escape(data.name)}),
|
||||
cancel: gettext("Keep data"),
|
||||
proceed: gettext("Cleanup data"),
|
||||
onproceed: performCleanup,
|
||||
nofade: true
|
||||
});
|
||||
};
|
||||
|
||||
self.refreshRepository = function() {
|
||||
@@ -749,6 +792,10 @@ $(function() {
|
||||
line = gettext("Disable <em>%(plugin)s</em>: %(result)s");
|
||||
break;
|
||||
}
|
||||
case "cleanup": {
|
||||
line = gettext("Cleanup <em>%(plugin)s</em>: %(result)s");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
</div>
|
||||
</td>
|
||||
<td class="settings_plugin_plugin_manager_plugins_actions">
|
||||
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a> | <a href="#" class="fa fa-trash-o" title="{{ _('Uninstall Plugin')|edq }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
|
||||
<a href="#" data-bind="css: $root.toggleButtonCss($data), attr: {title: $root.toggleButtonTitle($data)}, enable: $root.enableToggle($data), click: function() { $root.togglePlugin($data) }"></a> | <a href="#" class="fa fa-eraser" title="{{ _('Cleanup Plugin Data')|edq }}" data-bind="css: {disabled: !$root.enableCleanup($data)}, enable: $root.enableCleanup($data), click: function() { $root.cleanupPlugin($data) }"> | <a href="#" class="fa fa-trash-o" title="{{ _('Uninstall Plugin')|edq }}" data-bind="css: {disabled: !$root.enableUninstall($data)}, enable: $root.enableUninstall($data), click: function() { $root.uninstallPlugin($data) }"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -267,13 +267,6 @@
|
||||
<fieldset>
|
||||
<legend>{{ _('Confirmations') }}</legend>
|
||||
|
||||
<div class="control-group" title="{{ _('Confirm before uninstalling a plugin')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: config_confirmUninstall"> {{ _('Confirm before uninstalling a plugin') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('Confirm before disabling a plugin')|edq }}">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
|
||||
@@ -139,9 +139,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._configured_checks = self._settings.get(["checks"], merged=True)
|
||||
|
||||
update_check_hooks = self._plugin_manager.get_hooks("octoprint.plugin.softwareupdate.check_config")
|
||||
check_providers = self._settings.get(["check_providers"], merged=True)
|
||||
if not isinstance(check_providers, dict):
|
||||
check_providers = dict()
|
||||
check_providers = dict()
|
||||
|
||||
effective_configs = dict()
|
||||
|
||||
@@ -189,9 +187,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
for key, config in effective_configs.items():
|
||||
self._configured_checks[key] = config
|
||||
|
||||
self._settings.set(["check_providers"], check_providers)
|
||||
self._settings.save()
|
||||
|
||||
# we only want to process checks that came from plugins for
|
||||
# which the plugins are still installed and enabled
|
||||
config_checks = self._settings.get(["checks"])
|
||||
@@ -300,7 +295,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
},
|
||||
},
|
||||
"pip_command": None,
|
||||
"check_providers": {},
|
||||
|
||||
"cache_ttl": 24 * 60,
|
||||
|
||||
@@ -314,9 +308,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
if "checks" in data:
|
||||
del data["checks"]
|
||||
|
||||
if "check_providers" in data:
|
||||
del data["check_providers"]
|
||||
|
||||
checks = self._get_configured_checks()
|
||||
if "octoprint" in checks:
|
||||
data["octoprint_checkout_folder"] = self._get_octoprint_checkout_folder(checks=checks)
|
||||
@@ -453,7 +444,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
self._version_cache_dirty = True
|
||||
|
||||
def get_settings_version(self):
|
||||
return 6
|
||||
return 7
|
||||
|
||||
def on_settings_migrate(self, target, current=None):
|
||||
|
||||
@@ -538,6 +529,10 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
dummy_defaults["plugins"][self._identifier]["checks"]["octoprint"] = None
|
||||
self._settings.set(["checks", "octoprint"], None, defaults=dummy_defaults)
|
||||
|
||||
if current is None or current < 7:
|
||||
# remove check_providers again
|
||||
self._settings.set(["check_providers"], None, defaults=dict(check_providers=dict()))
|
||||
|
||||
def _clean_settings_check(self, key, data, defaults, delete=None, save=True):
|
||||
if not data:
|
||||
# nothing to do
|
||||
|
||||
@@ -69,7 +69,7 @@ class PrintTimeEstimator(object):
|
||||
but no intelligent estimate yet, we'll use that for the next step. Otherwise, up to a certain percentage
|
||||
in the print we do a percentage based weighing of the statistical data and the intelligent
|
||||
estimate - the closer to the beginning of the print, the more precedence for the statistical
|
||||
data, the closer to the cut off point, the more precendence for the intelligent estimate. This
|
||||
data, the closer to the cut off point, the more precedence for the intelligent estimate. This
|
||||
is our preliminary total print time.
|
||||
3. If the total print time is set, we do a sanity check for it. Based on the total print time
|
||||
estimate and the time we already spent printing, we calculate at what percentage we SHOULD be
|
||||
|
||||
@@ -306,7 +306,7 @@ class Server(object):
|
||||
### open port and prevent us from firing up Tornado later.
|
||||
###
|
||||
### The intermediary server's socket should have the CLOSE_EXEC flag (or its equivalent) set where possible, but
|
||||
### we can only do that if fcntl is availabel or we are on Windows, so better safe than sorry.
|
||||
### we can only do that if fcntl is available or we are on Windows, so better safe than sorry.
|
||||
###
|
||||
### See also issues #2035 and #2090
|
||||
|
||||
@@ -798,12 +798,16 @@ class Server(object):
|
||||
|
||||
# auto connect
|
||||
if self._settings.getBoolean(["serial", "autoconnect"]):
|
||||
self._logger.info("Autoconnect on startup is configured, trying to connect to the printer...")
|
||||
try:
|
||||
(port, baudrate) = self._settings.get(["serial", "port"]), self._settings.getInt(["serial", "baudrate"])
|
||||
printer_profile = printerProfileManager.get_default()
|
||||
connectionOptions = printer.__class__.get_connection_options()
|
||||
if port in connectionOptions["ports"] or port == "AUTO":
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
if port in connectionOptions["ports"] or port == "AUTO" or port is None:
|
||||
self._logger.info("Trying to connect to configured serial port {}".format(port))
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
else:
|
||||
self._logger.info("Could not find configured serial port {} in the system, cannot automatically connect to a non existing printer. Is it plugged in and booted up yet?")
|
||||
except Exception:
|
||||
self._logger.exception("Something went wrong while attempting to automatically connect to the printer")
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ def pluginCommand(name):
|
||||
return response
|
||||
return NO_CONTENT
|
||||
except Exception:
|
||||
logging.getLogger(__name__).exception("Error while excuting SimpleApiPlugin {}".format(name),
|
||||
logging.getLogger(__name__).exception("Error while executing SimpleApiPlugin {}".format(name),
|
||||
extra=dict(plugin=name))
|
||||
return abort(500)
|
||||
|
||||
@@ -248,7 +248,7 @@ def login():
|
||||
|
||||
return r
|
||||
|
||||
return make_response(("User unknown or password incorrect", 401, []))
|
||||
return make_response(("User unknown or password incorrect", 403, []))
|
||||
|
||||
elif "passive" in data:
|
||||
return passive_login()
|
||||
|
||||
@@ -507,17 +507,17 @@ def _get_temperature_data(preprocessor):
|
||||
|
||||
|
||||
def _keep_tools(x):
|
||||
return _delete_from_data(x, lambda k: not k.startswith("tool"))
|
||||
return _delete_from_data(x, lambda k: not k.startswith("tool") and k != "history")
|
||||
|
||||
|
||||
def _keep_bed(x):
|
||||
return _delete_from_data(x, lambda k: k != "bed")
|
||||
return _delete_from_data(x, lambda k: k != "bed" and k != "history")
|
||||
|
||||
def _delete_bed(x):
|
||||
return _delete_from_data(x, lambda k: k == "bed")
|
||||
|
||||
def _keep_chamber(x):
|
||||
return _delete_from_data(x, lambda k: k != "chamber")
|
||||
return _delete_from_data(x, lambda k: k != "chamber" and k != "history")
|
||||
|
||||
def _delete_chamber(x):
|
||||
return _delete_from_data(x, lambda k: k == "chamber")
|
||||
|
||||
@@ -181,6 +181,7 @@ def getSettings():
|
||||
"blockWhileDwelling": s.getBoolean(["serial", "blockWhileDwelling"]),
|
||||
"useParityWorkaround": s.get(["serial", "useParityWorkaround"]),
|
||||
"sendM112OnError": s.getBoolean(["serial", "sendM112OnError"]),
|
||||
"ackMax": s.getInt(["serial", "ackMax"]),
|
||||
"maxTimeoutsIdle": s.getInt(["serial", "maxCommunicationTimeouts", "idle"]),
|
||||
"maxTimeoutsPrinting": s.getInt(["serial", "maxCommunicationTimeouts", "printing"]),
|
||||
"maxTimeoutsLong": s.getInt(["serial", "maxCommunicationTimeouts", "long"]),
|
||||
@@ -474,6 +475,7 @@ def _saveSettings(data):
|
||||
if value in ("always", "detect", "never"):
|
||||
s.set(["serial", "useParityWorkaround"], value)
|
||||
if "sendM112OnError" in data["serial"]: s.setBoolean(["serial", "sendM112OnError"], data["serial"]["sendM112OnError"])
|
||||
if "ackMax" in data["serial"]: s.setInt(["serial", "ackMax"], data["serial"]["ackMax"])
|
||||
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
|
||||
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
|
||||
if "abortHeatupOnCancel" in data["serial"]: s.setBoolean(["serial", "abortHeatupOnCancel"], data["serial"]["abortHeatupOnCancel"])
|
||||
|
||||
@@ -74,7 +74,7 @@ class RequestlessExceptionLoggingMixin(tornado.web.RequestHandler):
|
||||
class CorsSupportMixin(tornado.web.RequestHandler):
|
||||
"""
|
||||
`tornado.web.RequestHandler <http://tornado.readthedocs.org/en/branch4.0/web.html#request-handlers>`_ mixin that
|
||||
makes sure to set CORS headers similarily to the Flask backed API endpoints.
|
||||
makes sure to set CORS headers similarly to the Flask backed API endpoints.
|
||||
"""
|
||||
|
||||
ENABLE_CORS = False
|
||||
|
||||
@@ -153,6 +153,7 @@ default_settings = {
|
||||
"useParityWorkaround": "detect",
|
||||
"maxConsecutiveResends": 10,
|
||||
"sendM112OnError": True,
|
||||
"ackMax": 1,
|
||||
|
||||
"capabilities": {
|
||||
"autoreport_temp": True,
|
||||
@@ -1240,7 +1241,7 @@ class Settings(object):
|
||||
self._logger.info("Migrated {} action to server.commands.{}".format(action, migrate_to))
|
||||
|
||||
to_delete.append(index)
|
||||
self._logger.info("Deleting {} action from configured system commands, superseeded by server.commands.{}".format(action, migrate_to))
|
||||
self._logger.info("Deleting {} action from configured system commands, superseded by server.commands.{}".format(action, migrate_to))
|
||||
|
||||
for index in reversed(to_delete):
|
||||
actions.pop(index)
|
||||
|
||||
@@ -410,9 +410,9 @@ var doParse = function () {
|
||||
break;
|
||||
case 'g':
|
||||
if(args[j].charAt(1).toLowerCase() === '2')
|
||||
direction=1;
|
||||
if(args[j].charAt(1).toLowerCase() === '3')
|
||||
direction=-1;
|
||||
if(args[j].charAt(1).toLowerCase() === '3')
|
||||
direction=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,6 +737,8 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
|
||||
var html = options.html;
|
||||
|
||||
var checkboxes = options.checkboxes;
|
||||
|
||||
var cancel = options.cancel || gettext("Cancel");
|
||||
var proceed = options.proceed || gettext("Proceed");
|
||||
var proceedClass = options.proceedClass || "danger";
|
||||
@@ -764,18 +766,32 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
var cancelButton = $('<a href="javascript:void(0)" class="btn">' + cancel + '</a>')
|
||||
.attr("data-dismiss", "modal")
|
||||
.attr("aria-hidden", "true");
|
||||
var proceedButton = $('<a href="javascript:void(0)" class="btn">' + proceed + '</a>')
|
||||
.addClass("btn-" + proceedClass);
|
||||
|
||||
if (!_.isArray(proceed)) {
|
||||
proceed = [proceed];
|
||||
}
|
||||
|
||||
var proceedButtons = [];
|
||||
_.each(proceed, function(text) {
|
||||
proceedButtons.push($('<a href="javascript:void(0)" class="btn">' + text + '</a>')
|
||||
.addClass("btn-" + proceedClass));
|
||||
});
|
||||
|
||||
var modal = $('<div></div>')
|
||||
.addClass('modal hide');
|
||||
if (!nofade) {
|
||||
modal.addClass('fade');
|
||||
}
|
||||
|
||||
var buttons = $('<div></div>').addClass('modal-footer').append(cancelButton);
|
||||
_.each(proceedButtons, function(button) {
|
||||
buttons.append(button);
|
||||
});
|
||||
|
||||
modal.addClass(dialogClass)
|
||||
.append($('<div></div>').addClass('modal-header').append(modalHeader))
|
||||
.append($('<div></div>').addClass('modal-body').append(modalBody))
|
||||
.append($('<div></div>').addClass('modal-footer').append(cancelButton).append(proceedButton));
|
||||
.append(buttons);
|
||||
modal.on('hidden', function(event) {
|
||||
if (onclose && _.isFunction(onclose)) {
|
||||
onclose(event);
|
||||
@@ -789,12 +805,14 @@ function showConfirmationDialog(msg, onacknowledge, options) {
|
||||
}
|
||||
modal.modal(modalOptions);
|
||||
|
||||
proceedButton.click(function(e) {
|
||||
e.preventDefault();
|
||||
if (onproceed && _.isFunction(onproceed)) {
|
||||
onproceed(e);
|
||||
}
|
||||
modal.modal("hide");
|
||||
_.each(proceedButtons, function(button, idx) {
|
||||
button.click(function(e) {
|
||||
e.preventDefault();
|
||||
if (onproceed && _.isFunction(onproceed)) {
|
||||
onproceed(idx, e);
|
||||
}
|
||||
modal.modal("hide");
|
||||
})
|
||||
});
|
||||
cancelButton.click(function(e) {
|
||||
if (oncancel && _.isFunction(oncancel)) {
|
||||
|
||||
@@ -205,18 +205,10 @@ $(function() {
|
||||
}
|
||||
|
||||
switch(response.status) {
|
||||
case 401: {
|
||||
new PNotify({
|
||||
title: gettext("Login failed"),
|
||||
text: gettext("User unknown or wrong password"),
|
||||
type: "error"
|
||||
});
|
||||
break;
|
||||
}
|
||||
case 403: {
|
||||
new PNotify({
|
||||
title: gettext("Login failed"),
|
||||
text: gettext("Your account is deactivated"),
|
||||
text: gettext("User unknown, wrong password or account deactivated"),
|
||||
type: "error"
|
||||
});
|
||||
break;
|
||||
@@ -235,7 +227,7 @@ $(function() {
|
||||
self.fromResponse(response);
|
||||
})
|
||||
.fail(function(error) {
|
||||
if (error && error.status === 401) {
|
||||
if (error && error.status === 403) {
|
||||
self.fromResponse(false);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -205,6 +205,7 @@ $(function() {
|
||||
self.serial_capBusyProtocol = ko.observable(undefined);
|
||||
self.serial_capEmergencyParser = ko.observable(undefined);
|
||||
self.serial_sendM112OnError = ko.observable(undefined);
|
||||
self.serial_ackMax = ko.observable(undefined);
|
||||
|
||||
self.folder_uploads = ko.observable(undefined);
|
||||
self.folder_timelapse = ko.observable(undefined);
|
||||
@@ -659,7 +660,7 @@ $(function() {
|
||||
}
|
||||
}
|
||||
|
||||
// handler for any explicitely provided callbacks
|
||||
// handler for any explicitly provided callbacks
|
||||
var callbackHandler = function() {
|
||||
if (!callback) return;
|
||||
try {
|
||||
|
||||
@@ -398,6 +398,13 @@
|
||||
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" title="{{ _('ok buffer size')|edq }}">
|
||||
<label class="control-label" for="settings-serialAckMax">{{ _('<code>ok</code> buffer size') }}</label>
|
||||
<div class="controls">
|
||||
<input type="number" min="0" class="input-mini text-right" id="settings-serialAckMax" data-bind="value: serial_ackMax">
|
||||
<span class="help-block">{{ _('Only modify if told to do so') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<input type="number" min="1" class="input-mini" id="webcam_timelapse_minDelay" data-bind="value: timelapseMinDelay, valueUpdate: 'afterkeydown', enable: !isPrinting()">
|
||||
<span class="add-on">{{ _('sec') }}</span>
|
||||
</div>
|
||||
<span class="help-block">{{ _('OctoPrint will rate limit snapshots to this minimum interval. This is to prevent against performance issues with vase mode/continous z prints.') }}</span>
|
||||
<span class="help-block">{{ _('OctoPrint will rate limit snapshots to this minimum interval. This it to prevent against performance issues with vase mode/continuous z prints.') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: persist, enable: isOperational() && !isPrinting() && loginState.isUser()"> {{ _('Save as default') }}
|
||||
<input type="checkbox" data-bind="checked: persist"> {{ _('Save as default') }}
|
||||
<span class="help-block">{{ _('Check this to make your selected timelapse mode and options persist across restarts.') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
+37
-20
@@ -40,7 +40,7 @@ from octoprint.filemanager.destinations import FileDestinations
|
||||
from octoprint.util import get_exception_string, sanitize_ascii, filter_non_ascii, CountedEvent, RepeatedTimer, \
|
||||
to_unicode, bom_aware_open, TypedQueue, PrependableQueue, TypeAlreadyInQueue, chunks, ResettableTimer, \
|
||||
monotonic_time
|
||||
from octoprint.util.platform import get_os
|
||||
from octoprint.util.platform import get_os, set_close_exec
|
||||
|
||||
try:
|
||||
import winreg
|
||||
@@ -383,7 +383,7 @@ class MachineCom(object):
|
||||
CAPABILITY_SUPPORT_DETECTED = "detected"
|
||||
CAPABILITY_SUPPORT_DISABLED = "disabled"
|
||||
|
||||
def __init__(self, port = None, baudrate=None, callbackObject=None, printerProfileManager=None):
|
||||
def __init__(self, port=None, baudrate=None, callbackObject=None, printerProfileManager=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._serialLogger = logging.getLogger("SERIAL")
|
||||
self._phaseLogger = logging.getLogger(__name__ + ".command_phases")
|
||||
@@ -517,7 +517,8 @@ class MachineCom(object):
|
||||
self._pausing_commands = settings().get(["serial", "pausingCommands"])
|
||||
self._emergency_commands = settings().get(["serial", "emergencyCommands"])
|
||||
|
||||
self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None)
|
||||
self._ack_max = settings().getInt(["serial", "ackMax"])
|
||||
self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None, maximum=self._ack_max)
|
||||
self._send_queue = SendQueue()
|
||||
self._temperature_timer = None
|
||||
self._sd_status_timer = None
|
||||
@@ -2674,6 +2675,15 @@ class MachineCom(object):
|
||||
|
||||
serial_obj.open()
|
||||
|
||||
# Set close_exec flag on serial handle, see #3212
|
||||
if hasattr(serial_obj, "fd"):
|
||||
# posix
|
||||
set_close_exec(serial_obj.fd)
|
||||
elif hasattr(serial_obj, "_port_handle"):
|
||||
# win32
|
||||
# noinspection PyProtectedMember
|
||||
set_close_exec(serial_obj._port_handle)
|
||||
|
||||
return BufferedReadlineWrapper(serial_obj)
|
||||
|
||||
serial_factories = list(self._serial_factory_hooks.items()) + [("default", default)]
|
||||
@@ -3154,6 +3164,19 @@ class MachineCom(object):
|
||||
self._logger.debug("Type already in send queue: " + e.type)
|
||||
return False
|
||||
|
||||
def _use_up_clear(self, gcode):
|
||||
# we only need to use up a clear if the command we just sent was either a gcode command or if we also
|
||||
# require ack's for unknown commands
|
||||
eats_clear = self._unknownCommandsNeedAck
|
||||
if gcode is not None:
|
||||
eats_clear = True
|
||||
|
||||
if eats_clear:
|
||||
# if we need to use up a clear, do that now
|
||||
self._clear_to_send.clear()
|
||||
|
||||
return eats_clear
|
||||
|
||||
def _send_loop(self):
|
||||
"""
|
||||
The send loop is responsible of sending commands in ``self._send_queue`` over the line, if it is cleared for
|
||||
@@ -3200,6 +3223,7 @@ class MachineCom(object):
|
||||
if linenumber is not None:
|
||||
# line number predetermined - this only happens for resends, so we'll use the number and
|
||||
# send directly without any processing (since that already took place on the first sending!)
|
||||
self._use_up_clear(gcode)
|
||||
self._do_send_with_checksum(command.encode("ascii"), linenumber)
|
||||
|
||||
else:
|
||||
@@ -3250,7 +3274,13 @@ class MachineCom(object):
|
||||
continue
|
||||
|
||||
# now comes the part where we increase line numbers and send stuff - no turning back now
|
||||
used_up_clear = self._use_up_clear(gcode)
|
||||
self._do_send(command, gcode=gcode)
|
||||
if not used_up_clear:
|
||||
# If we didn't use up a clear we need to tickle the read queue - there might
|
||||
# not be a reply to this command, so our _monitor loop will stay waiting until
|
||||
# timeout. We definitely do not want that, so we tickle the queue manually here
|
||||
self._continue_sending()
|
||||
|
||||
# trigger "sent" phase and use up one "ok"
|
||||
if on_sent is not None and callable(on_sent):
|
||||
@@ -3258,21 +3288,6 @@ class MachineCom(object):
|
||||
on_sent()
|
||||
self._process_command_phase("sent", command, command_type, gcode=gcode, subcode=subcode, tags=tags)
|
||||
|
||||
# we only need to use up a clear if the command we just sent was either a gcode command or if we also
|
||||
# require ack's for unknown commands
|
||||
use_up_clear = self._unknownCommandsNeedAck
|
||||
if gcode is not None:
|
||||
use_up_clear = True
|
||||
|
||||
if use_up_clear:
|
||||
# if we need to use up a clear, do that now
|
||||
self._clear_to_send.clear()
|
||||
else:
|
||||
# Otherwise we need to tickle the read queue - there might not be a reply
|
||||
# to this command, so our _monitor loop will stay waiting until timeout. We
|
||||
# definitely do not want that, so we tickle the queue manually here
|
||||
self._continue_sending()
|
||||
|
||||
finally:
|
||||
# no matter _how_ we exit this block, we signal that we
|
||||
# are done processing the last fetched queue entry
|
||||
@@ -3790,10 +3805,12 @@ class MachineCom(object):
|
||||
return
|
||||
|
||||
self._logger.info(message)
|
||||
self._do_send(cmd, gcode=gcode)
|
||||
|
||||
# use up an ok since we will get one back for this command and don't want to get out of sync
|
||||
self._clear_to_send.clear()
|
||||
used_up_clear = self._use_up_clear(gcode)
|
||||
self._do_send(cmd, gcode=gcode)
|
||||
if not used_up_clear:
|
||||
self._continue_sending()
|
||||
|
||||
return None,
|
||||
|
||||
|
||||
@@ -64,36 +64,55 @@ class Vector3D(object):
|
||||
return math.sqrt(self.x * self.x + self.y * self.y + self.z * self.z)
|
||||
|
||||
def __add__(self, other):
|
||||
if isinstance(other, Vector3D):
|
||||
try:
|
||||
if len(other) == 3:
|
||||
return Vector3D(self.x + other[0],
|
||||
self.y + other[1],
|
||||
self.z + other[2])
|
||||
except TypeError:
|
||||
# doesn't look like a 3-tuple
|
||||
pass
|
||||
|
||||
try:
|
||||
return Vector3D(self.x + other.x,
|
||||
self.y + other.y,
|
||||
self.z + other.z)
|
||||
elif isinstance(other, (tuple, list)) and len(other) == 3:
|
||||
return Vector3D(self.x + other[0],
|
||||
self.y + other[1],
|
||||
self.z + other[2])
|
||||
else:
|
||||
raise ValueError("other must be a Vector3D instance or a list or tuple of length 3")
|
||||
except AttributeError:
|
||||
# also doesn't look like a Vector3D
|
||||
pass
|
||||
|
||||
raise TypeError("other must be a Vector3D instance or a list or tuple of length 3")
|
||||
|
||||
def __sub__(self, other):
|
||||
if isinstance(other, Vector3D):
|
||||
try:
|
||||
if len(other) == 3:
|
||||
return Vector3D(self.x - other[0],
|
||||
self.y - other[1],
|
||||
self.z - other[2])
|
||||
except TypeError:
|
||||
# doesn't look like a 3-tuple
|
||||
pass
|
||||
|
||||
try:
|
||||
return Vector3D(self.x - other.x,
|
||||
self.y - other.y,
|
||||
self.z - other.z)
|
||||
elif isinstance(other, (tuple, list)) and len(other) == 3:
|
||||
return Vector3D(self.x - other[0],
|
||||
self.y - other[1],
|
||||
self.z - other[2])
|
||||
else:
|
||||
raise ValueError("other must be a Vector3D instance or a list or tuple")
|
||||
except AttributeError:
|
||||
# also doesn't look like a Vector3D
|
||||
pass
|
||||
|
||||
raise TypeError("other must be a Vector3D instance or a list or tuple of length 3")
|
||||
|
||||
def __mul__(self, other):
|
||||
if isinstance(other, (int, float)):
|
||||
try:
|
||||
return Vector3D(self.x * other,
|
||||
self.y * other,
|
||||
self.z * other)
|
||||
else:
|
||||
raise ValueError("other must be a float or int value")
|
||||
except TypeError:
|
||||
# doesn't look like a scalar
|
||||
pass
|
||||
|
||||
raise ValueError("other must be a float or int value")
|
||||
|
||||
def __rmul__(self, other):
|
||||
return self.__mul__(other)
|
||||
@@ -344,11 +363,11 @@ class gcode(object):
|
||||
totalExtrusion[currentExtruder])
|
||||
|
||||
if currentExtruder == 0 and len(currentE) > 1 and duplicationMode:
|
||||
# Copy first extruder length to other extruders
|
||||
# Copy first extruder length to other extruders
|
||||
for i in range(1, len(currentE)):
|
||||
totalExtrusion[i] += e
|
||||
currentE[i] += e
|
||||
maxExtrusion[i] = max(maxExtrusion[i],
|
||||
totalExtrusion[i] += e
|
||||
currentE[i] += e
|
||||
maxExtrusion[i] = max(maxExtrusion[i],
|
||||
totalExtrusion[i])
|
||||
else:
|
||||
e = 0.0
|
||||
@@ -438,13 +457,13 @@ class gcode(object):
|
||||
else:
|
||||
fwrecoverTime = (fwretractDist + s) / f
|
||||
elif M == 605: #Duplication/Mirroring mode
|
||||
s = getCodeInt(line, 'S')
|
||||
if s in [2, 4, 5, 6]:
|
||||
# Duplication / Mirroring mode selected. Printer firmware copies extrusion commands
|
||||
s = getCodeInt(line, 'S')
|
||||
if s in [2, 4, 5, 6]:
|
||||
# Duplication / Mirroring mode selected. Printer firmware copies extrusion commands
|
||||
# from first extruder to all other extruders
|
||||
duplicationMode = True
|
||||
else:
|
||||
duplicationMode = False
|
||||
else:
|
||||
duplicationMode = False
|
||||
|
||||
elif T is not None:
|
||||
if T > max_extruders:
|
||||
|
||||
Reference in new issue
Block a user