Merge branch 'devel' into dev/commRefactoringNG

This commit is contained in:
Gina Häußge committed 2021-04-19 18:01:30 +02:00
commit d197fabffc
72 files changed
+4014 -3784

No files matched your search

+3 -5
View File
@@ -1,7 +1,6 @@
name: 🐛 Report a bug
about: Create a bug report to help improve OctoPrint
description: Create a bug report to help improve OctoPrint
title: ""
issue_body: true
body:
- type: markdown
attributes:
@@ -130,7 +129,6 @@ body:
- label: Contents of the JavaScript browser console (always include in cases of issues with the user interface)
- label: Screenshots and/or videos showing the problem (always include in case of issues with the user interface)
- label: GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour)
- type: markdown
- type: textarea
attributes:
value: |
## Additional information & file uploads
label: Additional information & file uploads
+4 -7
View File
@@ -1,7 +1,6 @@
name: ✨ Request a feature
about: Request a new feature to implement in OctoPrint
description: Request a new feature to implement in OctoPrint
title: "[Request]"
issue_body: true
body:
- type: markdown
attributes:
@@ -29,9 +28,7 @@ body:
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: markdown
- type: textarea
attributes:
value: >
**Additional context**
Add any other context or screenshots about the feature request here.
label: Additional context
description: Add any other context or screenshots about the feature request here.
+1 -1
View File
@@ -3,7 +3,7 @@ on:
push:
pull_request:
release:
types: [released, prereleased]
types: [published]
workflow_dispatch:
jobs:
+7 -7
View File
@@ -18,21 +18,21 @@ prerelease
HEAD
\(detached.*
# maintenance is currently the branch for preparation of maintenance release 1.6.0
# maintenance is currently the branch for preparation of maintenance release 1.7.0
# so are any fix/... and improve/... branches
maintenance 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
fix/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
improve/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev
maintenance 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev
fix/.* 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev
improve/.* 1.7.0 07c4630d126617c2ae98a9c23ad49facf7bf0bbd pep440-dev
# staging/bugfix is the branch for preparation of the 1.5.3 hotfix release
# so are any bug/... branches
staging/bugfix 1.5.3 e46e8fa17a1553cd0c228a4fa4cfd93e2a9bce7b pep440-dev
bug/.* 1.5.3 e46e8fa17a1553cd0c228a4fa4cfd93e2a9bce7b pep440-dev
# staging/maintenance is currently the branch for preparation of 1.5.0rc4
# staging/maintenance is currently the branch for preparation of 1.6.0rc3
# so is regressionfix/...
staging/maintenance 1.5.0rc4 5e7ea35239908f9ed91895751d8a8202aa76ed4b pep440-dev
regressionfix/.* 1.5.0rc4 5e7ea35239908f9ed91895751d8a8202aa76ed4b pep440-dev
staging/maintenance 1.6.0rc3 c2844c8132871f40f8dec3a0cdff8e7cfd25bab9 pep440-dev
regressionfix/.* 1.6.0rc3 c2844c8132871f40f8dec3a0cdff8e7cfd25bab9 pep440-dev
# staging/devel is currently inactive (but has the 1.4.1rc4 namespace)
staging/devel 1.4.1rc4 650d54d1885409fa1d411eb54b9e8c7ff428910f pep440-dev
+14 -7
View File
@@ -6,10 +6,11 @@ thanks to everyone who contributed!
## Patrons & Sponsors
* 3D-TECH
* 3DPrinterOS
* Andrew Moorby
* Arnljot Arntsen
* Ash King
* Ashley Merrick
* BigTreeTech
* Boris Hussein
* Brad Jackson
@@ -17,11 +18,15 @@ thanks to everyone who contributed!
* BuildBee
* Christian Petropolis
* Christian Wolf
* Christoph Sigrist
* Creality3D
* D Brian Kimmel
* Dana Voigt
* DeltaMaker 3D Printers
* Dennis Breining
* Dennis Christilaw
* Diana C Rodriguez
* Douglas Floyd
* Eric Betts
* Ernesto Martinez
* Franziska Kunsmann
@@ -29,11 +34,9 @@ thanks to everyone who contributed!
* Greg Holloway
* Hog Duske
* Hopewell Medical Acupuncture Center
* jean-claude migneault
* Jefferson Hunt
* Jeremy Cole
* Joe Pasqua
* Joshua Wills
* Julian Melo
* Justin Kaufman
* Kaile Riser
* Kale Stedman
@@ -44,14 +47,15 @@ thanks to everyone who contributed!
* Kyle Menigoz
* LA 3D Printer Repair
* Lee Dohm
* Loyal Moses
* Makespace Madrid
* Mark Walker
* Michael Aumock
* Michael Begala
* Miles Flavel
* Mosaic Manufacturing
* Nat Friedman
* Neil R. Goldberg
* Norman Jaffe
* Ory Weaver
* Patrick Glyré
* Pete Barnwell
* Prof Yuh Wen Chen
@@ -69,6 +73,9 @@ thanks to everyone who contributed!
* Stefan Krister
* Steve Thompson
* Sven Mueller
* TH3D
* The Spaghetti Detective
* Ulderico Cirello
* Ulrich Kempken
and 2225 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [Github Sponsors](https://github.com/users/foosel/sponsorship)!
and 2309 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)!
+1
View File
@@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mermaid=e():t.mermaid=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=383)}([function(t,e,n){"use strict";n.r(e);var r=function(t,e){return t<e?-1:t>e?1:t>=e?0:NaN},i=function(t){var e;return 1===t.length&&(e=t,t=function(t,n){return r(e(t),n)}),{left:function(e,n,r,i){for(null==r&&(r=0),null==i&&(i=e.length);r<i;){var a=r+i>>>1;t(e[a],n)<0?r=a+1:i=a}return r},right:function(e,n,r,i){for(null==r&&(r=0),null==i&&(i=e.length);r<i;){var a=r+i>>>1;t(e[a],n)>0?i=a:r=a+1}return r}}};var a=i(r),o=a.right,s=a.left,c=o,u=function(t,e){null==e&&(e=l);for(var n=0,r=t.length-1,i=t[0],a=new Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return a};function l(t,e){return[t,e]}var h=function(t,e,n){var r,i,a,o,s=t.length,c=e.length,u=new Array(s*c);for(null==n&&(n=l),r=a=0;r<s;++r)for(o=t[r],i=0;i<c;++i,++a)u[a]=n(o,e[i]);return u},f=function(t,e){return e<t?-1:e>t?1:e>=t?0:NaN},d=function(t){return null===t?NaN:+t},p=function(t,e){var n,r,i=t.length,a=0,o=-1,s=0,c=0;if(null==e)for(;++o<i;)isNaN(n=d(t[o]))||(c+=(r=n-s)*(n-(s+=r/++a)));else for(;++o<i;)isNaN(n=d(e(t[o],o,t)))||(c+=(r=n-s)*(n-(s+=r/++a)));if(a>1)return c/(a-1)},y=function(t,e){var n=p(t,e);return n?Math.sqrt(n):n},g=function(t,e){var n,r,i,a=t.length,o=-1;if(null==e){for(;++o<a;)if(null!=(n=t[o])&&n>=n)for(r=i=n;++o<a;)null!=(n=t[o])&&(r>n&&(r=n),i<n&&(i=n))}else for(;++o<a;)if(null!=(n=e(t[o],o,t))&&n>=n)for(r=i=n;++o<a;)null!=(n=e(t[o],o,t))&&(r>n&&(r=n),i<n&&(i=n));return[r,i]},v=Array.prototype,m=v.slice,b=v.map,x=function(t){return function(){return t}},_=function(t){return t},k=function(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),a=new Array(i);++r<i;)a[r]=t+r*n;return a},w=Math.sqrt(50),E=Math.sqrt(10),T=Math.sqrt(2),C=function(t,e,n){var r,i,a,o,s=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];if((r=e<t)&&(i=t,t=e,e=i),0===(o=S(t,e,n))||!isFinite(o))return[];if(o>0)for(t=Math.ceil(t/o),e=Math.floor(e/o),a=new Array(i=Math.ceil(e-t+1));++s<i;)a[s]=(t+s)*o;else for(t=Math.floor(t*o),e=Math.ceil(e*o),a=new Array(i=Math.ceil(t-e+1));++s<i;)a[s]=(t-s)/o;return r&&a.reverse(),a};function S(t,e,n){var r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),a=r/Math.pow(10,i);return i>=0?(a>=w?10:a>=E?5:a>=T?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=w?10:a>=E?5:a>=T?2:1)}function A(t,e,n){var r=Math.abs(e-t)/Math.max(0,n),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),a=r/i;return a>=w?i*=10:a>=E?i*=5:a>=T&&(i*=2),e<t?-i:i}var M=function(t){return Math.ceil(Math.log(t.length)/Math.LN2)+1},O=function(){var t=_,e=g,n=M;function r(r){var i,a,o=r.length,s=new Array(o);for(i=0;i<o;++i)s[i]=t(r[i],i,r);var u=e(s),l=u[0],h=u[1],f=n(s,l,h);Array.isArray(f)||(f=A(l,h,f),f=k(Math.ceil(l/f)*f,h,f));for(var d=f.length;f[0]<=l;)f.shift(),--d;for(;f[d-1]>h;)f.pop(),--d;var p,y=new Array(d+1);for(i=0;i<=d;++i)(p=y[i]=[]).x0=i>0?f[i-1]:l,p.x1=i<d?f[i]:h;for(i=0;i<o;++i)l<=(a=s[i])&&a<=h&&y[c(f,a,0,d)].push(r[i]);return y}return r.value=function(e){return arguments.length?(t="function"==typeof e?e:x(e),r):t},r.domain=function(t){return arguments.length?(e="function"==typeof t?t:x([t[0],t[1]]),r):e},r.thresholds=function(t){return arguments.length?(n="function"==typeof t?t:Array.isArray(t)?x(m.call(t)):x(t),r):n},r},D=function(t,e,n){if(null==n&&(n=d),r=t.length){if((e=+e)<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t);return o+(+n(t[a+1],a+1,t)-o)*(i-a)}},N=function(t,e,n){return t=b.call(t,d).sort(r),Math.ceil((n-e)/(2*(D(t,.75)-D(t,.25))*Math.pow(t.length,-1/3)))},B=function(t,e,n){return Math.ceil((n-e)/(3.5*y(t)*Math.pow(t.length,-1/3)))},L=function(t,e){var n,r,i=t.length,a=-1;if(null==e){for(;++a<i;)if(null!=(n=t[a])&&n>=n)for(r=n;++a<i;)null!=(n=t[a])&&n>r&&(r=n)}else for(;++a<i;)if(null!=(n=e(t[a],a,t))&&n>=n)for(r=n;++a<i;)null!=(n=e(t[a],a,t))&&n>r&&(r=n);return r},P=function(t,e)Line truncated
+3
View File
@@ -112,6 +112,8 @@ pygments_style = "sphinx"
numfig = True
mermaid_version = ""
# -- Options for HTML output ---------------------------------------------------
import sphinx_rtd_theme
@@ -155,6 +157,7 @@ html_static_path = ["_static"]
def setup(app):
app.add_css_file("theme_overrides.css")
app.add_js_file("mermaid.min.js")
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+20
View File
@@ -1253,6 +1253,26 @@ octoprint.printer.factory
:return: The ``printer`` instance to use globally.
:rtype: PrinterInterface subclass or None
.. _sec-plugins-hook-printer-handle_connect:
octoprint.printer.handle_connect
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. py:function:: handle_connect(*args, **kwargs):
.. versionadded:: 1.6.0
Allows plugins to perform actions upon connecting to a printer. By returning ``True``,
plugins may also prevent further processing of the connect command. This hook is of
special interest if your plugin needs a connect from going through under certain
circumstances or if you need to do something before a connection to the printer is
established (e.g. switching on power to the printer).
:param kwargs: All connection parameters supplied to the ``connect`` call. Currently
this also includes ``port``, ``baudrate`` and ``profile``.
:return: ``True`` if OctoPrint should not proceed with the connect
:rtype: boolean or None
.. _sec-plugins-hook-printer-estimation-factory:
octoprint.printer.estimation.factory
+2 -1
View File
@@ -22,8 +22,9 @@ SETUP_REQUIRES = [
# Requirements for our application
INSTALL_REQUIRES = [
# additional OctoPrint plugins that are maintained on a different release cycle
"OctoPrint-FileCheck>=2021.2.23",
"OctoPrint-FirmwareCheck>=2021.2.4",
"OctoPrint-FileCheck>=2020.08.07",
"OctoPrint-PiSupport>=2021.3.26",
# the following dependencies are non trivial to update since later versions
# introduce backwards incompatible changes that might affect plugins, or due to
# other observed problems
+12 -6
View File
@@ -722,7 +722,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
import yaml
from octoprint.util import bom_aware_open
from octoprint.util.version import is_octoprint_compatible
from octoprint.util.version import is_octoprint_compatible, is_python_compatible
logger = log.getLogger(__name__ + ".startup")
@@ -753,13 +753,19 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
):
continue
if "version" in entry:
if "pythonversions" in entry and not is_python_compatible(
*entry["pythonversions"]
):
continue
if "pluginversions" in entry:
logger.debug(
"Blacklisted plugin: {}, version: {}".format(
entry["plugin"], entry["version"]
"Blacklisted plugin: {}, versions: {}".format(
entry["plugin"], ", ".join(entry["pluginversions"])
)
)
result.append((entry["plugin"], entry["version"]))
for version in entry["pluginversions"]:
result.append((entry["plugin"], version))
elif "versions" in entry:
logger.debug(
"Blacklisted plugin: {}, versions: {}".format(
@@ -767,7 +773,7 @@ def get_plugin_blacklist(settings, connectivity_checker=None):
)
)
for version in entry["versions"]:
result.append((entry["plugin"], version))
result.append((entry["plugin"], f"=={version}"))
else:
logger.debug("Blacklisted plugin: {}".format(entry["plugin"]))
result.append(entry["plugin"])
+16 -4
View File
@@ -10,10 +10,16 @@ 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")
dimensions = ("depth", "height", "width")
printing_area = ("maxX", "maxY", "maxZ", "minX", "minY", "minZ")
def empty_result(result):
dims = result.get("dimensions", {})
return all(map(lambda x: dims.get(x) == 0.0, dimensions))
def validate_result(result):
def validate_list(data):
return not any(map(invalid_float, data))
@@ -68,6 +74,7 @@ def util():
@click.option("--g90-extruder", "g90_extruder", is_flag=True)
@click.option("--bed-z", "bedz", type=float, default=0)
@click.option("--progress", "progress", is_flag=True)
@click.option("--layers", "layers", is_flag=True)
@click.argument("path", type=click.Path())
def gcode_command(
path,
@@ -81,6 +88,7 @@ def gcode_command(
g90_extruder,
bedz,
progress,
layers,
):
"""Runs a GCODE file analysis."""
@@ -115,7 +123,7 @@ def gcode_command(
def progress_callback(percentage):
click.echo(f"PROGRESS:{percentage}")
interpreter = gcode(progress_callback=progress_callback)
interpreter = gcode(progress_callback=progress_callback, incl_layers=layers)
interpreter.load(
path,
@@ -131,6 +139,10 @@ def gcode_command(
click.echo("DONE:{}s".format(time.monotonic() - start_time))
result = interpreter.get_result()
if empty_result(result):
click.echo("EMPTY:There are no extrusions in the file, nothing to analyse")
sys.exit(0)
if not validate_result(result):
click.echo(
"ERROR:Invalid analysis result, please create a bug report in OctoPrint's "
+2
View File
@@ -1042,6 +1042,8 @@ class FileManager:
def _add_analysis_result(self, destination, path, result):
if destination not in self._storage_managers:
return
if not result:
return
storage_manager = self._storage_managers[destination]
storage_manager.set_additional_metadata(path, "analysis", result, overwrite=True)
+17 -15
View File
@@ -470,27 +470,29 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
output = p.stdout.text
self._logger.debug(f"Got output: {output!r}")
result = {}
if "ERROR:" in output:
_, error = output.split("ERROR:")
raise RuntimeError(error.strip())
elif "EMPTY:" in output:
self._logger.info("Result is empty, no extrusions found")
elif "RESULTS:" not in output:
raise RuntimeError("No analysis result found")
else:
_, output = output.split("RESULTS:")
analysis = yaml.safe_load(output)
_, output = output.split("RESULTS:")
analysis = yaml.safe_load(output)
result = {}
result["printingArea"] = analysis["printing_area"]
result["dimensions"] = analysis["dimensions"]
if analysis["total_time"]:
result["estimatedPrintTime"] = analysis["total_time"] * 60
if analysis["extrusion_length"]:
result["filament"] = {}
for i in range(len(analysis["extrusion_length"])):
result["filament"]["tool%d" % i] = {
"length": analysis["extrusion_length"][i],
"volume": analysis["extrusion_volume"][i],
}
result["printingArea"] = analysis["printing_area"]
result["dimensions"] = analysis["dimensions"]
if analysis["total_time"]:
result["estimatedPrintTime"] = analysis["total_time"] * 60
if analysis["extrusion_length"]:
result["filament"] = {}
for i in range(len(analysis["extrusion_length"])):
result["filament"]["tool%d" % i] = {
"length": analysis["extrusion_length"][i],
"volume": analysis["extrusion_volume"][i],
}
if self._current.analysis and isinstance(self._current.analysis, dict):
return dict_merge(result, self._current.analysis)
+3 -2
View File
@@ -64,7 +64,8 @@ def plugin_manager(
this defaults to the entry point ``octoprint.plugin``.
plugin_disabled_list (list): A list of plugin identifiers that are currently disabled. If not provided this
defaults to all plugins for which ``enabled`` is set to ``False`` in the settings.
plugin_blacklist (list): A list of plugin identifiers/identifier-version tuples that are currently blacklisted.
plugin_blacklist (list): A list of plugin identifiers/identifier-requirement tuples
that are currently blacklisted.
plugin_restart_needing_hooks (list): A list of hook namespaces which cause a plugin to need a restart in order
be enabled/disabled. Does not have to contain full hook identifiers, will be matched with startswith similar
to logging handlers
@@ -107,7 +108,7 @@ def plugin_manager(
plugin_obsolete_hooks = ["octoprint.comm.protocol.gcode"]
if plugin_considered_bundled is None:
plugin_considered_bundled = ["firmware_check", "file_check"]
plugin_considered_bundled = ["firmware_check", "file_check", "pi_support"]
if plugin_validators is None:
plugin_validators = [_validate_plugin]
+18 -2
View File
@@ -816,11 +816,27 @@ class PluginManager:
if plugin_considered_bundled is None:
plugin_considered_bundled = []
processed_blacklist = []
for entry in plugin_blacklist:
if isinstance(entry, tuple):
key, version = entry
try:
processed_blacklist.append(
(key, pkg_resources.Requirement.parse(version))
)
except Exception:
self.logger.warning(
"Invalid version requirement {} for blacklist "
"entry {}, ignoring".format(version, key)
)
else:
processed_blacklist.append(entry)
self.plugin_folders = plugin_folders
self.plugin_bases = plugin_bases
self.plugin_entry_points = plugin_entry_points
self.plugin_disabled_list = plugin_disabled_list
self.plugin_blacklist = plugin_blacklist
self.plugin_blacklist = processed_blacklist
self.plugin_restart_needing_hooks = plugin_restart_needing_hooks
self.plugin_obsolete_hooks = plugin_obsolete_hooks
self.plugin_validators = plugin_validators
@@ -1289,7 +1305,7 @@ class PluginManager:
def matches_plugin(entry):
if isinstance(entry, (tuple, list)) and len(entry) == 2:
entry_key, entry_version = entry
return entry_key == key and entry_version == version
return entry_key == key and version in entry_version
return False
return any(map(lambda entry: matches_plugin(entry), self.plugin_blacklist))
+1 -1
View File
@@ -670,7 +670,7 @@ class UiPlugin(OctoPrintPlugin, SortablePlugin):
object.
Returns:
bool: ``True`` if the the implementation will serve the request,
bool: ``True`` if the implementation will serve the request,
``False`` otherwise.
"""
return False
@@ -1,4 +1,4 @@
<legend>{{ _('Registered application keys') }}</legend>
<h3>{{ _('Registered application keys') }}</h3>
<div data-bind="visible: keys.allSize() <= 0">
<p>{{ _('There are no application keys registered yet.') }}</p>
@@ -59,7 +59,7 @@
</ul>
</div>
</div>
<legend>{{ _('Manually generate an application key') }}</legend>
<h3>{{ _('Manually generate an application key') }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
@@ -18,10 +18,10 @@ from octoprint.util.version import (
)
SENTRY_URL_SERVER = (
"https://c11d13d9e92046bca4691ad1658dc543@o118517.ingest.sentry.io/1373987"
"https://650d1f41ffc14ded800d7862f887af20@o118517.ingest.sentry.io/1373987"
)
SENTRY_URL_COREUI = (
"https://a987a79a328e405a9545b8a036b420ee@o118517.ingest.sentry.io/1374096"
"https://775a5d0614c34a47b9fd1c92e16771af@o118517.ingest.sentry.io/1374096"
)
SETTINGS_DEFAULTS = {
@@ -59,7 +59,9 @@ $(function () {
self.renderer_showMoves = ko.observable(true);
self.renderer_showRetracts = ko.observable(true);
self.renderer_showPrinthead = ko.observable(true);
self.renderer_showSegmentStarts = ko.observable(false);
self.renderer_showBoundingBox = ko.observable(false);
self.renderer_showLayerBoundingBox = ko.observable(false);
self.renderer_showFullSize = ko.observable(false);
self.renderer_extrusionWidthEnabled = ko.observable(false);
self.renderer_extrusionWidth = ko.observable(2);
@@ -94,7 +96,9 @@ $(function () {
showMoves: self.renderer_showMoves(),
showRetracts: self.renderer_showRetracts(),
showHead: self.renderer_showPrinthead(),
showSegmentStarts: self.renderer_showSegmentStarts(),
showBoundingBox: self.renderer_showBoundingBox(),
showLayerBoundingBox: self.renderer_showLayerBoundingBox(),
showFullSize: self.renderer_showFullSize(),
extrusionWidth: self.renderer_extrusionWidthEnabled()
? self.renderer_extrusionWidth()
@@ -141,7 +145,9 @@ $(function () {
self.renderer_showMoves.subscribe(self.rendererOptionUpdated);
self.renderer_showRetracts.subscribe(self.rendererOptionUpdated);
self.renderer_showPrinthead.subscribe(self.rendererOptionUpdated);
self.renderer_showSegmentStarts.subscribe(self.rendererOptionUpdated);
self.renderer_showBoundingBox.subscribe(self.rendererOptionUpdated);
self.renderer_showLayerBoundingBox.subscribe(self.rendererOptionUpdated);
self.renderer_showFullSize.subscribe(self.rendererOptionUpdated);
self.renderer_extrusionWidthEnabled.subscribe(self.rendererOptionUpdated);
self.renderer_extrusionWidth.subscribe(self.rendererOptionUpdated);
@@ -394,7 +400,9 @@ $(function () {
self.renderer_showMoves(true);
self.renderer_showRetracts(true);
self.renderer_showPrinthead(true);
self.renderer_showSegmentStarts(false);
self.renderer_showBoundingBox(false);
self.renderer_showLayerBoundingBox(false);
self.renderer_showFullSize(false);
self.renderer_extrusionWidthEnabled(false);
self.renderer_extrusionWidth(2);
@@ -881,11 +889,13 @@ $(function () {
showMoves: self.renderer_showMoves(),
showRetracts: self.renderer_showRetracts(),
showPrinthead: self.renderer_showPrinthead(),
showSegmentStarts: self.renderer_showSegmentStarts(),
showPrevious: self.renderer_showPrevious(),
showCurrent: self.renderer_showCurrent(),
showNext: self.renderer_showNext(),
showFullsize: self.renderer_showFullSize(),
showBoundingBox: self.renderer_showBoundingBox(),
showLayerBoundingBox: self.renderer_showLayerBoundingBox(),
hideEmptyLayers: self.reader_hideEmptyLayers(),
sortLayers: self.reader_sortLayers()
});
@@ -904,6 +914,8 @@ $(function () {
self.renderer_showRetracts(current["showRetracts"]);
if (current["showPrinthead"] !== undefined)
self.renderer_showPrinthead(current["showPrinthead"]);
if (current["showSegmentStarts"] !== undefined)
self.renderer_showSegmentStarts(current["showSegmentStarts"]);
if (current["showPrevious"] !== undefined)
self.renderer_showPrevious(current["showPrevious"]);
if (current["showCurrent"] !== undefined)
@@ -914,6 +926,8 @@ $(function () {
self.renderer_showFullSize(current["showFullsize"]);
if (current["showBoundingBox"] !== undefined)
self.renderer_showBoundingBox(current["showBoundingBox"]);
if (current["showLayerBoundingBox"] !== undefined)
self.renderer_showLayerBoundingBox(current["showLayerBoundingBox"]);
if (current["hideEmptyLayers"] !== undefined)
self.reader_hideEmptyLayers(current["hideEmptyLayers"]);
if (current["sortLayers"] !== undefined)
@@ -37,6 +37,7 @@ GCODE.renderer = (function () {
colorRetract: "#ff0000",
colorRestart: "#0000ff",
colorHead: "#00ff00",
colorSegmentStart: "#666666",
showMoves: true,
showRetracts: true,
@@ -50,8 +51,11 @@ GCODE.renderer = (function () {
showCurrentLayer: false,
showPreviousLayer: false,
showBoundingBox: false,
showLayerBoundingBox: false,
showFullSize: false,
showHead: false,
showSegmentStarts: false,
sizeSegmentStart: 2 * pixelRatio,
moveModel: true,
zoomInOnModel: false,
@@ -113,7 +117,7 @@ GCODE.renderer = (function () {
ctx.clearRect(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y);
drawGrid();
drawBoundingBox();
drawBoundingBox(layerNumStore);
if (model && model.length) {
if (layerNumStore < model.length) {
if (renderOptions["showNextLayer"] && layerNumStore < model.length - 1) {
@@ -151,28 +155,31 @@ GCODE.renderer = (function () {
if (!model || !model[layer]) return;
var cmds = model[layer];
var i = 0;
var firstExtrusion;
var i;
// find bounds based on x/y moves with extrusion only
// if you want to change that criterion, this is the place to do it
var factorIn = function (cmd) {
return cmd && cmd.extrude && (cmd.x !== undefined || cmd.y !== undefined);
};
while (i < cmds.length) {
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined))
break;
i++;
for (i = 0; i < cmds.length; i++) {
if (factorIn(cmds[i])) break;
}
if (i == cmds.length) return;
if (i === cmds.length) return;
firstExtrusion = i;
// 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;
var minX = cmds[firstExtrusion].prevX,
maxX = cmds[firstExtrusion].prevX,
minY = cmds[firstExtrusion].prevY,
maxY = cmds[firstExtrusion].prevY;
while (i < cmds.length) {
if (cmds[i].extrude && (cmds[i].x !== undefined || cmds[i].y !== undefined)) {
for (i = firstExtrusion; i < cmds.length; i++) {
if (factorIn(cmds[i])) {
minX = Math.min(minX, cmds[i].prevX);
maxX = Math.max(maxX, cmds[i].prevX);
if (cmds[i].x !== undefined) {
@@ -186,7 +193,6 @@ GCODE.renderer = (function () {
maxY = Math.max(maxY, cmds[i].y);
}
}
i++;
}
return {minX: minX, maxX: maxX, minY: minY, maxY: maxY};
@@ -548,24 +554,27 @@ GCODE.renderer = (function () {
ctx.stroke();
};
var drawBoundingBox = function () {
var drawBoundingBox = function (layerNum) {
if (!modelInfo) return;
var minX, minY, width, height;
var draw = function (x, y, w, h, c) {
ctx.beginPath();
ctx.strokeStyle = c;
ctx.setLineDash([2, 5]);
ctx.rect(x, y, w, h);
ctx.stroke();
};
if (renderOptions["showFullSize"]) {
minX = modelInfo.min.x;
minY = modelInfo.min.y;
width = modelInfo.modelSize.x;
height = modelInfo.modelSize.y;
ctx.beginPath();
ctx.strokeStyle = "#0000ff";
ctx.setLineDash([2, 5]);
ctx.rect(minX, minY, width, height);
ctx.stroke();
draw(minX, minY, width, height, "#0000ff");
}
if (renderOptions["showBoundingBox"]) {
@@ -573,14 +582,18 @@ GCODE.renderer = (function () {
minY = modelInfo.boundingBox.minY;
width = modelInfo.boundingBox.maxX - minX;
height = modelInfo.boundingBox.maxY - minY;
draw(minX, minY, width, height, "#ff0000");
}
ctx.beginPath();
ctx.strokeStyle = "#ff0000";
ctx.setLineDash([2, 5]);
ctx.rect(minX, minY, width, height);
ctx.stroke();
if (renderOptions["showLayerBoundingBox"]) {
var layerBounds = getLayerBounds(layerNum);
if (layerBounds) {
minX = layerBounds.minX;
minY = layerBounds.minY;
width = layerBounds.maxX - minX;
height = layerBounds.maxY - minY;
draw(minX, minY, width, height, "#00ff00");
}
}
ctx.setLineDash([1, 0]);
@@ -633,6 +646,23 @@ GCODE.renderer = (function () {
ctx.lineJoin = origLineJoin;
};
var drawCross = function (centerX, centerY, size) {
var x1, y1, x2, y2;
var half = size / 2;
x1 = centerX - half;
x2 = centerX + half;
y1 = centerY - half;
y2 = centerY + half;
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.moveTo(x1, y2);
ctx.lineTo(x2, y1);
ctx.stroke();
};
var drawLayer = function (layerNum, fromProgress, toProgress, isNotCurrentLayer) {
log.trace(
"Drawing layer " +
@@ -692,6 +722,7 @@ GCODE.renderer = (function () {
//~~ render this layer's commands
var sizeRetractSpot = renderOptions["sizeRetractSpot"] * lineWidthFactor * 2;
var sizeSegmentStart = renderOptions["sizeSegmentStart"] * lineWidthFactor * 2;
// alpha value (100% if current layer is being rendered, 30% otherwise)
// Note - If showing currently layer as preview - also render it at 30% and draw the progress over the top at 100%
@@ -707,6 +738,7 @@ GCODE.renderer = (function () {
var colorMove = {};
var colorRetract = {};
var colorRestart = {};
var colorSegmentStart = {};
function getColorLineForTool(tool) {
var rv = colorLine[tool];
@@ -762,6 +794,19 @@ GCODE.renderer = (function () {
return rv;
}
function getColorSegmentStartForTool(tool) {
var rv = colorSegmentStart[tool];
if (rv === undefined) {
var shade = tool * 0.15;
rv = colorSegmentStart[tool] = pusher
.color(renderOptions["colorSegmentStart"])
.shade(shade)
.alpha(alpha)
.html();
}
return rv;
}
var prevPathType = "fill";
function strokePathIfNeeded(newPathType, strokeStyle) {
if (newPathType != prevPathType || newPathType == "fill") {
@@ -858,6 +903,12 @@ GCODE.renderer = (function () {
drawTriangle(prevX, prevY, sizeRetractSpot, false);
}
}
if (renderOptions["showSegmentStarts"] && !isNotCurrentLayer) {
strokePathIfNeeded("fill");
ctx.strokeStyle = getColorSegmentStartForTool(tool);
drawCross(x, y, sizeSegmentStart);
}
}
// set new (prevX, prevY)
@@ -886,6 +937,7 @@ GCODE.renderer = (function () {
var applyOffsets = function (layerNum) {
var canvasCenter;
var layerBounds;
// determine bed and model offsets
if (ctx) ctx.translate(-offsetModelX, -offsetModelY);
@@ -1,3 +1,4 @@
<h3>{{ _("GCode Viewer") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" title="{{ _('Maximum size for which the GCode Viewer autoloads the file for preview')|edq }}">
<label class="control-label" for="settings-gcodeviewer-featureSizeThreshold">{{ _('GCode Viewer file size threshold') }}</label>
@@ -86,6 +86,12 @@
<label class="checkbox">
<input type="checkbox" data-bind="checked: renderer_showBoundingBox">{{ _('Show printed bounding box') }}
</label>
<label class="checkbox">
<input type="checkbox" data-bind="checked: renderer_showLayerBoundingBox">{{ _('Show layer bounding box') }}
</label>
<label class="checkbox">
<input type="checkbox" data-bind="checked: renderer_showSegmentStarts">{{ _('Show segment starts') }}
</label>
</p>
<p>
<label class="checkbox">
@@ -1,459 +0,0 @@
__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 os
import flask
import sarge
from flask_babel import gettext
import octoprint.events
import octoprint.plugin
from octoprint.access.groups import USER_GROUP
from octoprint.access.permissions import Permissions
from octoprint.util import RepeatedTimer
from octoprint.util.platform import CLOSE_FDS
_PROC_DT_MODEL_PATH = "/proc/device-tree/model"
_OCTOPI_VERSION_PATH = "/etc/octopi_version"
_VCGENCMD_THROTTLE = "/usr/bin/vcgencmd get_throttled"
_CHECK_INTERVAL_OK = 300
_CHECK_INTERVAL_THROTTLED = 30
__LOCAL_DEBUG = os.path.exists(
os.path.realpath(os.path.join(os.path.dirname(__file__), ".local_debug"))
)
if __LOCAL_DEBUG:
### mocks & settings for local debugging
import sys
base = os.path.realpath(
os.path.join(
os.path.dirname(__file__),
"..",
"..",
"..",
"..",
"tests",
"plugins",
"pi_support",
"fakes",
)
)
_PROC_DT_MODEL_PATH = os.path.join(base, "fake_model.txt")
_OCTOPI_VERSION_PATH = os.path.join(base, "fake_octopi.txt")
_VCGENCMD_THROTTLE = "{} {}".format(
sys.executable, os.path.join(base, "fake_vcgencmd.py")
)
import itertools
_VCGENCMD_OUTPUT = itertools.chain(
iter(("0x0", "0x0", "0x50005", "0x50000", "0x70007")), itertools.repeat("0x70005")
)
_CHECK_INTERVAL_OK = 10
_CHECK_INTERVAL_THROTTLED = 5
# see https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=147781&start=50#p972790
_FLAG_UNDERVOLTAGE = 1 << 0
_FLAG_FREQ_CAPPED = 1 << 1
_FLAG_THROTTLED = 1 << 2
_FLAG_PAST_UNDERVOLTAGE = 1 << 16
_FLAG_PAST_FREQ_CAPPED = 1 << 17
_FLAG_PAST_THROTTLED = 1 << 18
class ThrottleState:
@classmethod
def from_value(cls, value=0):
if value == 0:
return ThrottleState(raw_value=value)
kwargs = {
"undervoltage": _FLAG_UNDERVOLTAGE & value == _FLAG_UNDERVOLTAGE,
"freq_capped": _FLAG_FREQ_CAPPED & value == _FLAG_FREQ_CAPPED,
"throttled": _FLAG_THROTTLED & value == _FLAG_THROTTLED,
"past_undervoltage": _FLAG_PAST_UNDERVOLTAGE & value
== _FLAG_PAST_UNDERVOLTAGE,
"past_freq_capped": _FLAG_PAST_FREQ_CAPPED & value == _FLAG_PAST_FREQ_CAPPED,
"past_throttled": _FLAG_PAST_THROTTLED & value == _FLAG_PAST_THROTTLED,
"raw_value": value,
}
return ThrottleState(**kwargs)
def __init__(self, **kwargs):
self._raw_value = kwargs.get("raw_value", -1)
self._undervoltage = False
self._freq_capped = False
self._throttled = False
self._past_undervoltage = False
self._past_freq_capped = False
self._past_throttled = False
for key, value in kwargs.items():
local_key = f"_{key}"
if hasattr(self, local_key) and isinstance(value, bool):
setattr(self, local_key, value)
@property
def undervoltage(self):
return self.current_undervoltage or self.past_undervoltage
@property
def current_undervoltage(self):
return self._undervoltage
@property
def past_undervoltage(self):
return self._past_undervoltage
@property
def overheat(self):
return self.current_overheat or self.past_overheat
@property
def current_overheat(self):
return self._freq_capped
@property
def past_overheat(self):
return self._past_freq_capped
@property
def issue(self):
return self.current_issue or self.past_issue
@property
def current_issue(self):
return self._undervoltage or self._freq_capped or self._throttled
@property
def past_issue(self):
return self._past_undervoltage or self._past_freq_capped or self._past_throttled
@property
def raw_value(self):
return self._raw_value
@property
def raw_value_hex(self):
return f"0x{self._raw_value:X}"
def __eq__(self, other):
if not isinstance(other, ThrottleState):
return False
return (
self._undervoltage == other._undervoltage
and self._freq_capped == other._freq_capped
and self._throttled == other._throttled
and self._past_undervoltage == other._past_undervoltage
and self._past_freq_capped == other._past_freq_capped
and self._past_throttled == other._past_throttled
and self._raw_value == other._raw_value
)
def as_dict(self):
return {
"raw_value": self._raw_value,
"current_undervoltage": self.current_undervoltage,
"past_undervoltage": self.past_undervoltage,
"current_overheat": self.current_overheat,
"past_overheat": self.past_overheat,
"current_issue": self.current_issue,
"past_issue": self.past_issue,
}
_proc_dt_model = None
def get_proc_dt_model():
global _proc_dt_model
if _proc_dt_model is None:
with open(_PROC_DT_MODEL_PATH, encoding="utf-8") as f:
_proc_dt_model = f.readline().strip(" \t\r\n\0")
return _proc_dt_model
def get_vcgencmd_throttled_state(command):
if __LOCAL_DEBUG:
output = "throttled={}".format(next(_VCGENCMD_OUTPUT)) # mock for local debugging
else:
output = sarge.get_stdout(command, close_fds=CLOSE_FDS)
if "throttled=0x" not in output:
raise ValueError(f'cannot parse "{command}" output: {output}')
value = output[len("throttled=") :].strip(" \t\r\n\0")
value = int(value, 0)
return ThrottleState.from_value(value)
def is_octopi():
return os.path.exists(_OCTOPI_VERSION_PATH)
_octopi_version = None
def get_octopi_version():
global _octopi_version
if _octopi_version is None:
with open(_OCTOPI_VERSION_PATH, encoding="utf-8") as f:
_octopi_version = f.readline().strip(" \t\r\n\0")
return _octopi_version
class PiSupportPlugin(
octoprint.plugin.EnvironmentDetectionPlugin,
octoprint.plugin.SimpleApiPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.StartupPlugin,
octoprint.plugin.SettingsPlugin,
):
# noinspection PyMissingConstructor
def __init__(self):
self._throttle_state = ThrottleState()
self._throttle_check = None
self._throttle_undervoltage = False
self._throttle_overheat = False
self._throttle_functional = True
# Additional permissions hook
def get_additional_permissions(self):
return [
{
"key": "STATUS",
"name": "Status",
"description": gettext(
"Allows to check for the Pi's throttling status and environment info"
),
"roles": ["check"],
"default_groups": [USER_GROUP],
}
]
# ~~ EnvironmentDetectionPlugin
def get_additional_environment(self):
result = {"model": get_proc_dt_model()}
self._check_throttled_state()
if self._throttle_functional:
result["throttle_state"] = self._throttle_state.raw_value_hex
if is_octopi():
result["octopi_version"] = get_octopi_version()
return result
# ~~ SimpleApiPlugin
def on_api_get(self, request):
if not Permissions.PLUGIN_PI_SUPPORT_STATUS.can():
return flask.abort(403)
environment = self.get_additional_environment()
result = {
"throttle_state": self._throttle_state.as_dict(),
"model_unrecommended": "zero" in environment.get("model").lower(),
}
result.update(environment)
return flask.jsonify(**result)
# ~~ AssetPlugin
def get_assets(self):
return {
"js": ["js/pi_support.js"],
"clientjs": ["clientjs/pi_support.js"],
"css": ["css/pi_support.css"],
}
# ~~ TemplatePlugin
def get_template_configs(self):
configs = [
{
"type": "settings",
"name": gettext("Pi Support"),
"template": "pi_support_settings.jinja2",
"custom_bindings": False,
}
]
if is_octopi():
configs.append(
{
"type": "about",
"name": "About OctoPi",
"template": "pi_support_about_octopi.jinja2",
}
)
return configs
def get_template_vars(self):
return self.get_additional_environment()
# ~~ StartupPlugin
def on_startup(self, *args, **kwargs):
if self._settings.get_boolean(["vcgencmd_throttle_check_enabled"]):
self._check_throttled_state()
self._throttle_check = RepeatedTimer(
self._check_throttled_state_interval,
self._check_throttled_state,
condition=self._check_throttled_state_condition,
)
self._throttle_check.start()
# ~~ SettingsPlugin
def get_settings_defaults(self):
return {
"vcgencmd_throttle_check_enabled": True,
"vcgencmd_throttle_check_command": _VCGENCMD_THROTTLE,
"ignore_unrecommended_model": False,
}
def get_settings_restricted_paths(self):
return {
"admin": [
["vcgencmd_throttle_check_enabled"],
["vcgencmd_throttle_check_command"],
]
}
# ~~ Helpers
def _check_throttled_state_interval(self):
if self._throttle_state.current_issue:
return _CHECK_INTERVAL_THROTTLED
else:
return _CHECK_INTERVAL_OK
def _check_throttled_state_condition(self):
return self._throttle_functional
def get_throttle_state(self, run_now=False):
"""Exposed as public helper."""
if run_now:
self._check_throttled_state()
if not self._throttle_functional:
return False
return self._throttle_state.as_dict()
def _check_throttled_state(self):
command = self._settings.get(["vcgencmd_throttle_check_command"])
self._logger.debug(f'Retrieving throttle state via "{command}"')
try:
state = get_vcgencmd_throttled_state(command)
except ValueError:
self._logger.warning(
'Fetching the current throttle state via "{}" doesn\'t work'.format(
command
)
)
self._throttle_functional = False
return
if self._throttle_state == state:
# no change
return
self._throttle_state = state
if (not self._throttle_undervoltage and self._throttle_state.undervoltage) or (
not self._throttle_overheat and self._throttle_state.overheat
):
message = (
"This Raspberry Pi is reporting problems that might lead to bad performance or errors caused "
"by overheating or insufficient power."
)
if self._throttle_state.undervoltage:
self._throttle_undervoltage = True
message += (
"\n!!! UNDERVOLTAGE REPORTED !!! Make sure that the power supply and power cable are "
"capable of supplying enough voltage and current to your Pi."
)
if self._throttle_state.overheat:
self._throttle_overheat = True
message += (
"\n!!! FREQUENCY CAPPING DUE TO OVERHEATING REPORTED !!! Improve cooling on the Pi's "
"CPU and GPU."
)
self._logger.warning(message)
self._plugin_manager.send_plugin_message(
self._identifier,
{"type": "throttle_state", "state": self._throttle_state.as_dict()},
)
# noinspection PyUnresolvedReferences
self._event_bus.fire(
octoprint.events.Events.PLUGIN_PI_SUPPORT_THROTTLE_STATE,
self._throttle_state.as_dict(),
)
def register_custom_events(*args, **kwargs):
return [
"throttle_state",
]
__plugin_name__ = "Pi Support Plugin"
__plugin_author__ = "Gina Häußge"
__plugin_description__ = "Provides additional information about your Pi in the UI."
__plugin_disabling_discouraged__ = gettext(
"Without this plugin OctoPrint will no longer be able to "
"provide additional information about your Pi, "
"which will make it more tricky to help you if you need support."
)
__plugin_license__ = "AGPLv3"
__plugin_pythoncompat__ = ">=2.7,<4"
def __plugin_check__():
try:
proc_dt_model = get_proc_dt_model()
if proc_dt_model is None:
return False
except Exception:
return False
return "raspberry pi" in proc_dt_model.lower()
def __plugin_load__():
plugin = PiSupportPlugin()
global __plugin_implementation__
__plugin_implementation__ = plugin
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.events.register_custom_events": register_custom_events,
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions,
}
global __plugin_helpers__
__plugin_helpers__ = {"get_throttled": plugin.get_throttle_state}
@@ -1,18 +0,0 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["OctoPrintClient"], factory);
} else {
factory(global.OctoPrintClient);
}
})(this, function (OctoPrintClient) {
var OctoPrintPiSupportClient = function (base) {
this.base = base;
};
OctoPrintPiSupportClient.prototype.get = function (opts) {
return this.base.get(this.base.getSimpleApiUrl("pi_support"));
};
OctoPrintClient.registerPluginComponent("pi_support", OctoPrintPiSupportClient);
return OctoPrintPiSupportClient;
});
@@ -1,8 +0,0 @@
#octopi_support_footer {
white-space: nowrap;
}
.pi_support_state_pulsate {
animation: pulsate 1s ease-out;
animation-iteration-count: infinite;
}
@@ -1,172 +0,0 @@
$(function () {
function PiSupportViewModel(parameters) {
var self = this;
self.loginState = parameters[0];
self.access = parameters[1];
self.settings = parameters[2];
self.model = ko.observable();
self.currentUndervoltage = ko.observable(false);
self.currentOverheat = ko.observable(false);
self.pastUndervoltage = ko.observable(false);
self.pastOverheat = ko.observable(false);
self.currentIssue = ko.observable(false);
self.pastIssue = ko.observable(false);
self.requestData = function () {
if (
!self.loginState.hasPermission(
self.access.permissions.PLUGIN_PI_SUPPORT_STATUS
)
) {
return;
}
OctoPrint.plugins.pi_support.get().done(function (response) {
// Raspberry Pi model
self.model(response.model);
// Unrecommended model
if (
response.model_unrecommended &&
!self.settings.settings.plugins.pi_support.ignore_unrecommended_model()
) {
var warning = gettext(
"OctoPrint does not and never has supported the " +
"RPi Zero or Zero W. Use at least a Raspberry Pi 3, or " +
"risk bad performance and failed prints."
);
var faq = gettext(
"" +
'You can read more <a href="%(url)s" target="_blank">in the FAQ</a>.'
);
var remove = gettext(
"You can disable this message via Settings > " +
"Pi Support > Ignore warning on unsupported hardware"
);
new PNotify({
title: gettext("Unsupported hardware detected"),
text:
"<p>" +
warning +
"</p><p>" +
_.sprintf(faq, {
url: "https://faq.octoprint.org/recommended-hardware"
}) +
"</p><p>" +
"<small>" +
remove +
"</small></p>",
type: "error",
hide: false
});
}
// Throttle state
self.fromThrottleState(response.throttle_state);
// OctoPi version
$("#pi_support_footer").remove();
if (!response.octopi_version) return;
var octoPiVersion = $(
"<li id='pi_support_footer'><small>" +
gettext("OctoPi") +
" " +
"<span class='octopi_version'>" +
response.octopi_version +
"</span></small></li>"
);
$("#footer_version").append(octoPiVersion);
});
};
self.fromThrottleState = function (state) {
self.currentUndervoltage(state.current_undervoltage);
self.pastUndervoltage(state.past_undervoltage);
self.currentOverheat(state.current_overheat);
self.pastOverheat(state.past_overheat);
self.currentIssue(state.current_issue);
self.pastIssue(state.past_issue);
};
self.popoverContent = ko.pureComputed(function () {
var undervoltageParagraphClasses = "muted";
var undervoltageSymbolClasses = "";
var overheatParagraphClasses = "muted";
var overheatSymbolClasses = "";
if (self.currentUndervoltage()) {
undervoltageSymbolClasses = "text-error pi_support_state_pulsate";
undervoltageParagraphClasses = "";
} else if (self.pastUndervoltage()) {
undervoltageSymbolClasses = "text-error";
undervoltageParagraphClasses = "";
}
if (self.currentOverheat()) {
overheatSymbolClasses = "text-error pi_support_state_pulsate";
overheatParagraphClasses = "";
} else if (self.pastOverheat()) {
overheatSymbolClasses = "text-error";
overheatParagraphClasses = "";
}
return (
"<p class='" +
undervoltageParagraphClasses +
"'><strong class='" +
undervoltageSymbolClasses +
'\'><i class="fa fa-bolt"></i><i class="fa fa-exclamation"></i></strong></strong> - ' +
gettext(
"Undervoltage. Make sure your power supply and cabling are providing enough power to the Pi."
) +
"</p>" +
"<p class='" +
overheatParagraphClasses +
"'><strong class='" +
overheatSymbolClasses +
'\'><i class="fa fa-thermometer-full"></i><i class="fa fa-exclamation"></i></strong> - ' +
gettext(
"Frequency capping due to overheating. Improve cooling of the CPU and GPU."
) +
"</p>" +
"<p>" +
gettext(
"A blinking symbol indicates a current issue, a non blinking symbol one that was observed some time since the Pi booted up."
) +
"</p>" +
"<p><small>" +
gettext("Click the symbol in the navbar for more information.") +
"</small></p>"
);
});
self.onStartup = self.onServerReconnect = self.onUserLoggedIn = self.onUserLoggedOut = function () {
self.requestData();
};
self.onDataUpdaterPluginMessage = function (plugin, data) {
if (plugin !== "pi_support") return;
if (!data.hasOwnProperty("state") || !data.hasOwnProperty("type")) return;
if (data.type !== "throttle_state") return;
if (
!self.loginState.hasPermission(
self.access.permissions.PLUGIN_PI_SUPPORT_STATUS
)
)
return;
self.fromThrottleState(data.state);
};
}
OCTOPRINT_VIEWMODELS.push({
construct: PiSupportViewModel,
elements: ["#navbar_plugin_pi_support"],
dependencies: ["loginStateViewModel", "accessViewModel", "settingsViewModel"]
});
});
@@ -1,31 +0,0 @@
<h3>{{ _('About OctoPi') }}</h3>
<h4>The ready-to-go Raspberry Pi image with OctoPrint</h4>
<p>Version <span class="plugin_pi_support_octopi_version">{{ plugin_pi_support_octopi_version }}</span>, running on <span class="plugin_pi_support_model">{{ plugin_pi_support_model }}</span></p>
<ul>
<li>Website: <a href="https://octoprint.org/download/" target="_blank" rel="noreferrer noopener">octoprint.org/download</a></li>
<li>Source Code: <a href="https://github.com/guysoft/OctoPi" target="_blank" rel="noreferrer noopener">github.com/guysoft/OctoPi</a></li>
</ul>
<p>
&copy; 2013-{{ now.strftime("%Y") }} <a href="https://github.com/guysoft/OctoPi/graphs/contributors" target="_blank" rel="noreferrer noopener">The OctoPi Authors</a>
</p>
<p>
OctoPi is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
</p>
<p>
OctoPi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
</p>
<p>
For a copy of the GNU General Public License, see
<a href="https://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank" rel="noreferrer noopener">www.gnu.org/licenses/gpl-3.0.en.html</a>.
</p>
@@ -1,4 +0,0 @@
<a href="https://faq.octoprint.org/pi-issues" target="_blank" rel="noopener noreferrer" data-bind="visible: currentIssue() || pastIssue(), popover: { placement: 'bottom', title: '{{ _('What do the symbols mean?')|esq }}', html: true, content: popoverContent, trigger: 'hover' }" style="display: none">
<span data-bind="visible: currentUndervoltage() || pastUndervoltage(), css: {'pi_support_state_pulsate': currentUndervoltage}" title="{{ _('Undervoltage')|edq }}"><i class="fas fa-bolt"></i><i class="fas fa-exclamation"></i></span>
<span data-bind="visible: currentOverheat() || pastOverheat(), css: {'pi_support_state_pulsate': currentOverheat}" title="{{ _('Overheat')|edq }}"><i class="fas fa-thermometer-full"></i><i class="fas fa-exclamation"></i></span>
</a>
@@ -1,38 +0,0 @@
<h3>{{ _('Pi Support') }}</h3>
<p>{{ _('Please restart OctoPrint after changing any of this plugin\'s settings.') }}</p>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.pi_support.ignore_unrecommended_model"> {{ _('Disable warning about unsupported hardware') }} <label class="label label-important">{{ _('Warning') }}</label>
</label>
<span class="help-block">{{ _('If you check this, you will no longer get warned if you run OctoPrint on Raspberry Pi models that are not officially supported due to bad performance that can lead to failed prints. Do so at your own risk.') }}</span>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: settings.plugins.pi_support.vcgencmd_throttle_check_enabled"> {{ _('Enable under voltage and overheat detection via <code>vcgencmd get_throttled</code>') }}
</label>
<span class="help-block">{{ _('This will regularly check with the Pi if something is amiss either with power regulation or CPU/GPU temperature.') }}</span>
</div>
</div>
<div>
<div><small><a href="#" class="muted" onclick="$(this).children().toggleClass('fa-caret-right fa-caret-down').parent().parent().parent().next().slideToggle('fast')"><i class="fas fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Command for under voltage/overheat detection') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.plugins.pi_support.vcgencmd_throttle_check_command">
<span class="help-block">{{ _('Defaults to <code>/usr/bin/vcgencmd get_throttled</code>. You usually shouldn\'t have to change this.') }}</span>
</div>
</div>
</form>
</div>
</div>
</form>
@@ -1 +1 @@
#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}
#settings_plugin_pluginmanager_pluginlist{height:calc(100vh - 450px);display:block;width:auto;overflow-x:hidden;padding-right:2px;margin-bottom:1em;position:relative;border-top:1px solid #eee;padding-top:6px}#settings_plugin_pluginmanager_pluginlist>table{margin-top:0px}#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}
@@ -1,21 +1,20 @@
#settings_plugin_pluginmanager {
}
#settings_plugin_pluginmanager_navbar {
position: -webkit-sticky; /* Safari, according to the internet */
position: sticky;
top: 0;
padding-bottom: 1px;
border-bottom: 1px solid #ddd;
background: white;
}
#settings_plugin_pluginmanager_pluginlist {
height: calc(100vh - 450px);
display: block;
width: auto;
overflow-x: hidden;
padding-right: 2px;
margin-bottom: 1em;
position: relative;
border-top: 1px solid #eee;
padding-top: 6px;
> table {
margin-top: 0px;
}
table {
th,
+19 -4
View File
@@ -228,6 +228,10 @@ class Printer(
Events.METADATA_STATISTICS_UPDATED, self._on_event_MetadataStatisticsUpdated
)
self._handle_connect_hooks = plugin_manager().get_hooks(
"octoprint.printer.handle_connect"
)
def _create_estimator(self, job_type=None):
if job_type is None:
with self._selectedFileMutex:
@@ -391,6 +395,17 @@ class Printer(
if self._protocol is not None or self._transport is not None:
return
for name, hook in self._handle_connect_hooks.items():
try:
if hook(self, **kwargs):
self._logger.info(f"Connect signalled as handled by plugin {name}")
return
except Exception:
self._logger.exception(
f"Exception while handling connect in plugin {name}",
extra={"plugin": name},
)
## prepare feedback controls
self._feedback_controls, self._feedback_matcher = convert_feedback_controls(
settings().get(["controls"])
@@ -1468,16 +1483,16 @@ class Printer(
except Exception:
pass
else:
if "display" in file_data:
if file_data.get("display"):
display_name = file_data["display"]
if "analysis" in file_data:
if isinstance(file_data.get("analysis"), dict):
if "estimatedPrintTime" in file_data["analysis"]:
analysis_total = file_data["analysis"]["estimatedPrintTime"]
if "filament" in file_data["analysis"].keys():
if file_data["analysis"].get("filament"):
filament = file_data["analysis"]["filament"]
if "statistics" in file_data:
if isinstance(file_data.get("statistics"), dict):
printer_profile = (
self._printer_profile_manager.get_current_or_default()["id"]
)
+2 -1
View File
@@ -1284,7 +1284,7 @@ class Server:
self._logger.exception("Stacktrace follows:")
def _create_socket_connection(self, session):
global printer, fileManager, analysisQueue, userManager, eventManager
global printer, fileManager, analysisQueue, userManager, eventManager, connectivityChecker
return util.sockjs.PrinterStateConnection(
printer,
fileManager,
@@ -1293,6 +1293,7 @@ class Server:
groupManager,
eventManager,
pluginManager,
connectivityChecker,
session,
)
+66 -9
View File
@@ -162,6 +162,54 @@ def readGcodeFiles():
return jsonify(files=files, free=usage.free, total=usage.total)
@api.route("/files/test", methods=["POST"])
@Permissions.FILES_LIST.require(403)
def runFilesTest():
valid_commands = {
"sanitize": ["storage", "path", "filename"],
"exists": ["storage", "path", "filename"],
}
command, data, response = get_json_command_from_request(request, valid_commands)
if response is not None:
return response
def sanitize(storage, path, filename):
sanitized_path = fileManager.sanitize_path(storage, path)
sanitized_name = fileManager.sanitize_name(storage, filename)
joined = fileManager.join_path(storage, sanitized_path, sanitized_name)
return sanitized_path, sanitized_name, joined
if command == "sanitize":
_, _, sanitized = sanitize(data["storage"], data["path"], data["filename"])
return jsonify(sanitized=sanitized)
elif command == "exists":
storage = data["storage"]
path = data["path"]
filename = data["filename"]
sanitized_path, _, sanitized = sanitize(storage, path, filename)
exists = fileManager.file_exists(storage, sanitized)
if exists:
suggestion = filename
name, ext = os.path.splitext(filename)
counter = 0
while fileManager.file_exists(
storage,
fileManager.join_path(
storage,
sanitized_path,
fileManager.sanitize_name(storage, suggestion),
),
):
counter += 1
suggestion = name + f"_{counter}" + ext
return jsonify(exists=True, suggestion=suggestion)
else:
return jsonify(exists=False)
@api.route("/files/<string:origin>", methods=["GET"])
@Permissions.FILES_LIST.require(403)
@with_revalidation_checking(
@@ -506,6 +554,11 @@ def uploadGcodeFile(target):
canonPath, canonFilename = fileManager.canonicalize(
FileDestinations.LOCAL, upload.filename
)
if request.values.get("path"):
canonPath = request.values.get("path")
if request.values.get("filename"):
canonFilename = request.values.get("filename")
futurePath = fileManager.sanitize_path(FileDestinations.LOCAL, canonPath)
futureFilename = fileManager.sanitize_name(
FileDestinations.LOCAL, canonFilename
@@ -518,12 +571,6 @@ def uploadGcodeFile(target):
if futureFilename is None:
abort(415, description="Can not upload file, wrong format?")
if "path" in request.values and request.values["path"]:
# we currently only support uploads to sdcard via local, so first target is local instead of "target"
futurePath = fileManager.sanitize_path(
FileDestinations.LOCAL, request.values["path"]
)
# prohibit overwriting currently selected file while it's being printed
futureFullPath = fileManager.join_path(
FileDestinations.LOCAL, futurePath, futureFilename
@@ -538,6 +585,12 @@ def uploadGcodeFile(target):
description="Trying to overwrite file that is currently being printed",
)
if (
fileManager.file_exists(FileDestinations.LOCAL, futureFullPathInStorage)
and request.values.get("noOverwrite") in valid_boolean_trues
):
abort(409, description="File already exists and noOverwrite was set")
reselect = printer.is_current_file(futureFullPathInStorage, sd)
user = current_user.get_name()
@@ -1160,9 +1213,13 @@ def _getCurrentFile():
def _validate(target, filename):
return filename == "/".join(
map(lambda x: fileManager.sanitize_name(target, x), filename.split("/"))
)
if target == FileDestinations.SDCARD:
# we make no assumptions about the shape of valid SDCard file names
return True
else:
return filename == "/".join(
map(lambda x: fileManager.sanitize_name(target, x), filename.split("/"))
)
class WerkzeugFileWrapper(octoprint.filemanager.util.AbstractFileWrapper):
+36
View File
@@ -120,6 +120,7 @@ def getSettings():
"snapshotTimeout": s.getInt(["webcam", "snapshotTimeout"]),
"snapshotSslValidation": s.getBoolean(["webcam", "snapshotSslValidation"]),
"ffmpegPath": s.get(["webcam", "ffmpeg"]),
"ffmpegCommandline": s.get(["webcam", "ffmpegCommandline"]),
"bitrate": s.get(["webcam", "bitrate"]),
"ffmpegThreads": s.get(["webcam", "ffmpegThreads"]),
"ffmpegVideoCodec": s.get(["webcam", "ffmpegVideoCodec"]),
@@ -138,6 +139,9 @@ def getSettings():
"printCancelConfirmation": s.getBoolean(
["feature", "printCancelConfirmation"]
),
"uploadOverwriteConfirmation": s.getBoolean(
["feature", "uploadOverwriteConfirmation"]
),
"g90InfluencesExtruder": s.getBoolean(["feature", "g90InfluencesExtruder"]),
"autoUppercaseBlacklist": s.get(["feature", "autoUppercaseBlacklist"]),
},
@@ -520,6 +524,33 @@ def _saveSettings(data):
)
if "ffmpegPath" in data["webcam"]:
s.set(["webcam", "ffmpeg"], data["webcam"]["ffmpegPath"])
if "ffmpegCommandline" in data["webcam"]:
commandline = data["webcam"]["ffmpegCommandline"]
if not all(
map(lambda x: "{" + x + "}" in commandline, ("ffmpeg", "input", "output"))
):
abort(
400,
description="Invalid webcam.ffmpegCommandline setting, lacks mandatory {ffmpeg}, {input} or {output}",
)
try:
commandline.format(
ffmpeg="ffmpeg",
fps="fps",
bitrate="bitrate",
threads="threads",
input="input",
output="output",
videocodec="videocodec",
containerformat="containerformat",
filters="filters",
)
except Exception:
# some invalid data we'll refuse to set
logger.exception("Invalid webcam.ffmpegCommandline setting")
abort(400, description="Invalid webcam.ffmpegCommandline setting")
else:
s.set(["webcam", "ffmpegCommandline"], commandline)
if "bitrate" in data["webcam"]:
s.set(["webcam", "bitrate"], data["webcam"]["bitrate"])
if "ffmpegThreads" in data["webcam"]:
@@ -564,6 +595,11 @@ def _saveSettings(data):
["feature", "printCancelConfirmation"],
data["feature"]["printCancelConfirmation"],
)
if "uploadOverwriteConfirmation" in data["feature"]:
s.setBoolean(
["feature", "uploadOverwriteConfirmation"],
data["feature"]["uploadOverwriteConfirmation"],
)
if "g90InfluencesExtruder" in data["feature"]:
s.setBoolean(
["feature", "g90InfluencesExtruder"],
+3
View File
@@ -116,6 +116,7 @@ class PrinterStateConnection(
groupManager,
eventManager,
pluginManager,
connectivityChecker,
session,
):
if isinstance(session, octoprint.vendor.sockjs.tornado.session.Session):
@@ -142,6 +143,7 @@ class PrinterStateConnection(
self._groupManager = groupManager
self._eventManager = eventManager
self._pluginManager = pluginManager
self._connectivityChecker = connectivityChecker
self._remoteAddress = None
self._user = self._userManager.anonymous_user_factory()
@@ -220,6 +222,7 @@ class PrinterStateConnection(
"config_hash": config_hash,
"debug": octoprint.server.debug,
"safe_mode": octoprint.server.safe_mode,
"online": self._connectivityChecker.online,
"permissions": [permission.as_dict() for permission in Permissions.all()],
},
)
+8 -1
View File
@@ -312,7 +312,7 @@ def in_cache():
@app.route("/")
def index():
from octoprint.server import printer
from octoprint.server import connectivityChecker, printer
global _templates, _plugin_names, _plugin_vars
@@ -366,6 +366,7 @@ def index():
enable_webcam,
enable_temperature_graph,
sockjs_connect_timeout,
connectivityChecker.online,
wizard_active(_templates.get(locale)),
] + sorted(
[
@@ -588,6 +589,7 @@ def index():
"enableSdSupport": enable_sd_support,
"sockJsConnectTimeout": sockjs_connect_timeout * 1000,
"wizard": wizard,
"online": connectivityChecker.online,
"now": now,
}
)
@@ -859,6 +861,11 @@ def fetch_template_data(refresh=False):
# navbar
templates["navbar"]["entries"] = {
"offlineindicator": {
"template": "navbar/offlineindicator.jinja2",
"_div": "navbar_offlineindicator",
"custom_bindings": False,
},
"settings": {
"template": "navbar/settings.jinja2",
"_div": "navbar_settings",
+2
View File
@@ -242,6 +242,7 @@ default_settings = {
"flipH": False,
"flipV": False,
"rotate90": False,
"ffmpegCommandline": '{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
"timelapse": {
"type": "off",
"options": {},
@@ -266,6 +267,7 @@ default_settings = {
"modelSizeDetection": True,
"printStartConfirmation": False,
"printCancelConfirmation": True,
"uploadOverwriteConfirmation": True,
"autoUppercaseBlacklist": ["M117", "M118"],
"g90InfluencesExtruder": False,
},
+1 -1
View File
@@ -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,.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
.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
+13 -10
View File
@@ -7,6 +7,7 @@
})(this, function (OctoPrintClient, $, _) {
var url = "api/files";
var downloadUrl = "downloads/files";
var testUrl = url + "/test";
var OctoPrintFilesClient = function (base) {
this.base = base;
@@ -198,20 +199,22 @@
return recursiveSearch(path.split("/"), root);
};
OctoPrintFilesClient.prototype.pathForElement = function (element) {
// TODO Remove in 1.4.x
log.warn(
"pathForElement has been renamed to pathForEntry, please use that instead"
OctoPrintFilesClient.prototype.sanitize = function (location, path, filename, opts) {
return this.base.issueCommand(
testUrl,
"sanitize",
{storage: location, path: path, filename: filename},
opts
);
return this.pathForEntry(element);
};
OctoPrintFilesClient.prototype.elementByPath = function (location, startElement) {
// TODO Remove in 1.4.x
log.warn(
"elementByPath has been renamed to entryForPath, please use that instead"
OctoPrintFilesClient.prototype.exists = function (location, path, filename, opts) {
return this.base.issueCommand(
testUrl,
"exists",
{storage: location, path: path, filename: filename},
opts
);
return this.entryForPath(location, startElement);
};
OctoPrintClient.registerComponent("files", OctoPrintFilesClient);
@@ -173,6 +173,9 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
BRANCH = data["branch"];
$("span.version").text(DISPLAY_VERSION);
// update connectivity state
ONLINE = data["online"];
// update plugin hash
var oldPluginHash = self._pluginHash;
self._pluginHash = data["plugin_hash"];
@@ -413,6 +416,8 @@ function DataUpdater(allViewModels, connectCallback, disconnectCallback) {
type: severity,
hide: false
});
} else if (type === "ConnectivityChanged") {
ONLINE = payload.new;
}
var legacyEventHandlers = {
@@ -513,6 +513,11 @@ $(function () {
clearTimeout(self.webcamDisableTimeout);
}
// IF disabled then we dont need to do anything
if (self.settings.webcam_webcamEnabled() == false) {
return;
}
// Determine stream type and switch to corresponding webcam.
var streamType = determineWebcamStreamType(self.settings.webcam_streamUrl());
if (streamType == "mjpg") {
@@ -707,7 +712,12 @@ $(function () {
self._switchToHlsWebcam = function () {
var video = document.getElementById("webcam_hls");
if (video.canPlayType("application/vnd.apple.mpegurl")) {
// Check for native playback options: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType
if (
video != null &&
typeof video.canPlayType != undefined &&
video.canPlayType("application/vnd.apple.mpegurl") == "probably"
) {
video.src = self.settings.webcam_streamUrl();
} else if (Hls.isSupported()) {
var hls = new Hls();
+117 -24
View File
@@ -97,6 +97,9 @@ $(function () {
);
});
self.uploadExistsDialog = undefined;
self.uploadFilename = ko.observable(undefined);
self.allItems = ko.observable(undefined);
self.currentPath = ko.observable("");
self.uploadProgressText = ko.observable();
@@ -160,18 +163,22 @@ $(function () {
listHelperExclusiveFilters.push(SUPPORTED_FILETYPES);
}
var sortByName = function (a, b) {
// sorts ascending
if (a["display"].toLowerCase() < b["display"].toLowerCase()) return -1;
if (a["display"].toLowerCase() > b["display"].toLowerCase()) return 1;
return 0;
};
self.listHelper = new ItemListHelper(
"gcodeFiles",
{
name: function (a, b) {
// sorts ascending
if (a["display"].toLowerCase() < b["display"].toLowerCase())
return -1;
if (a["display"].toLowerCase() > b["display"].toLowerCase()) return 1;
return 0;
},
name: sortByName,
upload: function (a, b) {
// sorts descending
if (a["date"] === undefined && b["date"] === undefined) {
return sortByName(a, b);
}
if (b["date"] === undefined || a["date"] > b["date"]) return -1;
if (a["date"] === undefined || a["date"] < b["date"]) return 1;
return 0;
@@ -1221,6 +1228,8 @@ $(function () {
}
});
self.uploadExistsDialog = $("#upload_exists_dialog");
//~~ Gcode upload
self.uploadButton = $("#gcode_upload");
@@ -1419,22 +1428,18 @@ $(function () {
if (button === undefined) return;
button
.fileupload({
url: url,
dataType: "json",
dropZone: enable ? drop : null,
drop: function (e, data) {},
submit: self._handleUploadStart,
done: self._handleUploadDone,
fail: self._handleUploadFail,
always: self._handleUploadAlways,
progressall: self._handleUploadProgress
})
.bind("fileuploadsubmit", function (e, data) {
if (self.currentPath() !== "")
data.formData = {path: self.currentPath()};
});
button.fileupload({
url: url,
dataType: "json",
dropZone: enable ? drop : null,
drop: function (e, data) {},
add: self._handleUploadAdd,
submit: self._handleUploadStart,
done: self._handleUploadDone,
fail: self._handleUploadFail,
always: self._handleUploadAlways,
progressall: self._handleUploadProgress
});
};
self._enableDragNDrop = function (enable) {
@@ -1460,6 +1465,89 @@ $(function () {
}
};
self._handleUploadAdd = function (e, data) {
var file = data.files[0];
var path = self.currentPath();
var formData = {};
if (path !== "") {
formData.path = path;
}
if (self.settingsViewModel.feature_uploadOverwriteConfirmation()) {
OctoPrint.files
.exists("local", path, file.name)
.done(function (response) {
if (response.exists) {
$("h3", self.uploadExistsDialog).text(
_.sprintf(gettext("File already exists: %(name)s"), {
name: file.name
})
);
$("input", self.uploadExistsDialog)
.val("")
.prop("placeholder", response.suggestion);
$("a.upload-rename", self.uploadExistsDialog)
.prop("disabled", false)
.off("click")
.on("click", function () {
var newName = $(
"input",
self.uploadExistsDialog
).val();
if (newName === "") newName = response.suggestion;
OctoPrint.files
.exists("local", path, newName)
.done(function (r) {
if (r.exists) {
$(
".control-group",
self.uploadExistsDialog
).addClass("error");
$(
".help-block",
self.uploadExistsDialog
).show();
} else {
$(
".control-group",
self.uploadExistsDialog
).removeClass("error");
$(
".help-block",
self.uploadExistsDialog
).hide();
self.uploadExistsDialog.modal("hide");
formData.filename = newName;
formData.noOverwrite = true;
data.formData = formData;
data.submit();
}
});
});
$("a.upload-overwrite", self.uploadExistsDialog)
.off("click")
.on("click", function () {
self.uploadExistsDialog.modal("hide");
data.formData = formData;
data.submit();
});
self.uploadExistsDialog.modal("show");
} else {
data.formData = formData;
data.submit();
}
});
} else {
data.formData = formData;
data.submit();
}
};
self._handleUploadStart = function (e, data) {
self.ignoreUpdatedFilesEvent = true;
return true;
@@ -1607,6 +1695,11 @@ $(function () {
"printerProfilesViewModel",
"accessViewModel"
],
elements: ["#files_wrapper", "#add_folder_dialog", "#move_file_or_folder_dialog"]
elements: [
"#files_wrapper",
"#add_folder_dialog",
"#move_file_or_folder_dialog",
"#upload_exists_dialog"
]
});
});
@@ -9,6 +9,21 @@ $(function () {
self.system = parameters[4];
self.access = parameters[5];
self.offline = ko.observable(!ONLINE);
self.offlinePopoverContent = function () {
return (
"<p>" +
gettext(
"OctoPrint cannot reach the internet. If this is not " +
"intentional, please check OctoPrint's network settings and " +
"the connectivity check configuration. Updates, plugin repository " +
"and anything else requiring access to the public internet will not " +
"work."
) +
"</p>"
);
};
self.appearanceClasses = ko.pureComputed(function () {
var classes = self.appearance.color();
if (self.appearance.colorTransparent()) {
@@ -16,6 +31,10 @@ $(function () {
}
return classes;
});
self.onServerReconnect = self.onServerConnect = self.onEventConnectivityChanged = function () {
self.offline(!ONLINE);
};
}
OCTOPRINT_VIEWMODELS.push({
@@ -158,6 +158,7 @@ $(function () {
self.webcam_snapshotTimeout = ko.observable(undefined);
self.webcam_snapshotSslValidation = ko.observable(undefined);
self.webcam_ffmpegPath = ko.observable(undefined);
self.webcam_ffmpegCommandline = ko.observable(undefined);
self.webcam_bitrate = ko.observable(undefined);
self.webcam_ffmpegThreads = ko.observable(undefined);
self.webcam_ffmpegVideoCodec = ko.observable(undefined);
@@ -173,6 +174,7 @@ $(function () {
self.feature_modelSizeDetection = ko.observable(undefined);
self.feature_printStartConfirmation = ko.observable(undefined);
self.feature_printCancelConfirmation = ko.observable(undefined);
self.feature_uploadOverwriteConfirmation = ko.observable(undefined);
self.feature_g90InfluencesExtruder = ko.observable(undefined);
self.feature_autoUppercaseBlacklist = ko.observable(undefined);
@@ -44,7 +44,8 @@
return;
}
notice.text_container.css("max-height", height);
notice.text_container.css("overflow", "auto");
notice.text_container.css("overflow-x", "hidden");
notice.text_container.css("overflow-y", "auto");
};
PNotify.prototype.modules.maxheight = {
+4 -3
View File
@@ -856,7 +856,7 @@ ul.dropdown-menu li a {
height: 30px;
margin-right: 10px;
margin-bottom: 10px;
padding-left: 8px;
padding: 0;
}
.control-box {
@@ -1383,10 +1383,11 @@ _:future,
.safari {
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 10px;
-webkit-border-radius: 10px;
}
::-webkit-scrollbar-thumb {
-webkit-border-radius: 10px;
@@ -41,3 +41,27 @@
<a href="#" class="btn btn-primary" data-bind="click: function() { if (moveSource() !== moveDestination() && !movingFileOrFolder()) { $root.moveFileOrFolder(moveEntry().path, moveDestination()) } else {} }, css: {disabled: moveSource() === moveDestination() || movingFileOrFolder()}"><i class="fas fa-spinner fa-spin" data-bind="visible: movingFileOrFolder"></i> {{ _('Move') }}</a>
</div>
</div>
<div id="upload_exists_dialog" class="modal hide fade">
<div class="modal-header">
<a href="#" class="close" data-dismiss="modal" aria-hidden="true">&times;</a>
<h3>{{ _('File already exists') }}</h3>
</div>
<div class="modal-body">
<p>{{ _('If you want to rename the file, you may do so below. A collision free suggestion has already been made.') }}</p>
<form class="form-horizontal" action="javascript:void(0)">
<div class="control-group">
<label class="control-label">{{ _('Rename to') }}</label>
<div class="controls">
<input type="text" class="input-block-level">
<span class="help-block" style="display: none">{{ _('File already exists') }}</span>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<a href="javascript:void(0)" class="btn" data-dismiss="modal" aria-hidden="true">{{ _('Cancel') }}</a>
<a href="javascript:void(0)" class="btn btn-primary upload-rename">{{ _('Upload (rename)') }}</a>
<a href="javascript:void(0)" class="btn btn-danger upload-overwrite">{{ _('Upload (overwrite)') }}</a>
</div>
</div>
@@ -1,3 +1,4 @@
<h3>{{ _("Access Control") }}</h3>
<ul class="nav nav-pills">
<li id="settings_accesscontrol_users_link" class="active">
<a href="#settings_accesscontrol_users" data-toggle="tab">{{ _('Users') }}</a>
@@ -1,6 +1,6 @@
<form class="form-horizontal" onsubmit="return false;">
<fieldset>
<legend>{{ _('CORS') }}</legend>
<h3>{{ _('CORS') }}</h3>
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -10,7 +10,7 @@
</div>
</fieldset>
<fieldset>
<legend>{{ _('Global API Key') }}</legend>
<h3>{{ _('Global API Key') }}</h3>
<div class="alert">
<p>{% trans %}
It is recommended to no longer use the global API key as it's one single key that gives full admin access
@@ -1,3 +1,4 @@
<h3>{{ _("Appearance") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group" title="{{ _('Name of this OctoPrint instance, will be shown in the navigation bar and broadcast on the network')|edq }}">
<label class="control-label" for="settings-appearanceName">{{ _('Title') }}</label>
@@ -1,3 +1,4 @@
<h3>{{ _("Features") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<div class="controls">
@@ -27,6 +28,13 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: feature_uploadOverwriteConfirmation" id="settings-uploadOverwriteConfirmation"> {{ _('Confirm before overwriting a file by upload') }}
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
@@ -1,3 +1,4 @@
<h3>{{ _("GCODE Scripts") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="control-group">
<label class="control-label">{{ _('Before print job starts') }}</label>
@@ -1,3 +1,4 @@
<h3>{{ _("Server") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
{% include "snippets/settings/server/serverAllowFraming.jinja2" %}
@@ -1,3 +1,4 @@
<h3>{{ _("Terminal Filters") }}</h3>
<form class="form-horizontal" onsubmit="return false;">
<div class="row-fluid">
<div class="span4"><h4>{{ _('Name') }}</h4></div>
@@ -29,6 +29,7 @@
<div><small><a href="#" class="muted" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.form-horizontal', container: '.hide' }"><i class="fas
fa-caret-right"></i> {{ _('Advanced options') }}</a></small></div>
<div class="hide">
{% include "snippets/settings/webcam/ffmpegCommandline.jinja2" %}
{% include "snippets/settings/webcam/ffmpegBitrate.jinja2" %}
{% include "snippets/settings/webcam/ffmpegThreads.jinja2" %}
{% include "snippets/settings/webcam/webcamSnapshotTimeout.jinja2" %}
@@ -35,6 +35,7 @@
var SUPPORTED_EXTENSIONS = {{ supportedExtensions|tojson }};
var PERMISSIONS = {{ permissions|tojson }};
var ONLINE = {% if online -%}true{% else %}false{%- endif %};
var OCTOPRINT_VIEWMODELS = [];
var ADDITIONAL_VIEWMODELS = [];
@@ -0,0 +1,3 @@
<a href="https://faq.octoprint.org/connectivity-offline" target="_blank" title="{{ _('There is no connection to the internet') }}" rel="noopener noreferrer" data-bind="visible: offline(), popover: { placement: 'bottom', title: '{{ _('There is no connection to the internet')|esq }}', html: true, content: offlinePopoverContent, trigger: 'hover' }" style="display: none">
<i class="far fa-unlink"></i>
</a>
@@ -0,0 +1,16 @@
<div class="control-group" title="{{ _('FFMPEG command line to use')|edq }}">
<label class="control-label" for="settings-webcamFfmpegCommandline">{{ _('FFMPEG command line') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: webcam_ffmpegCommandline" id="settings-webcamFfmpegCommandline">
<span class="help-block">{% trans %}
You can adjust the full FFMPEG command line here that
is used to generate the timelapse recordings, e.g. to add additional command line
parameters as needed. Supported placeholders are:
<code>{ffmpeg}</code> (configured path to ffmpeg), <code>{fps}</code> (configured framerate),
<code>{input}</code> (input files), <code>{videocodec}</code> (configured video codec to use),
<code>{threads}</code> (configured number of threads to use), <code>{bitrate}</code> (configured bitrate to use),
<code>{containerformat}</code> (configured container format to use), <code>{filters}</code> (filter chain for flip/rotate & watermark),
<code>{output}</code> (output file).
{% endtrans %}</span>
</div>
</div>
+16 -27
View File
@@ -961,6 +961,7 @@ class TimelapseRenderJob:
"""Rendering runnable."""
ffmpeg = settings().get(["webcam", "ffmpeg"])
commandline = settings().get(["webcam", "ffmpegCommandline"])
bitrate = settings().get(["webcam", "bitrate"])
if ffmpeg is None or bitrate is None:
self._logger.warning(
@@ -1015,6 +1016,7 @@ class TimelapseRenderJob:
# prepare ffmpeg command
command_str = self._create_ffmpeg_command_string(
commandline,
ffmpeg,
self._fps,
bitrate,
@@ -1099,6 +1101,7 @@ class TimelapseRenderJob:
@classmethod
def _create_ffmpeg_command_string(
cls,
commandline,
ffmpeg,
fps,
bitrate,
@@ -1116,6 +1119,7 @@ class TimelapseRenderJob:
Create ffmpeg command string based on input parameters.
Arguments:
commandline (str): Command line template to use
ffmpeg (str): Path to ffmpeg
fps (int): Frames per second for output
bitrate (str): Bitrate of output
@@ -1143,38 +1147,23 @@ class TimelapseRenderJob:
else:
containerformat = "mp4"
command = [
ffmpeg,
"-framerate",
str(fps),
"-i",
f'"{input}"',
"-vcodec",
videocodec,
"-threads",
str(threads),
"-r",
"25",
"-y",
"-b",
str(bitrate),
"-f",
containerformat,
]
filter_string = cls._create_filter_string(
hflip=hflip, vflip=vflip, rotate=rotate, watermark=watermark
)
placeholders = {
"ffmpeg": ffmpeg,
"fps": str(fps),
"input": input,
"output": output,
"videocodec": videocodec,
"threads": str(threads),
"bitrate": str(bitrate),
"containerformat": containerformat,
"filters": "-vf " + sarge.shell_quote(filter_string) if filter_string else "",
}
if filter_string is not None:
logger.debug(f"Applying videofilter chain: {filter_string}")
command.extend(["-vf", sarge.shell_quote(filter_string)])
# finalize command with output file
logger.debug(f"Rendering movie to {output}")
command.append(f'"{output}"')
return " ".join(command)
return commandline.format(**placeholders)
@classmethod
def _create_filter_string(
File diff suppressed because it is too large. Load diff
+49 -4
View File
@@ -208,9 +208,8 @@ regex_command = re.compile(
class gcode:
def __init__(self, progress_callback=None):
def __init__(self, incl_layers=False, progress_callback=None):
self._logger = logging.getLogger(__name__)
self.layerList = None
self.extrusionAmount = [0]
self.extrusionVolume = [0]
self.totalMoveTimeMinute = 0
@@ -221,6 +220,25 @@ class gcode:
self._minMax = MinMax3D()
self._progress_callback = progress_callback
self._incl_layers = incl_layers
self._layers = []
self._current_layer = None
def _track_layer(self, pos):
if not self._incl_layers:
return
if self._current_layer is None or self._current_layer["z"] != pos.z:
self._current_layer = {"z": pos.z, "minmax": MinMax3D(), "commands": 1}
self._layers.append(self._current_layer)
elif self._current_layer:
self._current_layer["minmax"].record(pos)
def _track_command(self):
if self._current_layer:
self._current_layer["commands"] += 1
@property
def dimensions(self):
size = self._minMax.size
@@ -237,6 +255,23 @@ class gcode:
"maxZ": None if math.isinf(self._minMax.max.z) else self._minMax.max.z,
}
@property
def layers(self):
return [
{
"num": num + 1,
"z": layer["z"],
"commands": layer["commands"],
"bounds": {
"minX": layer["minmax"].min.x,
"maxX": layer["minmax"].max.x,
"minY": layer["minmax"].min.y,
"maxY": layer["minmax"].max.y,
},
}
for num, layer in enumerate(self._layers)
]
def load(
self,
filename,
@@ -450,6 +485,10 @@ class gcode:
# time to add is maximum of both
totalMoveTimeMinute += max(moveTimeXYZ, extrudeTime)
# process layers if there's extrusion
if e:
self._track_layer(pos)
elif gcode == "G4": # Delay
S = getCodeFloat(line, "S")
if S is not None:
@@ -510,7 +549,6 @@ class gcode:
pos.y = y
if z is not None:
pos.z = z
# M codes
elif gcode == "M82": # Absolute E
relativeE = False
@@ -578,6 +616,9 @@ class gcode:
for _ in range(len(totalExtrusion), currentExtruder + 1):
totalExtrusion.append(0.0)
if gcode or tool:
self._track_command()
if throttle is not None:
throttle(lineNo, readBytes)
if self._progress_callback is not None:
@@ -602,13 +643,17 @@ class gcode:
}
def get_result(self):
return {
result = {
"total_time": self.totalMoveTimeMinute,
"extrusion_length": self.extrusionAmount,
"extrusion_volume": self.extrusionVolume,
"dimensions": self.dimensions,
"printing_area": self.printing_area,
}
if self._incl_layers:
result["layers"] = self.layers
return result
def getCodeInt(line, code):
Whitespace-only changes.
@@ -1 +0,0 @@
Raspberry Pi Zero W Rev 1.1
@@ -1 +0,0 @@
0.15.1
@@ -1 +0,0 @@
print("throttled=0x50005")
-185
View File
@@ -1,185 +0,0 @@
import unittest
import unittest.mock as mock
import ddt
from octoprint.util.platform import CLOSE_FDS
OCTOPI_VERSION = "0.14.0"
DT_MODEL = "Raspberry Pi Model F Rev 1.1"
VCGENCMD = "/usr/bin/vcgencmd get_throttled"
class PiSupportTestCase(unittest.TestCase):
def test_get_octopi_version(self):
from octoprint.plugins.pi_support import get_octopi_version
# import _fixups
with mock.patch("builtins.open", mock.mock_open(), create=True) as m:
m.return_value.readline.return_value = OCTOPI_VERSION
version = get_octopi_version()
m.assert_called_once_with("/etc/octopi_version", encoding="utf-8")
self.assertEqual(version, OCTOPI_VERSION)
def test_get_proc_dt_model(self):
from octoprint.plugins.pi_support import get_proc_dt_model
with mock.patch("builtins.open", mock.mock_open(), create=True) as m:
m.return_value.readline.return_value = DT_MODEL
model = get_proc_dt_model()
m.assert_called_once_with("/proc/device-tree/model", encoding="utf-8")
self.assertEqual(model, DT_MODEL)
def test_get_vcgencmd_throttle_state(self):
from octoprint.plugins.pi_support import get_vcgencmd_throttled_state
with mock.patch("sarge.get_stdout", mock.MagicMock()) as m:
m.return_value = "throttled=0x70005"
state = get_vcgencmd_throttled_state(VCGENCMD)
m.assert_called_once_with(VCGENCMD, close_fds=CLOSE_FDS)
self.assertTrue(state.current_undervoltage)
self.assertFalse(state.current_overheat)
self.assertTrue(state.current_issue)
self.assertTrue(state.past_undervoltage)
self.assertTrue(state.past_overheat)
self.assertTrue(state.past_issue)
def test_get_vcgencmd_throttle_state_unparseable1(self):
from octoprint.plugins.pi_support import get_vcgencmd_throttled_state
with mock.patch("sarge.get_stdout", mock.MagicMock()) as m:
m.return_value = "invalid"
try:
get_vcgencmd_throttled_state(VCGENCMD)
except ValueError:
# expected
pass
else:
self.fail("Expected ValueError")
def test_get_vcgencmd_throttle_state_unparseable2(self):
from octoprint.plugins.pi_support import get_vcgencmd_throttled_state
with mock.patch("sarge.get_stdout", mock.MagicMock()) as m:
m.return_value = "throttled=0xinvalid"
try:
get_vcgencmd_throttled_state(VCGENCMD)
except ValueError:
# expected
pass
else:
self.fail("Expected ValueError")
@ddt.ddt
class ThrottleStateTestCase(unittest.TestCase):
@ddt.data(
(
0x00000,
{
"_undervoltage": False,
"_freq_capped": False,
"_throttled": False,
"_past_undervoltage": False,
"_past_freq_capped": False,
"_past_throttled": False,
"current_undervoltage": False,
"past_undervoltage": False,
"current_overheat": False,
"past_overheat": False,
"current_issue": False,
"past_issue": False,
},
),
(
0x50005,
{
"_undervoltage": True,
"_freq_capped": False,
"_throttled": True,
"_past_undervoltage": True,
"_past_freq_capped": False,
"_past_throttled": True,
"current_undervoltage": True,
"past_undervoltage": True,
"current_overheat": False,
"past_overheat": False,
"current_issue": True,
"past_issue": True,
},
),
(
0x50000,
{
"_undervoltage": False,
"_freq_capped": False,
"_throttled": False,
"_past_undervoltage": True,
"_past_freq_capped": False,
"_past_throttled": True,
"current_undervoltage": False,
"past_undervoltage": True,
"current_overheat": False,
"past_overheat": False,
"current_issue": False,
"past_issue": True,
},
),
(
0x00006,
{
"_undervoltage": False,
"_freq_capped": True,
"_throttled": True,
"_past_undervoltage": False,
"_past_freq_capped": False,
"_past_throttled": False,
"current_undervoltage": False,
"past_undervoltage": False,
"current_overheat": True,
"past_overheat": False,
"current_issue": True,
"past_issue": False,
},
),
)
@ddt.unpack
def test_conversion(self, input, expected_flags):
from octoprint.plugins.pi_support import ThrottleState
output = ThrottleState.from_value(input)
for key, value in expected_flags.items():
self.assertEqual(getattr(output, key), value)
def test_as_dict(self):
from octoprint.plugins.pi_support import ThrottleState
state = ThrottleState(
undervoltage=True,
throttled=True,
past_undervoltage=True,
past_freq_capped=True,
past_throttled=True,
)
self.assertDictEqual(
state.as_dict(),
{
"current_undervoltage": True,
"past_undervoltage": True,
"current_overheat": False,
"past_overheat": True,
"current_issue": True,
"past_issue": True,
"raw_value": -1,
},
)
+23 -5
View File
@@ -13,6 +13,7 @@ class TimelapseRenderJobTest(unittest.TestCase):
@data(
(
(
'{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
"/path/to/ffmpeg",
25,
"10000k",
@@ -22,10 +23,25 @@ class TimelapseRenderJobTest(unittest.TestCase):
"mpeg2video",
),
{},
'/path/to/ffmpeg -framerate 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 1 -r 25 -y -b 10000k -f vob -vf \'[in] format=yuv420p [out]\' "/path/to/output.mpg"',
'/path/to/ffmpeg -r 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 1 -b 10000k -f vob -y -vf \'[in] format=yuv420p [out]\' "/path/to/output.mpg"',
),
(
(
'{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y -g 5 {filters} "{output}"',
"/path/to/ffmpeg",
25,
"10000k",
1,
"/path/to/input/files_%d.jpg",
"/path/to/output.mpg",
"mpeg2video",
),
{},
'/path/to/ffmpeg -r 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 1 -b 10000k -f vob -y -g 5 -vf \'[in] format=yuv420p [out]\' "/path/to/output.mpg"',
),
(
(
'{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
"/path/to/ffmpeg",
25,
"10000k",
@@ -35,10 +51,11 @@ class TimelapseRenderJobTest(unittest.TestCase):
"libx264",
),
{},
'/path/to/ffmpeg -framerate 25 -i "/path/to/input/files_%d.jpg" -vcodec libx264 -threads 1 -r 25 -y -b 10000k -f mp4 -vf \'[in] format=yuv420p [out]\' "/path/to/output.mp4"',
'/path/to/ffmpeg -r 25 -i "/path/to/input/files_%d.jpg" -vcodec libx264 -threads 1 -b 10000k -f mp4 -y -vf \'[in] format=yuv420p [out]\' "/path/to/output.mp4"',
),
(
(
'{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
"/path/to/ffmpeg",
25,
"10000k",
@@ -48,10 +65,11 @@ class TimelapseRenderJobTest(unittest.TestCase):
"mpeg2video",
),
{"hflip": True},
'/path/to/ffmpeg -framerate 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 1 -r 25 -y -b 10000k -f vob -vf \'[in] format=yuv420p,hflip [out]\' "/path/to/output.mpg"',
'/path/to/ffmpeg -r 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 1 -b 10000k -f vob -y -vf \'[in] format=yuv420p,hflip [out]\' "/path/to/output.mpg"',
),
(
(
'{ffmpeg} -r {fps} -i "{input}" -vcodec {videocodec} -threads {threads} -b {bitrate} -f {containerformat} -y {filters} "{output}"',
"/path/to/ffmpeg",
25,
"20000k",
@@ -61,13 +79,13 @@ class TimelapseRenderJobTest(unittest.TestCase):
"mpeg2video",
),
{"rotate": True, "watermark": "/path/to/watermark.png"},
'/path/to/ffmpeg -framerate 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 4 -r 25 -y -b 20000k -f vob -vf \'[in] format=yuv420p,transpose=2 [postprocessed]; movie=/path/to/watermark.png [wm]; [postprocessed][wm] overlay=10:main_h-overlay_h-10 [out]\' "/path/to/output.mpg"',
'/path/to/ffmpeg -r 25 -i "/path/to/input/files_%d.jpg" -vcodec mpeg2video -threads 4 -b 20000k -f vob -y -vf \'[in] format=yuv420p,transpose=2 [postprocessed]; movie=/path/to/watermark.png [wm]; [postprocessed][wm] overlay=10:main_h-overlay_h-10 [out]\' "/path/to/output.mpg"',
),
)
@unpack
def test_create_ffmpeg_command_string(self, args, kwargs, expected):
actual = TimelapseRenderJob._create_ffmpeg_command_string(*args, **kwargs)
self.assertEqual(actual, expected)
self.assertEqual(expected, actual)
@data(
({}, "[in] format=yuv420p [out]"),
Binary file not shown.
File diff suppressed because it is too large. Load diff
+978 -895
View File
File diff suppressed because it is too large. Load diff