It turns out the issues we had with the less helpful
JS error output under Firefox was simply due to
the error message not being included in the
stack trace, vs Chrome where it is.
Solved this by always including the message.
Also iron out a bunch of other warnings.
Heads-up: This upgrades Jinja, werkzeug and itsdangerous as well!
Jinja 3 is not fully backwards compatible to 2
due to a bug fix we so far pinned to an old
version for. It's time to stop doing that
with OctoPrint 2.0.0. Should only affect plugins that
are still trying to access variables defined in
an outer scope in an inner scope, as deemed
an unintentional behaviour in pallets/jinja#641
and removed in Jinja 2.9. It's easy to solve
by switching to using assignments, see
https://jinja.palletsprojects.com/en/3.0.x/templates/#assignments.
This allows browsers and other clients to calculate download progress
and detect if the download fails (they get less data than expected).
This is most useful when downloading multiple timelapses due to their
potential size.
Also fixes an oversight where the printer's firmware wasn't being added
to `systeminfo.txt` when downloading system info.
We now need to explicitly trigger a write to config.yaml to test proper
creation at the right places since we no longer will automatically
generate a global API key - that has been removed.
/*! loglevel - v1.7.0 - https://github.com/pimterry/loglevel - (c) 2020 Tim Perry - licensed MIT */
!function(a,b){"use strict";"function"==typeofdefine&&define.amd?define(b):"object"==typeofmodule&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";functiona(a,b){varc=a[b];if("function"==typeofc.bind)returnc.bind(a);try{returnFunction.prototype.bind.call(c,a)}catch(b){returnfunction(){returnFunction.prototype.apply.apply(c,[a,arguments])}}}functionb(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}functionc(c){return"debug"===c&&(c="log"),typeofconsole!==i&&("trace"===c&&j?b:void0!==console[c]?a(console,c):void0!==console.log?a(console,"log"):h)}functiond(a,b){for(varc=0;c<k.length;c++){vard=k[c];this[d]=c<a?h:this.methodFactory(d,a,b)}this.log=this.debug}functione(a,b,c){returnfunction(){typeofconsole!==i&&(d.call(this,b,c),this[a].apply(this,arguments))}}functionf(a,b,d){returnc(a)||e.apply(this,arguments)}functiong(a,b,c){functione(a){varb=(k[a]||"silent").toUpperCase();if(typeofwindow!==i&&l){try{returnvoid(window.localStorage[l]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(l)+"="+b+";"}catch(a){}}}functiong(){vara;if(typeofwindow!==i&&l){try{a=window.localStorage[l]}catch(a){}if(typeofa===i)try{varb=window.document.cookie,c=b.indexOf(encodeURIComponent(l)+"=");-1!==c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}returnvoid0===j.levels[a]&&(a=void0),a}}varh,j=this,l="loglevel";"string"==typeofa?l+=":"+a:"symbol"==typeofa&&(l=void0),j.name=a,j.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},j.methodFactory=c||f,j.getLevel=function(){returnh},j.setLevel=function(b,c){if("string"==typeofb&&void0!==j.levels[b.toUpperCase()]&&(b=j.levels[b.toUpperCase()]),!("number"==typeofb&&b>=0&&b<=j.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(h=b,!1!==c&&e(b),d.call(j,b,a),typeofconsole===i&&b<j.levels.SILENT)return"No console available for logging"},j.setDefaultLevel=function(a){g()||j.setLevel(a,!1)},j.enableAll=function(a){j.setLevel(j.levels.TRACE,a)},j.disableAll=function(a){j.setLevel(j.levels.SILENT,a)};varm=g();null==m&&(m=null==b?"WARN":b),j.setLevel(m,!1)}varh=function(){},i="undefined",j=typeofwindow!==i&&typeofwindow.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),k=["trace","debug","info","warn","error"],l=newg,m={};l.getLogger=function(a){if("symbol"!=typeofa&&"string"!=typeofa||""===a)thrownewTypeError("You must supply a name when creating a logger.");varb=m[a];returnb||(b=m[a]=newg(a,l.getLevel(),l.methodFactory)),b};varn=typeofwindow!==i?window.log:void0;returnl.noConflict=function(){returntypeofwindow!==i&&window.log===l&&(window.log=n),l},l.getLoggers=function(){returnm},l.default=l,l});
/*! loglevel - v1.8.1 - https://github.com/pimterry/loglevel - (c) 2022 Tim Perry - licensed MIT */
!function(a,b){"use strict";"function"==typeofdefine&&define.amd?define(b):"object"==typeofmodule&&module.exports?module.exports=b():a.log=b()}(this,function(){"use strict";functiona(a,b){varc=a[b];if("function"==typeofc.bind)returnc.bind(a);try{returnFunction.prototype.bind.call(c,a)}catch(b){returnfunction(){returnFunction.prototype.apply.apply(c,[a,arguments])}}}functionb(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}functionc(c){return"debug"===c&&(c="log"),typeofconsole!==i&&("trace"===c&&j?b:void0!==console[c]?a(console,c):void0!==console.log?a(console,"log"):h)}functiond(a,b){for(varc=0;c<k.length;c++){vard=k[c];this[d]=c<a?h:this.methodFactory(d,a,b)}this.log=this.debug}functione(a,b,c){returnfunction(){typeofconsole!==i&&(d.call(this,b,c),this[a].apply(this,arguments))}}functionf(a,b,d){returnc(a)||e.apply(this,arguments)}functiong(a,b,c){functione(a){varb=(k[a]||"silent").toUpperCase();if(typeofwindow!==i&&m){try{returnvoid(window.localStorage[m]=b)}catch(a){}try{window.document.cookie=encodeURIComponent(m)+"="+b+";"}catch(a){}}}functiong(){vara;if(typeofwindow!==i&&m){try{a=window.localStorage[m]}catch(a){}if(typeofa===i)try{varb=window.document.cookie,c=b.indexOf(encodeURIComponent(m)+"=");-1!==c&&(a=/^([^;]+)/.exec(b.slice(c))[1])}catch(a){}returnvoid0===l.levels[a]&&(a=void0),a}}functionh(){if(typeofwindow!==i&&m){try{returnvoidwindow.localStorage.removeItem(m)}catch(a){}try{window.document.cookie=encodeURIComponent(m)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(a){}}}varj,l=this;b=null==b?"WARN":b;varm="loglevel";"string"==typeofa?m+=":"+a:"symbol"==typeofa&&(m=void0),l.name=a,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=c||f,l.getLevel=function(){returnj},l.setLevel=function(b,c){if("string"==typeofb&&void0!==l.levels[b.toUpperCase()]&&(b=l.levels[b.toUpperCase()]),!("number"==typeofb&&b>=0&&b<=l.levels.SILENT))throw"log.setLevel() called with invalid level: "+b;if(j=b,!1!==c&&e(b),d.call(l,b,a),typeofconsole===i&&b<l.levels.SILENT)return"No console available for logging"},l.setDefaultLevel=function(a){b=a,g()||l.setLevel(a,!1)},l.resetLevel=function(){l.setLevel(b,!1),h()},l.enableAll=function(a){l.setLevel(l.levels.TRACE,a)},l.disableAll=function(a){l.setLevel(l.levels.SILENT,a)};varn=g();null==n&&(n=b),l.setLevel(n,!1)}varh=function(){},i="undefined",j=typeofwindow!==i&&typeofwindow.navigator!==i&&/Trident\/|MSIE /.test(window.navigator.userAgent),k=["trace","debug","info","warn","error"],l=newg,m={};l.getLogger=function(a){if("symbol"!=typeofa&&"string"!=typeofa||""===a)thrownewTypeError("You must supply a name when creating a logger.");varb=m[a];returnb||(b=m[a]=newg(a,l.getLevel(),l.methodFactory)),b};varn=typeofwindow!==i?window.log:void0;returnl.noConflict=function(){returntypeofwindow!==i&&window.log===l&&(window.log=n),l},l.getLoggers=function(){returnm},l.default=l,l});
@@ -206,9 +206,12 @@ class TestAtomicWrite(unittest.TestCase):
mock_ntf.return_value=mock_file
mock_exists.return_value=False
umask=0o026
# test
withoctoprint.util.atomic_write(targetpath)asf:
f.write("test")
withmock.patch("octoprint.util.UMASK",umask):
withoctoprint.util.atomic_write(targetpath)asf:
f.write("test")
# assert
mock_ntf.assert_called_once_with(
@@ -227,7 +230,7 @@ class TestAtomicWrite(unittest.TestCase):
deftest_atomic_write_rel_path_aware(
self,mock_exists,mock_chmod,mock_ntf,mock_move
):
"""Tests whether the tempoary file is to created in the same directory as the target file. This time submitting a relative path."""
"""Tests whether the temporary file is to created in the same directory as the target file. This time submitting a relative path."""
# setup
tmpdirpath="../test"
@@ -240,9 +243,12 @@ class TestAtomicWrite(unittest.TestCase):
mock_ntf.return_value=mock_file
mock_exists.return_value=False
umask=0o026
# test
withoctoprint.util.atomic_write(targetpath)asf:
f.write("test")
withmock.patch("octoprint.util.UMASK",umask):
withoctoprint.util.atomic_write(targetpath)asf:
f.write("test")
# assert
mock_ntf.assert_called_once_with(
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.