Merge branch 'maintenance' into devel
This commit is contained in:
commit
f7ad7d93a5
20 files changed
+702
-214
No files matched your search
@@ -2,7 +2,6 @@ name: Build
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
types: [opened, sychronize, reopened]
|
||||
release:
|
||||
types: [published, prereleased]
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
name: "Linkify systeminfo bundles"
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created, edited]
|
||||
|
||||
jobs:
|
||||
linkifyBundles:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v2
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
let comment = context.payload.comment.body;
|
||||
|
||||
const botMarker = "<!-- linkify_bundles -->";
|
||||
const botWasHere = comment.indexOf(botMarker);
|
||||
if (botWasHere !== -1) {
|
||||
comment = comment.substring(0, botWasHere);
|
||||
};
|
||||
|
||||
const bundleRegex = /\[(octoprint-systeminfo-\d{14}\.zip)\]\(([^)]+)\)/g;
|
||||
|
||||
const bundles = [];
|
||||
const seen = [];
|
||||
const matches = comment.matchAll(bundleRegex);
|
||||
for (const match of matches) {
|
||||
if (!seen.includes(match[1])) {
|
||||
bundles.push({filename: match[1], link: match[2], match: match[0]});
|
||||
seen.push(match[1]);
|
||||
}
|
||||
};
|
||||
|
||||
if (bundles) {
|
||||
let text = comment + botMarker + "\n\n---\n\n\nBundles:\n\n";
|
||||
bundles.forEach((bundle) => {
|
||||
text += " * [" + bundle.filename + "](https://bundleviewer.octoprint.org/?url=" + encodeURIComponent(bundle.link) + ")\n"
|
||||
});
|
||||
text += "\n*edited by @github-actions to add bundle viewer links*\n";
|
||||
|
||||
github.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: context.payload.comment.id,
|
||||
body: text
|
||||
});
|
||||
}
|
||||
@@ -134,6 +134,9 @@ date of first contribution):
|
||||
* ["MichaIng"](https://github.com/MichaIng)
|
||||
* ["jasonbcox"](https://github.com/jasonbcox)
|
||||
* ["shadycuz"](https://github.com/shadycuz)
|
||||
* [David Rifkind](https://github.com/drifkind)
|
||||
* [Nils Hofmann](https://github.com/Master92)
|
||||
* [Miroslav Šedivý](https://github.com/eumiro)
|
||||
|
||||
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
|
||||
[Daid Braam](https://github.com/daid). Parts of its communication layer and
|
||||
|
||||
@@ -61,6 +61,7 @@ INSTALL_REQUIRES = [
|
||||
"sentry-sdk>=0.15.1,<1",
|
||||
"filetype>=1.0.7,<2",
|
||||
"zeroconf>=0.24,<0.25",
|
||||
"zipstream-new>=1.1.8,<1.2",
|
||||
# vendor bundled dependencies
|
||||
"unidecode>=0.04.14,<0.05", # dependency of awesome-slugify
|
||||
"blinker>=1.4,<2", # dependency of flask_principal
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2017 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
click.disable_unicode_literals_warning = True
|
||||
@@ -8,6 +10,40 @@ click.disable_unicode_literals_warning = True
|
||||
# ~~ "octoprint util" commands
|
||||
|
||||
|
||||
def validate_result(result):
|
||||
dimensions = ("depth", "height", "width")
|
||||
printing_area = ("maxX", "maxY", "maxZ", "minX", "minY", "minZ")
|
||||
|
||||
def validate_list(data):
|
||||
return not any(map(invalid_float, data))
|
||||
|
||||
def validate_dict(data, keys):
|
||||
for k in keys:
|
||||
if k not in data or invalid_float(data[k]):
|
||||
return False
|
||||
return True
|
||||
|
||||
def invalid_float(value):
|
||||
return value is None or value == float("inf") or value == float("-inf")
|
||||
|
||||
if "dimensions" not in result or not validate_dict(result["dimensions"], dimensions):
|
||||
return False
|
||||
|
||||
if "extrusion_length" not in result or not validate_list(result["extrusion_length"]):
|
||||
return False
|
||||
|
||||
if "extrusion_volume" not in result or not validate_list(result["extrusion_volume"]):
|
||||
return False
|
||||
|
||||
if "printing_area" not in result or not validate_dict(
|
||||
result["printing_area"], printing_area
|
||||
):
|
||||
return False
|
||||
|
||||
if "total_time" not in result or invalid_float(result["total_time"]):
|
||||
return False
|
||||
|
||||
|
||||
@click.group()
|
||||
def analysis_commands():
|
||||
pass
|
||||
@@ -88,6 +124,15 @@ def gcode_command(
|
||||
)
|
||||
|
||||
click.echo("DONE:{}s".format(time.monotonic() - start_time))
|
||||
|
||||
result = interpreter.get_result()
|
||||
if not validate_result(result):
|
||||
click.echo(
|
||||
"ERROR:Invalid analysis result, please create a bug report in OctoPrint's "
|
||||
"issue tracker and be sure to also include the GCODE file with which this "
|
||||
"happened"
|
||||
)
|
||||
sys.exit(-1)
|
||||
click.echo("RESULTS:")
|
||||
click.echo(
|
||||
yaml.safe_dump(
|
||||
|
||||
@@ -310,6 +310,10 @@ class AbstractAnalysisQueue:
|
||||
)
|
||||
)
|
||||
self._finished_callback(self._current, result)
|
||||
except RuntimeError as exc:
|
||||
self._logger.error(
|
||||
"Analysis for {} ran into error: {}".format(self._current, exc)
|
||||
)
|
||||
finally:
|
||||
self._current = None
|
||||
self._current_progress = None
|
||||
@@ -468,7 +472,10 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
output = p.stdout.text
|
||||
self._logger.debug("Got output: {!r}".format(output))
|
||||
|
||||
if "RESULTS:" not in output:
|
||||
if "ERROR:" in output:
|
||||
_, error = output.split("ERROR:")
|
||||
raise RuntimeError(error.strip())
|
||||
elif "RESULTS:" not in output:
|
||||
raise RuntimeError("No analysis result found")
|
||||
|
||||
_, output = output.split("RESULTS:")
|
||||
|
||||
@@ -22,6 +22,7 @@ class StorageInterface:
|
||||
Interface of storage adapters for OctoPrint.
|
||||
"""
|
||||
|
||||
# noinspection PyUnreachableCode
|
||||
@property
|
||||
def analysis_backlog(self):
|
||||
"""
|
||||
@@ -36,6 +37,7 @@ class StorageInterface:
|
||||
return
|
||||
yield
|
||||
|
||||
# noinspection PyUnreachableCode
|
||||
def analysis_backlog_for_path(self, path=None):
|
||||
# empty generator pattern, yield is intentionally unreachable
|
||||
return
|
||||
|
||||
@@ -103,6 +103,9 @@ GCODE.renderer = (function () {
|
||||
" segments"
|
||||
);
|
||||
|
||||
applyOffsets(layerNumStore);
|
||||
applyZoom(layerNumStore);
|
||||
|
||||
notifyIfViewportChanged();
|
||||
|
||||
var p1 = ctx.transformedPoint(0, 0);
|
||||
@@ -144,6 +147,51 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
function getLayerBounds(layer) {
|
||||
if (!model || !model[layer]) return;
|
||||
|
||||
var cmds = model[layer];
|
||||
var i = 0;
|
||||
|
||||
// find bounds based on x/y moves with extrusion only
|
||||
// if you want to change that criterion, this is the place to do it
|
||||
|
||||
while (i < cmds.length) {
|
||||
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == cmds.length) return;
|
||||
|
||||
// initialize with guaranteed defined values and cut out a bunch of
|
||||
// testing for undefined cases
|
||||
var minX = cmds[i].prevX,
|
||||
maxX = cmds[i].prevX,
|
||||
minY = cmds[i].prevY,
|
||||
maxY = cmds[i].prevY;
|
||||
|
||||
while (i < cmds.length) {
|
||||
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined)) {
|
||||
minX = Math.min(minX, cmds[i].prevX);
|
||||
maxX = Math.max(maxX, cmds[i].prevX);
|
||||
if (cmds[i].x !== undefined) {
|
||||
minX = Math.min(minX, cmds[i].x);
|
||||
maxX = Math.max(maxX, cmds[i].x);
|
||||
}
|
||||
minY = Math.min(minY, cmds[i].prevY);
|
||||
maxY = Math.max(maxY, cmds[i].prevY);
|
||||
if (cmds[i].y !== undefined) {
|
||||
minY = Math.min(minY, cmds[i].y);
|
||||
maxY = Math.max(maxY, cmds[i].y);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return {minX: minX, maxX: maxX, minY: minY, maxY: maxY};
|
||||
}
|
||||
|
||||
function trackTransforms(ctx) {
|
||||
var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
var xform = svg.createSVGMatrix();
|
||||
@@ -270,9 +318,6 @@ GCODE.renderer = (function () {
|
||||
if (renderOptions["onDrag"] && renderOptions["onDrag"](pt) === false)
|
||||
return;
|
||||
|
||||
ctx.translate(pt.x - dragStart.x, pt.y - dragStart.y);
|
||||
reRender();
|
||||
|
||||
renderOptions["centerViewport"] = false;
|
||||
renderOptions["zoomInOnModel"] = false;
|
||||
renderOptions["zoomInOnBed"] = false;
|
||||
@@ -283,6 +328,9 @@ GCODE.renderer = (function () {
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
ctx.translate(pt.x - dragStart.x, pt.y - dragStart.y);
|
||||
reRender();
|
||||
|
||||
if (renderOptions["onInternalOptionChange"] !== undefined) {
|
||||
renderOptions["onInternalOptionChange"]({
|
||||
centerViewport: false,
|
||||
@@ -326,9 +374,6 @@ GCODE.renderer = (function () {
|
||||
// return to old position
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
|
||||
// render
|
||||
reRender();
|
||||
|
||||
// disable conflicting options
|
||||
renderOptions["zoomInOnModel"] = false;
|
||||
renderOptions["zoomInOnBed"] = false;
|
||||
@@ -339,6 +384,9 @@ GCODE.renderer = (function () {
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
// render
|
||||
reRender();
|
||||
|
||||
if (renderOptions["onInternalOptionChange"] !== undefined) {
|
||||
renderOptions["onInternalOptionChange"]({
|
||||
zoomInOnModel: false,
|
||||
@@ -836,41 +884,41 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
var applyOffsets = function () {
|
||||
var applyOffsets = function (layerNum) {
|
||||
var canvasCenter;
|
||||
|
||||
// determine bed and model offsets
|
||||
if (ctx) ctx.translate(-offsetModelX, -offsetModelY);
|
||||
if (renderOptions["centerViewport"] || renderOptions["zoomInOnModel"]) {
|
||||
canvasCenter = ctx.transformedPoint(canvas.width / 2, canvas.height / 2);
|
||||
if (modelInfo) {
|
||||
offsetModelX =
|
||||
canvasCenter.x -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2;
|
||||
offsetModelY =
|
||||
canvasCenter.y -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2;
|
||||
layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
offsetModelX = canvasCenter.x - (layerBounds.minX + layerBounds.maxX) / 2;
|
||||
offsetModelY = canvasCenter.y - (layerBounds.minY + layerBounds.maxY) / 2;
|
||||
} else {
|
||||
offsetModelX = 0;
|
||||
offsetModelY = 0;
|
||||
}
|
||||
offsetBedX = 0;
|
||||
offsetBedY = 0;
|
||||
} else if (modelInfo && renderOptions["moveModel"]) {
|
||||
offsetModelX =
|
||||
renderOptions["bed"]["x"] / 2 -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2;
|
||||
offsetModelY =
|
||||
renderOptions["bed"]["y"] / 2 -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2;
|
||||
offsetBedX =
|
||||
-1 *
|
||||
(renderOptions["bed"]["x"] / 2 -
|
||||
(modelInfo.boundingBox.minX + modelInfo.boundingBox.maxX) / 2);
|
||||
offsetBedY =
|
||||
-1 *
|
||||
(renderOptions["bed"]["y"] / 2 -
|
||||
(modelInfo.boundingBox.minY + modelInfo.boundingBox.maxY) / 2);
|
||||
} else if (renderOptions["moveModel"]) {
|
||||
layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
offsetModelX =
|
||||
renderOptions["bed"]["x"] / 2 -
|
||||
(layerBounds.minX + layerBounds.maxX) / 2;
|
||||
offsetModelY =
|
||||
renderOptions["bed"]["y"] / 2 -
|
||||
(layerBounds.minY + layerBounds.maxY) / 2;
|
||||
offsetBedX =
|
||||
-1 *
|
||||
(renderOptions["bed"]["x"] / 2 -
|
||||
(layerBounds.minX + layerBounds.maxX) / 2);
|
||||
offsetBedY =
|
||||
-1 *
|
||||
(renderOptions["bed"]["y"] / 2 -
|
||||
(layerBounds.minY + layerBounds.maxY) / 2);
|
||||
}
|
||||
} else if (
|
||||
renderOptions["bed"]["circular"] ||
|
||||
renderOptions["bed"]["centeredOrigin"]
|
||||
@@ -889,7 +937,7 @@ GCODE.renderer = (function () {
|
||||
if (ctx) ctx.translate(offsetModelX, offsetModelY);
|
||||
};
|
||||
|
||||
var applyZoom = function () {
|
||||
var applyZoom = function (layerNum) {
|
||||
// get middle of canvas
|
||||
var pt = ctx.transformedPoint(canvas.width / 2, canvas.height / 2);
|
||||
|
||||
@@ -904,28 +952,36 @@ GCODE.renderer = (function () {
|
||||
transform = ctx.getTransform();
|
||||
}
|
||||
|
||||
if (modelInfo && renderOptions["zoomInOnModel"]) {
|
||||
// if we need to zoom in on model, scale factor is calculated by longer side of object in relation to that axis of canvas
|
||||
var width = modelInfo.boundingBox.maxX - modelInfo.boundingBox.minX;
|
||||
var length = modelInfo.boundingBox.maxY - modelInfo.boundingBox.minY;
|
||||
if (renderOptions["zoomInOnModel"]) {
|
||||
var layerBounds = getLayerBounds(layerNum);
|
||||
if (layerBounds) {
|
||||
// if we need to zoom in on model, scale factor is calculated by longer side of object in relation to that axis of canvas
|
||||
// limited arbitrarily to 50 x extrusion width, to prevent extreme disorienting zoom
|
||||
var width = Math.max(
|
||||
layerBounds.maxX - layerBounds.minX,
|
||||
renderOptions["extrusionWidth"] * 50
|
||||
);
|
||||
var length = Math.max(
|
||||
layerBounds.maxY - layerBounds.minY,
|
||||
renderOptions["extrusionWidth"] * 50
|
||||
);
|
||||
|
||||
var scaleF =
|
||||
width > length
|
||||
? (canvas.width - 10) / width
|
||||
: (canvas.height - 10) / length;
|
||||
if (transform.a && transform.d) {
|
||||
scaleX =
|
||||
(scaleF / transform.a) * (renderOptions["invertAxes"]["x"] ? -1 : 1);
|
||||
scaleY =
|
||||
(scaleF / transform.d) * (renderOptions["invertAxes"]["y"] ? 1 : -1);
|
||||
ctx.translate(pt.x, pt.y);
|
||||
ctx.scale(scaleX, scaleY);
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
var scaleF =
|
||||
width > length
|
||||
? (canvas.width - 10) / width
|
||||
: (canvas.height - 10) / length;
|
||||
if (transform.a && transform.d) {
|
||||
scaleX =
|
||||
(scaleF / transform.a) *
|
||||
(renderOptions["invertAxes"]["x"] ? -1 : 1);
|
||||
scaleY =
|
||||
(scaleF / transform.d) *
|
||||
(renderOptions["invertAxes"]["y"] ? 1 : -1);
|
||||
ctx.translate(pt.x, pt.y);
|
||||
ctx.scale(scaleX, scaleY);
|
||||
ctx.translate(-pt.x, -pt.y);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// reset scale to 1
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1085,8 +1141,8 @@ GCODE.renderer = (function () {
|
||||
}
|
||||
|
||||
applyInversion();
|
||||
applyOffsets();
|
||||
applyZoom();
|
||||
scaleX = 1;
|
||||
scaleY = 1;
|
||||
|
||||
this.render(layerNum, 0, toProgress);
|
||||
},
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
#settings_plugin_pluginmanager_navbar{position:-webkit-sticky;position:sticky;top:0;padding-bottom:1px;border-bottom:1px solid #ddd;background:white}#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px !important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px;padding-right:10px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty{overflow:hidden;width:100%;height:400px;background-image:url("../img/repo_unavailable.png");text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:bold}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:bold;color:#990000}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#990000}#settings_plugin_pluginmanager_workingdialog_output .call{color:#000099}
|
||||
/*# sourceMappingURL=pluginmanager.css.map */
|
||||
#settings_plugin_pluginmanager_navbar{position:-webkit-sticky;position:sticky;top:0;padding-bottom:1px;border-bottom:1px solid #ddd;background:#fff}#settings_plugin_pluginmanager_pluginlist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_name .prop,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_name .prop{white-space:nowrap}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_pluginlist table td.settings_plugin_plugin_manager_plugins_actions a.disabled,#settings_plugin_pluginmanager_pluginlist table th.settings_plugin_plugin_manager_plugins_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_orphanlist{display:block;width:auto;max-height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px;margin-bottom:1em}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_id,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_id{text-overflow:ellipsis;text-align:left}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions{text-align:center;width:80px}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a{text-decoration:none;color:#000}#settings_plugin_pluginmanager_orphanlist table td.settings_plugin_plugin_manager_orphans_actions a.disabled,#settings_plugin_pluginmanager_orphanlist table th.settings_plugin_plugin_manager_orphans_actions a.disabled{color:#ccc;cursor:default}#settings_plugin_pluginmanager_repositorydialog h4{position:relative}#settings_plugin_pluginmanager_repositorydialog h4 a.dropdown-toggle{color:inherit;text-decoration:none;font-size:14px}#settings_plugin_pluginmanager_repositorydialog h4 ul.dropdown-menu{font-size:14px}#settings_plugin_pluginmanager_repositorydialog .form-search{text-align:center;margin-bottom:5px!important}#settings_plugin_pluginmanager_repositorydialog .form-inline{padding:5px 10px 5px 5px;margin-bottom:0}#settings_plugin_pluginmanager_repositorydialog .form-inline .help-block{margin-bottom:0;font-size:85%}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable{overflow:hidden;width:100%;height:400px;background-image:url(../img/repo_unavailable.png);text-align:center;display:table}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_empty div,#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_unavailable div{display:table-cell;vertical-align:middle}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list{width:auto;height:400px;overflow-x:hidden;overflow-y:scroll;padding-right:2px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry{border-bottom:1px solid #ddd;padding:5px}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .meta{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}#settings_plugin_pluginmanager_repositorydialog #settings_plugin_pluginmanager_repositorydialog_list .entry .stats .prop{white-space:nowrap}#settings_plugin_pluginmanager_workingdialog_output .message{font-weight:700}#settings_plugin_pluginmanager_workingdialog_output .error{font-weight:700;color:#900}#settings_plugin_pluginmanager_workingdialog_output .stdout{color:#333}#settings_plugin_pluginmanager_workingdialog_output .stderr{color:#900}#settings_plugin_pluginmanager_workingdialog_output .call{color:#009}
|
||||
@@ -1,2 +1 @@
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}div.swupdate-advanced{margin-bottom:5px}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:bold}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:bold;color:#666666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#990000}#settings_plugin_softwareupdate_workingdialog_output .call{color:#000099}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:bold;color:#990000}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
/*# sourceMappingURL=softwareupdate.css.map */
|
||||
#settings_plugin_softwareupdate_updatelist{display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em}div.swupdate-advanced{margin-bottom:5px}td.settings_plugin_softwareupdate_column_update{width:16px}td.settings_plugin_softwareupdate_column_update a{text-decoration:none;color:#000}td.settings_plugin_softwareupdate_column_information .line{display:block}td.settings_plugin_softwareupdate_column_information .settings_plugin_softwareupdate_release_channel{line-height:20px;height:20px;font-size:9px;margin-bottom:0;vertical-align:baseline}#settings_plugin_softwareupdate_workingdialog_output{font-size:.8em}#settings_plugin_softwareupdate_workingdialog_output .message{font-weight:700}#settings_plugin_softwareupdate_workingdialog_output .separator{font-weight:700;color:#666}#settings_plugin_softwareupdate_workingdialog_output .stdout{color:#333}#settings_plugin_softwareupdate_workingdialog_output .stderr{color:#900}#settings_plugin_softwareupdate_workingdialog_output .call{color:#009}#settings_plugin_softwareupdate_workingdialog_output .message_error{font-weight:700;color:#900}.softwareupdate_notification ul{margin:10px 0 10px 25px}.softwareupdate_notification ul .name{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;display:block}
|
||||
@@ -718,6 +718,11 @@ class Server:
|
||||
app, util.flask.permission_validator, permissions.Permissions.WEBCAM
|
||||
),
|
||||
] + access_validators_from_plugins
|
||||
systeminfo_validators = [
|
||||
util.tornado.access_validation_factory(
|
||||
app, util.flask.permission_validator, permissions.Permissions.SYSTEM
|
||||
)
|
||||
] + access_validators_from_plugins
|
||||
|
||||
timelapse_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*timelapse_validators)
|
||||
@@ -731,6 +736,9 @@ class Server:
|
||||
camera_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*camera_validators)
|
||||
}
|
||||
systeminfo_permission_validator = {
|
||||
"access_validation": util.tornado.validation_chain(*systeminfo_validators)
|
||||
}
|
||||
|
||||
no_hidden_files_validator = {
|
||||
"path_validation": util.tornado.path_validation_factory(
|
||||
@@ -744,6 +752,22 @@ class Server:
|
||||
status_code=404,
|
||||
)
|
||||
}
|
||||
timelapses_path_validator = {
|
||||
"path_validation": util.tornado.path_validation_factory(
|
||||
lambda path: not octoprint.util.is_hidden_path(path)
|
||||
and octoprint.timelapse.valid_timelapse(path),
|
||||
status_code=400,
|
||||
)
|
||||
}
|
||||
logs_path_validator = {
|
||||
"path_validation": util.tornado.path_validation_factory(
|
||||
lambda path: not octoprint.util.is_hidden_path(path)
|
||||
and os.path.realpath(os.path.abspath(path)).startswith(
|
||||
settings().getBaseFolder("logs")
|
||||
),
|
||||
status_code=400,
|
||||
)
|
||||
}
|
||||
|
||||
def joined_dict(*dicts):
|
||||
if not len(dicts):
|
||||
@@ -770,6 +794,24 @@ class Server:
|
||||
timelapse_path_validator,
|
||||
),
|
||||
),
|
||||
# zipped timelapse bundles
|
||||
(
|
||||
r"/downloads/timelapses",
|
||||
util.tornado.DynamicZipBundleHandler,
|
||||
joined_dict(
|
||||
{
|
||||
"as_attachment": True,
|
||||
"attachment_name": "octoprint-timelapses.zip",
|
||||
"path_processor": lambda x: (
|
||||
x,
|
||||
os.path.join(self._settings.getBaseFolder("timelapse"), x),
|
||||
),
|
||||
},
|
||||
timelapse_permission_validator,
|
||||
timelapses_path_validator,
|
||||
),
|
||||
),
|
||||
# uploaded printables
|
||||
(
|
||||
r"/downloads/files/local/(.*)",
|
||||
util.tornado.LargeResponseHandler,
|
||||
@@ -785,6 +827,7 @@ class Server:
|
||||
additional_mime_types,
|
||||
),
|
||||
),
|
||||
# log files
|
||||
(
|
||||
r"/downloads/logs/([^/]*)",
|
||||
util.tornado.LargeResponseHandler,
|
||||
@@ -798,6 +841,29 @@ class Server:
|
||||
log_permission_validator,
|
||||
),
|
||||
),
|
||||
# zipped log file bundles
|
||||
(
|
||||
r"/downloads/logs",
|
||||
util.tornado.DynamicZipBundleHandler,
|
||||
joined_dict(
|
||||
{
|
||||
"as_attachment": True,
|
||||
"attachment_name": "octoprint-logs.zip",
|
||||
"path_processor": lambda x: (
|
||||
x,
|
||||
os.path.join(self._settings.getBaseFolder("logs"), x),
|
||||
),
|
||||
},
|
||||
log_permission_validator,
|
||||
logs_path_validator,
|
||||
),
|
||||
),
|
||||
# system info bundle
|
||||
(
|
||||
r"/downloads/systeminfo.zip",
|
||||
util.tornado.SystemInfoBundleHandler,
|
||||
systeminfo_permission_validator,
|
||||
),
|
||||
# camera snapshot
|
||||
(
|
||||
r"/downloads/camera/current",
|
||||
|
||||
@@ -1385,6 +1385,211 @@ class DeprecatedEndpointHandler(CorsSupportMixin, tornado.web.RequestHandler):
|
||||
options = _handle_method
|
||||
|
||||
|
||||
class StaticZipBundleHandler(CorsSupportMixin, tornado.web.RequestHandler):
|
||||
def initialize(
|
||||
self, files=None, as_attachment=True, attachment_name=None, access_validation=None
|
||||
):
|
||||
if files is None:
|
||||
files = []
|
||||
if as_attachment and not attachment_name:
|
||||
raise ValueError("attachment name must be set if as_attachment is True")
|
||||
|
||||
self._files = files
|
||||
self._as_attachment = as_attachment
|
||||
self._attachment_name = attachment_name
|
||||
self._access_validator = access_validation
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
return self.stream_zip(self._files)
|
||||
|
||||
def get_attachment_name(self):
|
||||
return self._attachment_name
|
||||
|
||||
# noinspection PyCompatibility
|
||||
def normalize_files(self, files):
|
||||
result = []
|
||||
for f in files:
|
||||
if isinstance(f, str):
|
||||
result.append({"path": f})
|
||||
elif isinstance(f, dict) and ("path" in f or "iter" in f or "content" in f):
|
||||
result.append(f)
|
||||
return result
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def stream_zip(self, files):
|
||||
self.set_header("Content-Type", "application/zip")
|
||||
if self._as_attachment:
|
||||
self.set_header(
|
||||
"Content-Disposition",
|
||||
'attachment; filename="{}"'.format(self.get_attachment_name()),
|
||||
)
|
||||
|
||||
import zipstream
|
||||
|
||||
z = zipstream.ZipFile()
|
||||
for f in self.normalize_files(files):
|
||||
# noinspection PyCompatibility
|
||||
name = f.get("name")
|
||||
path = f.get("path")
|
||||
iter = f.get("iter")
|
||||
content = f.get("content")
|
||||
|
||||
if path:
|
||||
z.write(path, arcname=name, compress_type=zipstream.ZIP_STORED)
|
||||
elif iter and name:
|
||||
z.write_iter(name, iter, compress_type=zipstream.ZIP_STORED)
|
||||
elif content and name:
|
||||
z.writestr(name, content, compress_type=zipstream.ZIP_STORED)
|
||||
|
||||
for chunk in z:
|
||||
try:
|
||||
self.write(chunk)
|
||||
yield self.flush()
|
||||
except tornado.iostream.StreamClosedError:
|
||||
return
|
||||
|
||||
|
||||
class DynamicZipBundleHandler(StaticZipBundleHandler):
|
||||
# noinspection PyMethodOverriding
|
||||
def initialize(
|
||||
self,
|
||||
path_validation=None,
|
||||
path_processor=None,
|
||||
as_attachment=True,
|
||||
attachment_name=None,
|
||||
access_validation=None,
|
||||
):
|
||||
if as_attachment and not attachment_name:
|
||||
raise ValueError("attachment name must be set if as_attachment is True")
|
||||
|
||||
self._path_validator = path_validation
|
||||
self._path_processor = path_processor
|
||||
self._as_attachment = as_attachment
|
||||
self._attachment_name = attachment_name
|
||||
self._access_validator = access_validation
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
|
||||
files = list(
|
||||
map(octoprint.util.to_unicode, self.request.query_arguments.get("files", []))
|
||||
)
|
||||
return self._get_files_zip(files)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
|
||||
import json
|
||||
|
||||
content_type = self.request.headers.get("Content-Type", "")
|
||||
try:
|
||||
if "application/json" in content_type:
|
||||
data = json.loads(self.request.body)
|
||||
else:
|
||||
data = self.request.body_arguments
|
||||
except Exception:
|
||||
raise tornado.web.HTTPError(400)
|
||||
|
||||
return self._get_files_zip(
|
||||
list(map(octoprint.util.to_unicode, data.get("files", [])))
|
||||
)
|
||||
|
||||
def _get_files_zip(self, files):
|
||||
files = self.normalize_files(files)
|
||||
if not files:
|
||||
raise tornado.web.HTTPError(400)
|
||||
|
||||
for f in files:
|
||||
if "path" in f:
|
||||
if callable(self._path_processor):
|
||||
path = self._path_processor(f["path"])
|
||||
if isinstance(path, tuple):
|
||||
f["name"], f["path"] = path
|
||||
else:
|
||||
f["path"] = path
|
||||
self._path_validator(f["path"])
|
||||
|
||||
return self.stream_zip(files)
|
||||
|
||||
|
||||
class SystemInfoBundleHandler(StaticZipBundleHandler):
|
||||
# noinspection PyMethodOverriding
|
||||
def initialize(self, access_validation=None):
|
||||
self._as_attachment = True
|
||||
self._attachment_name = "octoprint-systeminfo-{datetime}.zip"
|
||||
self._access_validator = access_validation
|
||||
|
||||
def get(self, *args, **kwargs):
|
||||
if self._access_validator is not None:
|
||||
self._access_validator(self.request)
|
||||
|
||||
from octoprint.cli.systeminfo import get_systeminfo
|
||||
from octoprint.server import (
|
||||
connectivityChecker,
|
||||
environmentDetector,
|
||||
printer,
|
||||
safe_mode,
|
||||
)
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import dict_flatten
|
||||
|
||||
systeminfo = get_systeminfo(environmentDetector, connectivityChecker)
|
||||
systeminfo["browser.user_agent"] = self.request.headers.get("User-Agent")
|
||||
systeminfo["octoprint.safe_mode"] = safe_mode is not None
|
||||
|
||||
terminaltxt = None
|
||||
if printer and printer.is_operational():
|
||||
firmware_info = printer.firmware_info
|
||||
if firmware_info:
|
||||
systeminfo.update(
|
||||
dict_flatten({"firmware": firmware_info["name"]}, prefix="printer")
|
||||
)
|
||||
|
||||
if hasattr(printer, "_log"):
|
||||
terminaltxt = list(printer._log)
|
||||
|
||||
logbase = settings().getBaseFolder("logs")
|
||||
|
||||
systeminfotxt = []
|
||||
for k in sorted(systeminfo.keys()):
|
||||
systeminfotxt.append("{}: {}".format(k, systeminfo[k]))
|
||||
|
||||
files = [
|
||||
{
|
||||
"name": "systeminfo.txt",
|
||||
"content": octoprint.util.to_bytes("\n".join(systeminfotxt)),
|
||||
},
|
||||
{"path": os.path.join(logbase, "octoprint.log"), "name": "octoprint.log"},
|
||||
{"path": os.path.join(logbase, "serial.log"), "name": "serial.log"},
|
||||
{
|
||||
"path": os.path.join(logbase, "plugin_softwareupdate_console.log"),
|
||||
"name": "plugin_softwareupdate_console.log",
|
||||
},
|
||||
{
|
||||
"path": os.path.join(logbase, "plugin_pluginmanager_console.log"),
|
||||
"name": "plugin_pluginmanager_console.log",
|
||||
},
|
||||
]
|
||||
if terminaltxt is not None:
|
||||
files.append(
|
||||
{
|
||||
"name": "terminal.txt",
|
||||
"content": octoprint.util.to_bytes("\n".join(terminaltxt)),
|
||||
}
|
||||
)
|
||||
|
||||
return self.stream_zip(files)
|
||||
|
||||
def get_attachment_name(self):
|
||||
import time
|
||||
|
||||
return "octoprint-systeminfo-{}.zip".format(time.strftime("%Y%m%d%H%M%S"))
|
||||
|
||||
|
||||
class GlobalHeaderTransform(tornado.web.OutputTransform):
|
||||
|
||||
HEADERS = {}
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top, #fff, #e6e6e6);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fff), to(#e6e6e6));background-image:-webkit-linear-gradient(top, #fff, #e6e6e6);background-image:-o-linear-gradient(top, #fff, #e6e6e6);background-image:linear-gradient(to bottom, #fff, #e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top, #08c, #04c);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#04c));background-image:-webkit-linear-gradient(top, #08c, #04c);background-image:-o-linear-gradient(top, #08c, #04c);background-image:linear-gradient(to bottom, #08c, #04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;background-image:-moz-linear-gradient(top, #fbb450, #f89406);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));background-image:-webkit-linear-gradient(top, #fbb450, #f89406);background-image:-o-linear-gradient(top, #fbb450, #f89406);background-image:linear-gradient(to bottom, #fbb450, #f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btnLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn.active,.btn:active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:focus,.btn:hover{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class*=" icon-"],.btn-large [class^=icon-]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class*=" icon-"],.btn-small [class^=icon-]{margin-top:0}.btn-mini [class*=" icon-"],.btn-mini [class^=icon-]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary.active,.btn-primary:active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -216,6 +216,16 @@
|
||||
return this.get(url, params);
|
||||
};
|
||||
|
||||
OctoPrintClient.prototype.bulkDownloadUrl = function (url, files) {
|
||||
return (
|
||||
url +
|
||||
"?" +
|
||||
_.map(files, function (f) {
|
||||
return "files=" + encodeURIComponent(f);
|
||||
}).join("&")
|
||||
);
|
||||
};
|
||||
|
||||
OctoPrintClient.prototype.upload = function (url, file, filename, additional) {
|
||||
additional = additional || {};
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
var url = "api/timelapse";
|
||||
|
||||
var downloadUrl = "downloads/timelapse";
|
||||
var bulkDownloadUrl = "downloads/timelapses";
|
||||
|
||||
var timelapseUrl = function (filename) {
|
||||
return url + "/" + filename;
|
||||
@@ -86,6 +87,10 @@
|
||||
return this.base.download(timelapseDownloadUrl(filename), opts);
|
||||
};
|
||||
|
||||
OctoPrintTimelapseClient.prototype.bulkDownloadUrl = function (filenames) {
|
||||
return this.base.bulkDownloadUrl(bulkDownloadUrl, filenames);
|
||||
};
|
||||
|
||||
OctoPrintTimelapseClient.prototype.delete = function (filename, opts) {
|
||||
return this.base.delete(timelapseUrl(filename), opts);
|
||||
};
|
||||
|
||||
@@ -377,6 +377,31 @@ $(function () {
|
||||
);
|
||||
};
|
||||
|
||||
self.enableBulkDownload = ko.pureComputed(function () {
|
||||
return (
|
||||
self.markedForFileDeletion().length &&
|
||||
!self.isBusy() &&
|
||||
!self.bulkDownloadUrlTooLong()
|
||||
);
|
||||
});
|
||||
|
||||
self.bulkDownloadUrlTooLong = ko.pureComputed(function () {
|
||||
return BASEURL.length + self.bulkDownloadUrl().length >= 2000;
|
||||
});
|
||||
|
||||
self.bulkDownloadButtonUrl = ko.pureComputed(function () {
|
||||
var files = self.markedForFileDeletion();
|
||||
if (!files.length || self.bulkDownloadUrlTooLong()) {
|
||||
return "javascript:void(0)";
|
||||
}
|
||||
return self.bulkDownloadUrl();
|
||||
});
|
||||
|
||||
self.bulkDownloadUrl = function () {
|
||||
var files = self.markedForFileDeletion();
|
||||
return OctoPrint.timelapse.bulkDownloadUrl(files);
|
||||
};
|
||||
|
||||
self.markUnrenderedOnPage = function () {
|
||||
self.markedForUnrenderedDeletion(
|
||||
_.uniq(
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
/*! modernizr 3.6.0 (Custom Build) | MIT *
|
||||
* https://modernizr.com/download/?-canvas-localstorage-svg-touchevents-webgl-setclasses !*/
|
||||
!function(e,t,n){function o(e,t){return typeof e===t}function a(){var e,t,n,a,s,r,i;for(var l in f)if(f.hasOwnProperty(l)){if(e=[],t=f[l],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(a=o(t.fn,"function")?t.fn():t.fn,s=0;s<e.length;s++)r=e[s],i=r.split("."),1===i.length?Modernizr[i[0]]=a:(!Modernizr[i[0]]||Modernizr[i[0]]instanceof Boolean||(Modernizr[i[0]]=new Boolean(Modernizr[i[0]])),Modernizr[i[0]][i[1]]=a),c.push((a?"":"no-")+i.join("-"))}}function s(e){var t=u.className,n=Modernizr._config.classPrefix||"";if(p&&(t=t.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(o,"$1"+n+"js$2")}Modernizr._config.enableClasses&&(t+=" "+n+e.join(" "+n),p?u.className.baseVal=t:u.className=t)}function r(){return"function"!=typeof t.createElement?t.createElement(arguments[0]):p?t.createElementNS.call(t,"http://www.w3.org/2000/svg",arguments[0]):t.createElement.apply(t,arguments)}function i(){var e=t.body;return e||(e=r(p?"svg":"body"),e.fake=!0),e}function l(e,n,o,a){var s,l,c,f,d="modernizr",p=r("div"),v=i();if(parseInt(o,10))for(;o--;)c=r("div"),c.id=a?a[o]:d+(o+1),p.appendChild(c);return s=r("style"),s.type="text/css",s.id="s"+d,(v.fake?v:p).appendChild(s),v.appendChild(p),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(t.createTextNode(e)),p.id=d,v.fake&&(v.style.background="",v.style.overflow="hidden",f=u.style.overflow,u.style.overflow="hidden",u.appendChild(v)),l=n(p,e),v.fake?(v.parentNode.removeChild(v),u.style.overflow=f,u.offsetHeight):p.parentNode.removeChild(p),!!l}var c=[],f=[],d={_version:"3.6.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){f.push({name:e,fn:t,options:n})},addAsyncTest:function(e){f.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=d,Modernizr=new Modernizr,Modernizr.addTest("svg",!!t.createElementNS&&!!t.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),Modernizr.addTest("localstorage",function(){var e="modernizr";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}});var u=t.documentElement,p="svg"===u.nodeName.toLowerCase();Modernizr.addTest("canvas",function(){var e=r("canvas");return!(!e.getContext||!e.getContext("2d"))}),Modernizr.addTest("webgl",function(){var t=r("canvas"),n="probablySupportsContext"in t?"probablySupportsContext":"supportsContext";return n in t?t[n]("webgl")||t[n]("experimental-webgl"):"WebGLRenderingContext"in e});var v=d._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];d._prefixes=v;var m=d.testStyles=l;Modernizr.addTest("touchevents",function(){var n;if("ontouchstart"in e||e.DocumentTouch&&t instanceof DocumentTouch)n=!0;else{var o=["@media (",v.join("touch-enabled),("),"heartz",")","{#modernizr{top:9px;position:absolute}}"].join("");m(o,function(e){n=9===e.offsetTop})}return n}),a(),s(c),delete d.addTest,delete d.addAsyncTest;for(var g=0;g<Modernizr._q.length;g++)Modernizr._q[g]();e.Modernizr=Modernizr}(window,document);
|
||||
/*! modernizr 3.11.0 (Custom Build) | MIT *
|
||||
* https://modernizr.com/download/?-canvas-fetch-localstorage-svg-touchevents-webgl-setclasses !*/
|
||||
!function(e,t,n,o){function a(e,t){return typeof e===t}function r(){return"function"!=typeof n.createElement?n.createElement(arguments[0]):p?n.createElementNS.call(n,"http://www.w3.org/2000/svg",arguments[0]):n.createElement.apply(n,arguments)}function s(){var e=n.body;return e||(e=r(p?"svg":"body"),e.fake=!0),e}function i(e,t,o,a){var i,l,c,u,d="modernizr",p=r("div"),v=s();if(parseInt(o,10))for(;o--;)c=r("div"),c.id=a?a[o]:d+(o+1),p.appendChild(c);return i=r("style"),i.type="text/css",i.id="s"+d,(v.fake?v:p).appendChild(i),v.appendChild(p),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(n.createTextNode(e)),p.id=d,v.fake&&(v.style.background="",v.style.overflow="hidden",u=f.style.overflow,f.style.overflow="hidden",f.appendChild(v)),l=t(p,e),v.fake?(v.parentNode.removeChild(v),f.style.overflow=u,f.offsetHeight):p.parentNode.removeChild(p),!!l}function l(e,n,o){var a;if("getComputedStyle"in t){a=getComputedStyle.call(t,e,n);var r=t.console;if(null!==a)o&&(a=a.getPropertyValue(o));else if(r){var s=r.error?"error":"log";r[s].call(r,"getComputedStyle returning null, its possible modernizr test results are inaccurate")}}else a=!n&&e.currentStyle&&e.currentStyle[o];return a}var c=[],u={_version:"3.11.0",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,t){var n=this;setTimeout(function(){t(n[e])},0)},addTest:function(e,t,n){c.push({name:e,fn:t,options:n})},addAsyncTest:function(e){c.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=u,Modernizr=new Modernizr;var d=[],f=n.documentElement,p="svg"===f.nodeName.toLowerCase();Modernizr.addTest("canvas",function(){var e=r("canvas");return!(!e.getContext||!e.getContext("2d"))}),Modernizr.addTest("localstorage",function(){var e="modernizr";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return!1}}),Modernizr.addTest("svg",!!n.createElementNS&&!!n.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),Modernizr.addTest("webgl",function(){return"WebGLRenderingContext"in t}),Modernizr.addTest("fetch","fetch"in t);var v=u._config.usePrefixes?" -webkit- -moz- -o- -ms- ".split(" "):["",""];u._prefixes=v;var h=function(){var e=t.matchMedia||t.msMatchMedia;return e?function(t){var n=e(t);return n&&n.matches||!1}:function(e){var t=!1;return i("@media "+e+" { #modernizr { position: absolute; } }",function(e){t="absolute"===l(e,null,"position")}),t}}();u.mq=h,Modernizr.addTest("touchevents",function(){if("ontouchstart"in t||t.TouchEvent||t.DocumentTouch&&n instanceof DocumentTouch)return!0;var e=["(",v.join("touch-enabled),("),"heartz",")"].join("");return h(e)}),function(){var e,t,n,o,r,s,i;for(var l in c)if(c.hasOwnProperty(l)){if(e=[],t=c[l],t.name&&(e.push(t.name.toLowerCase()),t.options&&t.options.aliases&&t.options.aliases.length))for(n=0;n<t.options.aliases.length;n++)e.push(t.options.aliases[n].toLowerCase());for(o=a(t.fn,"function")?t.fn():t.fn,r=0;r<e.length;r++)s=e[r],i=s.split("."),1===i.length?Modernizr[i[0]]=o:(Modernizr[i[0]]&&(!Modernizr[i[0]]||Modernizr[i[0]]instanceof Boolean)||(Modernizr[i[0]]=new Boolean(Modernizr[i[0]])),Modernizr[i[0]][i[1]]=o),d.push((o?"":"no-")+i.join("-"))}}(),function(e){var t=f.className,n=Modernizr._config.classPrefix||"";if(p&&(t=t.baseVal),Modernizr._config.enableJSClass){var o=new RegExp("(^|\\s)"+n+"no-js(\\s|$)");t=t.replace(o,"$1"+n+"js$2")}Modernizr._config.enableClasses&&(e.length>0&&(t+=" "+n+e.join(" "+n)),p?f.className.baseVal=t:f.className=t)}(d),delete u.addTest,delete u.addAsyncTest;for(var m=0;m<Modernizr._q.length;m++)Modernizr._q[m]();e.Modernizr=Modernizr}(window,window,document);
|
||||
@@ -7,4 +7,7 @@
|
||||
<strong data-bind="text: key"></strong>: <span data-bind="text: value"></span><br />
|
||||
</p>
|
||||
|
||||
<a href="javascript:void(0)" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
|
||||
<a href="{{ url_for('index', _external=True) }}downloads/systeminfo.zip" class="btn btn-primary"><i class="fas fa-download"></i> {{ _('Download Systeminfo Bundle') }}</a>
|
||||
|
||||
<a href="javascript:void(0)" class="btn" data-bind="click: copySystemInfo"><i class="far fa-copy"></i> {{ _('Copy') }}</a>
|
||||
@@ -133,6 +133,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
<button class="btn btn-small" data-bind="click: removeMarkedFiles, enable: markedForFileDeletion().length > 0">{{ _('Delete selected') }}</button>
|
||||
<a class="btn btn-small" data-bind="css: { disabled: !enableBulkDownload() }, attr: { href: bulkDownloadButtonUrl }">{{_('Download selected')}}</a>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed table-hover" id="timelapse_files">
|
||||
<thead>
|
||||
@@ -163,6 +164,7 @@
|
||||
<li data-bind="css: {disabled: listHelper.currentPage() === listHelper.lastPage()}"><a href="javascript:void(0)" data-bind="click: listHelper.nextPage">»</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<small data-bind="visible: bulkDownloadUrlTooLong"><i class="fa fa-warning"></i> {{ _('Too many files selected to download at once. Reduce number of files to enable download button.') }}</small>
|
||||
|
||||
|
||||
<div data-bind="visible: unrenderedListHelper.allSize">
|
||||
|
||||
@@ -9,6 +9,7 @@ import io
|
||||
import logging
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import zlib
|
||||
|
||||
|
||||
@@ -178,6 +179,12 @@ class AnalysisAborted(Exception):
|
||||
Exception.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
regex_command = re.compile(
|
||||
r"^\s*((?P<codeGM>[GM]\d+)(\.(?P<subcode>\d+))?|(?P<codeT>T)(?P<tool>\d+))"
|
||||
)
|
||||
"""Regex for a GCODE command."""
|
||||
|
||||
|
||||
class gcode:
|
||||
def __init__(self, progress_callback=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
@@ -337,173 +344,180 @@ class gcode:
|
||||
self._filamentDiameter = 0.0
|
||||
line = line[0 : line.find(";")]
|
||||
|
||||
G = getCodeInt(line, "G")
|
||||
M = getCodeInt(line, "M")
|
||||
T = getCodeInt(line, "T")
|
||||
match = regex_command.search(line)
|
||||
gcode = tool = None
|
||||
if match:
|
||||
values = match.groupdict()
|
||||
if "codeGM" in values and values["codeGM"]:
|
||||
gcode = values["codeGM"]
|
||||
elif "codeT" in values and values["codeT"]:
|
||||
gcode = values["codeT"]
|
||||
tool = int(values["tool"])
|
||||
|
||||
if G is not None:
|
||||
if G == 0 or G == 1: # Move
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
e = getCodeFloat(line, "E")
|
||||
f = getCodeFloat(line, "F")
|
||||
# G codes
|
||||
if gcode in ("G0", "G1"): # Move
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
e = getCodeFloat(line, "E")
|
||||
f = getCodeFloat(line, "F")
|
||||
|
||||
if x is not None or y is not None or z is not None:
|
||||
# this is a move
|
||||
move = True
|
||||
if x is not None or y is not None or z is not None:
|
||||
# this is a move
|
||||
move = True
|
||||
else:
|
||||
# print head stays on position
|
||||
move = False
|
||||
|
||||
oldPos = pos
|
||||
|
||||
# Use new coordinates if provided. If not provided, use prior coordinates (minus tool offset)
|
||||
# in absolute and 0.0 in relative mode.
|
||||
newPos = Vector3D(
|
||||
x * scale if x is not None else (0.0 if relativeMode else pos.x),
|
||||
y * scale if y is not None else (0.0 if relativeMode else pos.y),
|
||||
z * scale if z is not None else (0.0 if relativeMode else pos.z),
|
||||
)
|
||||
|
||||
if relativeMode:
|
||||
# Relative mode: add to current position
|
||||
pos += newPos
|
||||
else:
|
||||
# Absolute mode: apply tool offsets
|
||||
pos = newPos
|
||||
|
||||
if f is not None and f != 0:
|
||||
feedrate = f
|
||||
|
||||
if e is not None:
|
||||
if relativeMode or relativeE:
|
||||
# e is already relative, nothing to do
|
||||
pass
|
||||
else:
|
||||
# print head stays on position
|
||||
move = False
|
||||
e -= currentE[currentExtruder]
|
||||
|
||||
oldPos = pos
|
||||
# If move with extrusion, calculate new min/max coordinates of model
|
||||
if e > 0 and move:
|
||||
# extrusion and move -> oldPos & pos relevant for print area & dimensions
|
||||
self._minMax.record(oldPos)
|
||||
self._minMax.record(pos)
|
||||
|
||||
# Use new coordinates if provided. If not provided, use prior coordinates (minus tool offset)
|
||||
# in absolute and 0.0 in relative mode.
|
||||
newPos = Vector3D(
|
||||
x if x is not None else (0.0 if relativeMode else pos.x),
|
||||
y if y is not None else (0.0 if relativeMode else pos.y),
|
||||
z if z is not None else (0.0 if relativeMode else pos.z),
|
||||
totalExtrusion[currentExtruder] += e
|
||||
currentE[currentExtruder] += e
|
||||
maxExtrusion[currentExtruder] = max(
|
||||
maxExtrusion[currentExtruder], totalExtrusion[currentExtruder]
|
||||
)
|
||||
|
||||
if relativeMode:
|
||||
# Relative mode: scale and add to current position
|
||||
pos += newPos * scale
|
||||
else:
|
||||
# Absolute mode: scale coordinates and apply tool offsets
|
||||
pos = newPos * scale
|
||||
if currentExtruder == 0 and len(currentE) > 1 and duplicationMode:
|
||||
# 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])
|
||||
else:
|
||||
e = 0
|
||||
|
||||
if f is not None and f != 0:
|
||||
feedrate = f
|
||||
# move time in x, y, z, will be 0 if no movement happened
|
||||
moveTimeXYZ = abs((oldPos - pos).length / feedrate)
|
||||
|
||||
if e is not None:
|
||||
if relativeMode or relativeE:
|
||||
# e is already relative, nothing to do
|
||||
pass
|
||||
else:
|
||||
e -= currentE[currentExtruder]
|
||||
# time needed for extruding, will be 0 if no extrusion happened
|
||||
extrudeTime = abs(e / feedrate)
|
||||
|
||||
# If move with extrusion, calculate new min/max coordinates of model
|
||||
if e > 0.0 and move:
|
||||
# extrusion and move -> oldPos & pos relevant for print area & dimensions
|
||||
self._minMax.record(oldPos)
|
||||
self._minMax.record(pos)
|
||||
# time to add is maximum of both
|
||||
totalMoveTimeMinute += max(moveTimeXYZ, extrudeTime)
|
||||
|
||||
totalExtrusion[currentExtruder] += e
|
||||
currentE[currentExtruder] += e
|
||||
maxExtrusion[currentExtruder] = max(
|
||||
maxExtrusion[currentExtruder], totalExtrusion[currentExtruder]
|
||||
)
|
||||
|
||||
if currentExtruder == 0 and len(currentE) > 1 and duplicationMode:
|
||||
# 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])
|
||||
else:
|
||||
e = 0.0
|
||||
|
||||
# move time in x, y, z, will be 0 if no movement happened
|
||||
moveTimeXYZ = abs((oldPos - pos).length / feedrate)
|
||||
|
||||
# time needed for extruding, will be 0 if no extrusion happened
|
||||
extrudeTime = abs(e / feedrate)
|
||||
|
||||
# time to add is maximum of both
|
||||
totalMoveTimeMinute += max(moveTimeXYZ, extrudeTime)
|
||||
|
||||
elif G == 4: # Delay
|
||||
S = getCodeFloat(line, "S")
|
||||
if S is not None:
|
||||
totalMoveTimeMinute += S / 60
|
||||
P = getCodeFloat(line, "P")
|
||||
if P is not None:
|
||||
totalMoveTimeMinute += P / 60 / 1000
|
||||
elif G == 10: # Firmware retract
|
||||
totalMoveTimeMinute += fwretractTime
|
||||
elif G == 11: # Firmware retract recover
|
||||
totalMoveTimeMinute += fwrecoverTime
|
||||
elif G == 20: # Units are inches
|
||||
scale = 25.4
|
||||
elif G == 21: # Units are mm
|
||||
scale = 1
|
||||
elif G == 28: # Home
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
center = Vector3D(0.0, 0.0, 0.0)
|
||||
if x is None and y is None and z is None:
|
||||
pos = center
|
||||
else:
|
||||
pos = Vector3D(pos)
|
||||
if x is not None:
|
||||
pos.x = center.x
|
||||
if y is not None:
|
||||
pos.y = center.y
|
||||
if z is not None:
|
||||
pos.z = center.z
|
||||
elif G == 90: # Absolute position
|
||||
relativeMode = False
|
||||
if g90_extruder:
|
||||
relativeE = False
|
||||
elif G == 91: # Relative position
|
||||
relativeMode = True
|
||||
if g90_extruder:
|
||||
relativeE = True
|
||||
elif G == 92:
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
e = getCodeFloat(line, "E")
|
||||
|
||||
if e is None and x is None and y is None and z is None:
|
||||
# no parameters, set all axis to 0
|
||||
currentE[currentExtruder] = 0.0
|
||||
pos.x = 0.0
|
||||
pos.y = 0.0
|
||||
pos.z = 0.0
|
||||
else:
|
||||
# some parameters set, only set provided axes
|
||||
if e is not None:
|
||||
currentE[currentExtruder] = e
|
||||
if x is not None:
|
||||
pos.x = x
|
||||
if y is not None:
|
||||
pos.y = y
|
||||
if z is not None:
|
||||
pos.z = z
|
||||
|
||||
elif M is not None:
|
||||
if M == 82: # Absolute E
|
||||
elif gcode == "G4": # Delay
|
||||
S = getCodeFloat(line, "S")
|
||||
if S is not None:
|
||||
totalMoveTimeMinute += S / 60
|
||||
P = getCodeFloat(line, "P")
|
||||
if P is not None:
|
||||
totalMoveTimeMinute += P / 60 / 1000
|
||||
elif gcode == "G10": # Firmware retract
|
||||
totalMoveTimeMinute += fwretractTime
|
||||
elif gcode == "G11": # Firmware retract recover
|
||||
totalMoveTimeMinute += fwrecoverTime
|
||||
elif gcode == "G20": # Units are inches
|
||||
scale = 25.4
|
||||
elif gcode == "G21": # Units are mm
|
||||
scale = 1
|
||||
elif gcode == "G28": # Home
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
center = Vector3D(0.0, 0.0, 0.0)
|
||||
if x is None and y is None and z is None:
|
||||
pos = center
|
||||
else:
|
||||
pos = Vector3D(pos)
|
||||
if x is not None:
|
||||
pos.x = center.x
|
||||
if y is not None:
|
||||
pos.y = center.y
|
||||
if z is not None:
|
||||
pos.z = center.z
|
||||
elif gcode == "G90": # Absolute position
|
||||
relativeMode = False
|
||||
if g90_extruder:
|
||||
relativeE = False
|
||||
elif M == 83: # Relative E
|
||||
elif gcode == "G91": # Relative position
|
||||
relativeMode = True
|
||||
if g90_extruder:
|
||||
relativeE = True
|
||||
elif M == 207 or M == 208: # Firmware retract settings
|
||||
s = getCodeFloat(line, "S")
|
||||
f = getCodeFloat(line, "F")
|
||||
if s is not None and f is not None:
|
||||
if M == 207:
|
||||
fwretractTime = s / f
|
||||
fwretractDist = s
|
||||
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
|
||||
# from first extruder to all other extruders
|
||||
duplicationMode = True
|
||||
else:
|
||||
duplicationMode = False
|
||||
elif gcode == "G92":
|
||||
x = getCodeFloat(line, "X")
|
||||
y = getCodeFloat(line, "Y")
|
||||
z = getCodeFloat(line, "Z")
|
||||
e = getCodeFloat(line, "E")
|
||||
|
||||
elif T is not None:
|
||||
if T > max_extruders:
|
||||
if e is None and x is None and y is None and z is None:
|
||||
# no parameters, set all axis to 0
|
||||
currentE[currentExtruder] = 0.0
|
||||
pos.x = 0.0
|
||||
pos.y = 0.0
|
||||
pos.z = 0.0
|
||||
else:
|
||||
# some parameters set, only set provided axes
|
||||
if e is not None:
|
||||
currentE[currentExtruder] = e
|
||||
if x is not None:
|
||||
pos.x = x
|
||||
if y is not None:
|
||||
pos.y = y
|
||||
if z is not None:
|
||||
pos.z = z
|
||||
|
||||
# M codes
|
||||
elif gcode == "M82": # Absolute E
|
||||
relativeE = False
|
||||
elif gcode == "M83": # Relative E
|
||||
relativeE = True
|
||||
elif gcode in ("M207", "M208"): # Firmware retract settings
|
||||
s = getCodeFloat(line, "S")
|
||||
f = getCodeFloat(line, "F")
|
||||
if s is not None and f is not None:
|
||||
if gcode == "M207":
|
||||
fwretractTime = s / f
|
||||
fwretractDist = s
|
||||
else:
|
||||
fwrecoverTime = (fwretractDist + s) / f
|
||||
elif gcode == "M605": # Duplication/Mirroring mode
|
||||
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
|
||||
|
||||
# T codes
|
||||
elif tool is not None:
|
||||
if tool > max_extruders:
|
||||
self._logger.warning(
|
||||
"GCODE tried to select tool %d, that looks wrong, ignoring for GCODE analysis"
|
||||
% T
|
||||
% tool
|
||||
)
|
||||
elif T == currentExtruder:
|
||||
elif tool == currentExtruder:
|
||||
pass
|
||||
else:
|
||||
pos.x -= (
|
||||
@@ -517,7 +531,7 @@ class gcode:
|
||||
else 0
|
||||
)
|
||||
|
||||
currentExtruder = T
|
||||
currentExtruder = tool
|
||||
|
||||
pos.x += (
|
||||
offsets[currentExtruder][0]
|
||||
|
||||
Reference in new issue
Block a user