Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2022-08-02 15:43:35 +02:00
commit e524da88d6
15 files changed
+93 -99

No files matched your search

+10 -10
View File
@@ -1,10 +1,10 @@
<!--
Thank you for your interest into contributing to OctoPrint, it's
Thank you for your interest in contributing to OctoPrint, it's
highly appreciated!
Please make sure you have read the "guidelines for contributing" as
linked just above this form, there's a section on Pull Requests in there
as well that contains important information.
as well which contains important information.
As a summary, please make sure you have ticked all points on this
checklist:
@@ -16,25 +16,25 @@ checklist:
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
* [ ] Your PR targets OctoPrint's devel branch if it's a completely
new feature, or maintenance if it's a bug fix or improvement of
* [ ] Your PR targets OctoPrint's `devel` branch if it's a completely
new feature, or `maintenance` if it's a bug fix or improvement of
existing functionality for the current stable version (no PRs
against master or anything else please)
against `master` or anything else please)
* [ ] Your PR was opened from a custom branch on your repository
(no PRs from your version of master, maintenance or devel please),
e.g. dev/my_new_feature or fix/my_bugfix
(no PRs from your version of `master`, `maintenance`, or `devel`
please), e.g. `dev/my_new_feature` or `fix/my_bugfix`
* [ ] Your PR only contains relevant changes: no unrelated files,
no dead code, ideally only one commit - rebase and squash your PR
if necessary!
* [ ] Your changes follow the existing coding style
* [ ] If your changes include style sheets: You have modified the
.less source files, not the .css files (those are generated with
lessc)
`.less` source files, not the `.css` files (those are generated
with `lessc`)
* [ ] You have tested your changes (please state how!) - ideally you
have added unit tests
* [ ] You have run the existing unit tests against your changes and
nothing broke
* [ ] You have added yourself to the AUTHORS.md file :)
* [ ] You have added yourself to the `AUTHORS.md` file :)
<!--
Describe your PR further using the template provided below. The more
+1
View File
@@ -168,6 +168,7 @@ date of first contribution):
* [Zack Lewis](https://github.com/lima3w)
* [Billy Richardson](https://github.com/richardsondev)
* [Christian Bianchini](https://github.com/max246)
* [Kestin Goforth](https://github.com/kforth)
OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by
[Daid Braam](https://github.com/daid). Parts of its communication layer and
+4 -5
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
__author__ = "Gina Häußge <osd@foosel.net>"
__license__ = "The MIT License <http://opensource.org/licenses/MIT>"
__copyright__ = "Copyright (C) 2015 Gina Häußge - Released under terms of the MIT License"
@@ -17,9 +19,7 @@ from pygments.filters import VisibleWhitespaceFilter, ErrorToken
from pygments.lexers.python import PythonConsoleLexer
from pygments.util import ClassNotFound
if False:
# For type annotation
from typing import Any, Dict, List, Tuple # NOQA
from typing import Any
def _merge_dict(a, b):
@@ -72,8 +72,7 @@ class CodeBlockExt(CodeBlock):
option_spec = _merge_dict(CodeBlock.option_spec, {"whitespace": directives.flag})
def run(self):
# type: () -> List[nodes.Node]
def run(self) -> list[nodes.Node]:
# get result from parent implementation
code_block = CodeBlock.run(self)
+5 -7
View File
@@ -1,3 +1,5 @@
from __future__ import annotations
__author__ = "Gina Häußge <osd@foosel.net>"
__license__ = "The MIT License <http://opensource.org/licenses/MIT>"
__copyright__ = "Copyright (C) 2015 Gina Häußge - Released under terms of the MIT License"
@@ -18,16 +20,13 @@ from sphinx.directives.code import (
)
from sphinx.util.nodes import set_source_info
if False:
# For type annotation
from typing import Any, List # NOQA
from typing import Any
cache = {}
class OnlineIncludeReader(LiteralIncludeReader):
def read_file(self, filename, location=None):
# type: (unicode, Any) -> List[unicode]
def read_file(self, filename: str, location: Any = None) -> list[str]:
global cache
try:
@@ -53,8 +52,7 @@ class OnlineIncludeReader(LiteralIncludeReader):
class OnlineIncludeDirective(LiteralInclude):
def run(self):
# type: () -> List[nodes.Node]
def run(self) -> list[nodes.Node]:
document = self.state.document
if not document.settings.file_insertion_enabled:
return [
+39 -64
View File
@@ -262,55 +262,38 @@ class OctoPrintDevelCommands(click.MultiCommand):
"--list", "list_files", is_flag=True, help="List all available files and exit"
)
def command(files, all_files, list_files):
import os.path
import shutil
from pathlib import Path
available_files = {
"core": {
"source": "static/less/octoprint.less",
"output": "static/css/octoprint.css",
},
"login": {
"source": "static/less/login.less",
"output": "static/css/login.css",
},
"recovery": {
"source": "static/less/recovery.less",
"output": "static/css/recovery.css",
},
"plugin_announcements": {
"source": "plugins/announcements/static/less/announcements.less",
"output": "plugins/announcements/static/css/announcements.css",
},
"plugin_appkeys_core": {
"source": "plugins/appkeys/static/less/appkeys.less",
"output": "plugins/appkeys/static/css/appkeys.css",
},
"plugin_appkeys_authdialog": {
"source": "plugins/appkeys/static/less/authdialog.less",
"output": "plugins/appkeys/static/css/authdialog.css",
},
"plugin_backup": {
"source": "plugins/backup/static/less/backup.less",
"output": "plugins/backup/static/css/backup.css",
},
"plugin_gcodeviewer": {
"source": "plugins/gcodeviewer/static/less/gcodeviewer.less",
"output": "plugins/gcodeviewer/static/css/gcodeviewer.css",
},
"plugin_logging": {
"source": "plugins/logging/static/less/logging.less",
"output": "plugins/logging/static/css/logging.css",
},
"plugin_pluginmanager": {
"source": "plugins/pluginmanager/static/less/pluginmanager.less",
"output": "plugins/pluginmanager/static/css/pluginmanager.css",
},
"plugin_softwareupdate": {
"source": "plugins/softwareupdate/static/less/softwareupdate.less",
"output": "plugins/softwareupdate/static/css/softwareupdate.css",
},
}
# src/octoprint
octoprint_base = Path(__file__).parent.parent
available_files = {}
for less_file in Path(octoprint_base, "static", "less").glob("*.less"):
# Check corresponding css file exists
# Less files can be imported, not all need building
css_file = Path(less_file.parent.parent, "css", f"{less_file.stem}.css")
if css_file.exists():
available_files[less_file.stem] = {
"source": str(less_file),
"output": str(css_file),
}
path_to_plugins = Path(octoprint_base, "plugins")
for plugin in Path(path_to_plugins).iterdir():
for less_file in Path(plugin, "static", "less").glob("*.less"):
name = f"plugin_{plugin.name}"
if less_file.stem != plugin.name:
name += f"_{less_file.stem}"
# Check there is a corresponding CSS file first
css_file = Path(
less_file.parent.parent, "css", f"{less_file.stem}.css"
)
if css_file.exists():
available_files[name] = {
"source": str(less_file),
"output": str(css_file),
}
if list_files:
click.echo("Available files to build:")
@@ -329,7 +312,6 @@ class OctoPrintDevelCommands(click.MultiCommand):
# Check that lessc is installed
less = shutil.which("lessc")
if not less:
click.echo(
"lessc is not installed/not available, please install it first"
@@ -339,26 +321,19 @@ class OctoPrintDevelCommands(click.MultiCommand):
)
sys.exit(1)
# Find the folder of the `octoprint` package
# Two folders up from this file
octoprint = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
for file in files:
if file not in available_files.keys():
click.echo(f"Unknown file {file}")
for less_file in files:
if less_file not in available_files.keys():
click.echo(f"Unknown file {less_file}")
sys.exit(1)
source_path = os.path.join(octoprint, available_files[file]["source"])
output_path = os.path.join(octoprint, available_files[file]["output"])
# Check the target file exists
if not os.path.exists(source_path):
click.echo(f"Target file {source_path} does not exist")
continue
# Build command line, with necessary options
# TODO -x is deprecated, find replacement?
less_command = [less, "-x", source_path, output_path]
less_command = [
less,
"-x",
available_files[less_file]["source"],
available_files[less_file]["output"],
]
self.command_caller.call(less_command)
+2 -2
View File
@@ -164,7 +164,7 @@ class StorageInterface:
:param string path: the path of the new folder
:param bool ignore_existing: if set to True, no error will be raised if the folder to be added already exists
:param unicode display: display name of the folder
:param str display: display name of the folder
:return: the sanitized name of the new folder to be used for future references to the folder
"""
raise NotImplementedError()
@@ -220,7 +220,7 @@ class StorageInterface:
:param list links: any links to add with the file
:param bool allow_overwrite: if set to True no error will be raised if the file already exists and the existing file
and its metadata will just be silently overwritten
:param unicode display: display name of the file
:param str display: display name of the file
:return: the sanitized name of the file to be used for future references to it
"""
raise NotImplementedError()
@@ -480,8 +480,10 @@ var doParse = function () {
center_j = Number(args[j].slice(1));
break;
case "g":
if (args[j].charAt(1).toLowerCase() === "2") direction = -1;
if (args[j].charAt(1).toLowerCase() === "3") direction = 1;
if (args[j].charAt(1) === "2" || args[j].charAt(2) === "2")
direction = -1;
else if (args[j].charAt(1) === "3" || args[j].charAt(2) === "3")
direction = 1;
break;
}
}
@@ -711,6 +711,13 @@ class SoftwareUpdatePlugin(
def on_settings_load(self):
# ensure we don't persist check configs we receive on the API
data = dict(octoprint.plugin.SettingsPlugin.on_settings_load(self))
# set credentials flag
credentials = self._settings.get(["credentials"])
data["credentials"] = {}
for key, value in credentials.items():
data["credentials"][f"{key}_set"] = bool(value)
if "checks" in data:
del data["checks"]
@@ -65,6 +65,7 @@ $(function () {
self.config_pipEnableCheck = ko.observable();
self.config_minimumFreeStorage = ko.observable();
self.config_githubToken = ko.observable();
self.config_githubTokenSet = ko.observable(false);
self.error_checkoutFolder = ko.pureComputed(function () {
return (
@@ -334,6 +335,10 @@ $(function () {
self.config_minimumFreeStorage(
self.settings.settings.plugins.softwareupdate.minimum_free_storage()
);
self.config_githubTokenSet(
self.settings.settings.plugins.softwareupdate.credentials.github_set()
);
};
self._copyConfigBack = function () {
@@ -1,7 +1,12 @@
<div class="control-group">
<label class="control-label">{{ _('GitHub Access Token') }}</label>
<div class="controls">
<!-- ko if : config_githubTokenSet -->
<input type="text" class="input-block-level" data-bind="value: config_githubToken" placeholder="{{ _('Token entered but hidden for privacy reasons')|edq }}">
<!-- /ko -->
<!-- ko ifnot : config_githubTokenSet -->
<input type="text" class="input-block-level" data-bind="value: config_githubToken" placeholder="{{ _('Enter a new token...')|edq }}">
<!-- /ko -->
<span class="help-block">{{ _('Set this if you keep running into rate limiting issues. <a href="%(url)s" target="_blank" rel="noopener noreferer">See here for how to obtain a token</a>.', url="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token") }}</span>
</div>
</div>
@@ -38,9 +38,7 @@ def _git(args, cwd, hide_stderr=False):
else:
return None, None
stdout = p.communicate()[0].strip()
if sys.version >= "3":
stdout = stdout.decode()
stdout = p.communicate()[0].strip().decode()
if p.returncode != 0:
return p.returncode, None
+1 -1
View File
@@ -6,7 +6,7 @@ import base64
import logging
import sys
PY3 = sys.version_info[0] == 3 # should now always be true, kept for plugins
PY3 = sys.version_info >= (3, 0) # should now always be True, kept for plugins
import flask as _flask
import flask_login
+1 -1
View File
@@ -265,7 +265,7 @@ class ReverseProxiedEnvironment:
# sensible defaults
if header_prefix is None:
header_prefix = ["x-script-name"]
header_prefix = ["x-script-name", "x-forwarded-prefix"]
if header_scheme is None:
header_scheme = ["x-forwarded-proto", "x-scheme"]
if header_host is None:
+2 -3
View File
@@ -77,7 +77,7 @@ def to_unicode(
s_or_u: Union[str, bytes], encoding: str = "utf-8", errors: str = "strict"
) -> str:
"""
Make sure ``s_or_u`` is a unicode string (str).
Make sure ``s_or_u`` is a string (str).
Arguments:
s_or_u (str or bytes): The value to convert
@@ -202,7 +202,6 @@ def warning_factory(warning_type):
"__dict__",
"__doc__",
"__str__",
"__unicode__",
"__repr__",
"__getattribute__",
"__setattr__",
@@ -1618,7 +1617,7 @@ class CaseInsensitiveSet(Set):
"""
Basic case insensitive set
Any str or unicode values will be stored and compared in lower case. Other value types are left as-is.
Any str values will be stored and compared in lower case. Other value types are left as-is.
"""
def __init__(self, *args):
+6 -1
View File
@@ -587,8 +587,13 @@ class gcode:
else:
e = 0
# calculate 3d arc length
arcLengthXYZ = math.sqrt(
(oldPos.z - pos.z) ** 2 + ((endAngle - startAngle) * r) ** 2
)
# move time in x, y, z, will be 0 if no movement happened
moveTimeXYZ = abs((oldPos - pos).length / feedrate)
moveTimeXYZ = abs(arcLengthXYZ / feedrate)
# time needed for extruding, will be 0 if no extrusion happened
extrudeTime = abs(e / feedrate)