* Use json for annoucements cache
Parsing this XML file is very slow, so there's no reason to do it more
than we have to.
See 4480-2021-12-11T13:23:48-05:00.json, MainThread -> parse
On my system, this reduces the time for /plugin/announcements/channels
from 250ms CPU time to 50ms.
The rough improvment in this specific function call is from 8% to 0.32%
of total runtime.
* ♻️ Refactor json serializer
* Move back to octoprint.util.json
* Leave old encoding helper as is but add additional
one focused on serialization (with full roundtrips).
Use each as needed (primarily encoding one).
octoprint.util.encoding -> old one
octoprint.util.serializing -> new one
Each serves different purpose, we don't want
to end up with `__jsonclass__` stuff in our
API output at some point, so separate the
concerns here and allow different handling.
* Ensure wrappers are in place for backwards
compatibility (e.g. dump vs dumps).
* 🐛 Fix handling of invalid cache
We get different exceptions now and in any case just throw
*anything* away that we can't parse.
* 🎨 Use fallback typing annotation for Py3.7.{0,1}
Better solution than getting stuck to Dict only, thanks
@flaviut for the suggestion!
* 🐛 Fix bytes encoding
bytes objects are explicitly not always UTF-8, so encode them in a way
that doesn't lead to errors and encoding/decoding problems when they are
actually binary data.
Co-authored-by: Gina Häußge <gina@octoprint.org>
* pyupgrade
* various new codemods
* manual removal of Py2/3 compat imports
* manual adjustment of docs, examples, tests
* to_str is now the new to_unicode, deprecated
redirection to to_bytes has been removed
* to_native_str has been redirected to point to
to_str
* to_unicode has been redirected to point to
to_str
* atomic_write refactored to use
NamedTemporaryDirectory
* various other fixes/refactorings all over the
place
* changed model detection implementation to use device-tree
* now active if running on a Pi, regardless whether that runs OctoPi
or not
* detect undervoltage/overheat issues via vcgencmd and report back on
UI
* Don't restrict the list of compatibility values to check against
to only those we have mapped, also support unmapped more exotic
ones.
* Allow 1:1 check against sys.platform values (with startswith).
Combined with the above that allows very granular compatibility
modelling ("freebsd11", "freebsd12") if required.
* Instead of only whitelisting ("linux", "freebsd") now also black
listing is possible ("!windows").
A detected os must match all provided whitelist elements (if the
whitelist is empty that is considered always the case) and none of
the backlist elements (if the blacklist is empty that is also
considered always the case).
See the included unit tests for examples of how this works.