🎨 pre-commit update
This commit is contained in:
1 parent
dc45341303
commit
2231e81efd
42 files changed
+42
-83
No files matched your search
+10
-11
@@ -1,7 +1,9 @@
|
||||
default_language_version:
|
||||
python: python3.10
|
||||
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|scripts/|translations/|.*\.css|.*\.svg)
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.1.0
|
||||
rev: v4.4.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
@@ -14,7 +16,7 @@ repos:
|
||||
args: ["--remove"]
|
||||
exclude: "setup.py|versioneer.py|src/octoprint_setuptools/__init__.py"
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.31.0
|
||||
rev: v3.3.1
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py37-plus"]
|
||||
@@ -43,26 +45,23 @@ repos:
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 22.3.0
|
||||
rev: 23.1.0
|
||||
hooks:
|
||||
- id: black
|
||||
additional_dependencies:
|
||||
- click==8.0.4
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 3.9.2
|
||||
rev: 6.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
args: [--config=setup.cfg]
|
||||
additional_dependencies:
|
||||
- flake8-bugbear==22.3.20
|
||||
- importlib-metadata<5.0
|
||||
- flake8-bugbear
|
||||
exclude: ^(docs/)
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v2.5.1
|
||||
rev: v2.7.1
|
||||
hooks:
|
||||
- id: prettier
|
||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
||||
rev: v8.8.0
|
||||
rev: v8.34.0
|
||||
hooks:
|
||||
- id: eslint
|
||||
additional_dependencies:
|
||||
@@ -70,7 +69,7 @@ repos:
|
||||
files: \.js$
|
||||
exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/)
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.1.0
|
||||
rev: v2.2.2
|
||||
hooks:
|
||||
- id: codespell
|
||||
exclude: ^(src/octoprint/vendor/|tests/static/js/lib|tests/util/_files|tests/playwright|scripts/)
|
||||
@@ -1360,7 +1360,7 @@ octoprint.printer.sdcardupload
|
||||
to be created on the ``sdcard`` storage. ``elapsed`` is the elapsed time in seconds.
|
||||
|
||||
If the hook is going to handle the upload, it must return the (future) remote filename of the file on the ``sdcard``
|
||||
storage. If it returns ``None`` (or an otherwise falsy value), OctoPrint will interpret this as the hook not going to
|
||||
storage. If it returns ``None`` (or an otherwise false-y value), OctoPrint will interpret this as the hook not going to
|
||||
handle the file upload, in which case the next hook or - if no other hook is registered - the default implementation
|
||||
will be called.
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ cache = {}
|
||||
|
||||
class OnlineIncludeReader(LiteralIncludeReader):
|
||||
def read_file(self, filename: str, location: Any = None) -> list[str]:
|
||||
|
||||
global cache
|
||||
try:
|
||||
if filename in cache:
|
||||
|
||||
@@ -15,7 +15,7 @@ lookupfile = .versioneer-lookup
|
||||
|
||||
[flake8]
|
||||
max-line-length = 90
|
||||
extend-ignore = E203, E231, E265, E266, E402, E501, E731
|
||||
extend-ignore = E203, E231, E265, E266, E402, E501, E731, B023, B903, B904, B907, B950, W503
|
||||
select = B,C,E,F,W,T4,B9
|
||||
exclude =
|
||||
src/octoprint/vendor
|
||||
|
||||
@@ -268,7 +268,6 @@ class PermissionsMetaClass(type):
|
||||
|
||||
|
||||
class Permissions(metaclass=PermissionsMetaClass):
|
||||
|
||||
# Special permission
|
||||
ADMIN = OctoPrintPermission(
|
||||
"Admin",
|
||||
|
||||
@@ -362,7 +362,6 @@ from .systeminfo import cli as systeminfo_commands # noqa: E402
|
||||
@click.version_option(version=octoprint.__version__, allow_from_autoenv=False)
|
||||
@click.pass_context
|
||||
def octo(ctx, **kwargs):
|
||||
|
||||
if ctx.invoked_subcommand is None:
|
||||
# We have to support calling the octoprint command without any
|
||||
# sub commands to remain backwards compatible.
|
||||
|
||||
@@ -63,8 +63,8 @@ class Daemon:
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
si = open(os.devnull, encoding="utf-8")
|
||||
so = open(os.devnull, "at+", encoding="utf-8")
|
||||
se = open(os.devnull, "at+", encoding="utf-8")
|
||||
so = open(os.devnull, "a+", encoding="utf-8")
|
||||
se = open(os.devnull, "a+", encoding="utf-8")
|
||||
|
||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||
@@ -160,7 +160,7 @@ class Daemon:
|
||||
|
||||
def set_pid(self, pid):
|
||||
"""Write the pid to the pidfile."""
|
||||
with open(self.pidfile, "wt+", encoding="utf-8") as f:
|
||||
with open(self.pidfile, "w+", encoding="utf-8") as f:
|
||||
f.write(str(pid) + "\n")
|
||||
|
||||
def remove_pidfile(self):
|
||||
|
||||
@@ -167,7 +167,7 @@ class EnvironmentDetector:
|
||||
|
||||
dumped_environment = yaml.dump(environment, pretty=True).strip()
|
||||
environment_lines = "\n".join(
|
||||
map(lambda l: f"| {l}", dumped_environment.split("\n"))
|
||||
map(lambda x: f"| {x}", dumped_environment.split("\n"))
|
||||
)
|
||||
return "Detected environment is Python {} under {} ({}). Details:\n{}".format(
|
||||
environment["python"]["version"],
|
||||
|
||||
@@ -2,6 +2,5 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||
|
||||
|
||||
class FileDestinations:
|
||||
|
||||
SDCARD = "sdcard"
|
||||
LOCAL = "local"
|
||||
@@ -8,7 +8,6 @@ class TornadoAccessFilter(logging.Filter):
|
||||
status, request_line, rtt = record.args
|
||||
|
||||
if status == 409:
|
||||
|
||||
_, url, _ = request_line.split()
|
||||
u = urllib.parse.urlparse(url)
|
||||
if u.path in ("/api/printer",):
|
||||
|
||||
@@ -66,7 +66,6 @@ class OctoPrintStreamHandler(AsyncLogHandlerMixin, logging.StreamHandler):
|
||||
class TriggeredRolloverLogHandler(
|
||||
AsyncLogHandlerMixin, logging.handlers.RotatingFileHandler
|
||||
):
|
||||
|
||||
do_rollover = False
|
||||
suffix_template = "%Y-%m-%d_%H-%M-%S"
|
||||
file_pattern = re.compile(r"^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}$")
|
||||
|
||||
@@ -38,7 +38,6 @@ class ActionCommandPromptPlugin(
|
||||
octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
):
|
||||
|
||||
COMMAND = "M876"
|
||||
CAP_PROMPT_SUPPORT = "PROMPT_SUPPORT"
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class AnnouncementPlugin(
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self):
|
||||
self._cached_channel_configs = None
|
||||
|
||||
@@ -60,7 +60,6 @@ class BackupPlugin(
|
||||
octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.WizardPlugin,
|
||||
):
|
||||
|
||||
_pip_caller = None
|
||||
|
||||
_backup_in_progress = threading.Lock()
|
||||
@@ -168,7 +167,6 @@ class BackupPlugin(
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_BACKUP_ACCESS.require(403)
|
||||
def create_backup(self):
|
||||
|
||||
data = flask.request.json
|
||||
exclude = data.get("exclude", [])
|
||||
filename = self._build_backup_filename(settings=self._settings)
|
||||
@@ -922,7 +920,6 @@ class BackupPlugin(
|
||||
)
|
||||
|
||||
with cls._backup_in_progress:
|
||||
|
||||
if name is None:
|
||||
name = cls._build_backup_filename(settings)
|
||||
|
||||
@@ -971,7 +968,9 @@ class BackupPlugin(
|
||||
final_path = os.path.join(datafolder, name)
|
||||
|
||||
own_folder = datafolder
|
||||
defaults = [os.path.join(basedir, "config.yaml"),] + [
|
||||
defaults = [
|
||||
os.path.join(basedir, "config.yaml"),
|
||||
] + [
|
||||
os.path.join(basedir, folder)
|
||||
for folder in default_settings["folder"].keys()
|
||||
]
|
||||
@@ -1179,7 +1178,6 @@ class BackupPlugin(
|
||||
on_restore_start(path)
|
||||
|
||||
try:
|
||||
|
||||
with zipfile.ZipFile(path, "r") as zip:
|
||||
# read metadata
|
||||
try:
|
||||
|
||||
@@ -16,7 +16,6 @@ class CoreWizardPlugin(
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
Subwizards,
|
||||
):
|
||||
|
||||
# ~~ TemplatePlugin API
|
||||
|
||||
def get_template_configs(self):
|
||||
|
||||
@@ -42,7 +42,6 @@ class DiscoveryPlugin(
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
octoprint.plugin.SettingsPlugin,
|
||||
):
|
||||
|
||||
ssdp_multicast_addr = "239.255.255.250" # IPv6: ff0X::c
|
||||
|
||||
ssdp_multicast_port = 1900
|
||||
@@ -688,7 +687,6 @@ class DiscoveryPlugin(
|
||||
)
|
||||
|
||||
class Request(BaseHTTPRequestHandler):
|
||||
|
||||
# noinspection PyMissingConstructor
|
||||
def __init__(self, request_text):
|
||||
self.rfile = BytesIO(request_text)
|
||||
|
||||
@@ -496,8 +496,8 @@ $(function () {
|
||||
};
|
||||
|
||||
self._configureContainerElement = function (containerElement) {
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavor is to have the
|
||||
// gocde canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// Prevent the default browser action for the mouse wheel down event. The desired behavior is to have the
|
||||
// gcode canvas pan on mouse down + drag, which happens. But if we don't prevent the default action, the browser
|
||||
// will also scroll the entire page.
|
||||
containerElement.mousedown(function (event) {
|
||||
// Middle mouse button
|
||||
|
||||
@@ -23,7 +23,6 @@ class LoggingPlugin(
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
):
|
||||
|
||||
# Additional permissions hook
|
||||
|
||||
def get_additional_permissions(self):
|
||||
|
||||
@@ -114,7 +114,6 @@ class PluginManagerPlugin(
|
||||
octoprint.plugin.BlueprintPlugin,
|
||||
octoprint.plugin.EventHandlerPlugin,
|
||||
):
|
||||
|
||||
ARCHIVE_EXTENSIONS = (".zip", ".tar.gz", ".tgz", ".tar", ".gz", ".whl")
|
||||
PYTHON_EXTENSIONS = (".py",)
|
||||
JSON_EXTENSIONS = (".json",)
|
||||
@@ -1823,7 +1822,6 @@ class PluginManagerPlugin(
|
||||
additional_args = self._settings.get(["pip_args"])
|
||||
|
||||
if additional_args is not None:
|
||||
|
||||
inapplicable_arguments = self.__class__.PIP_INAPPLICABLE_ARGUMENTS.get(
|
||||
args[0], list()
|
||||
)
|
||||
|
||||
@@ -231,7 +231,6 @@ class SoftwareUpdatePlugin(
|
||||
or self._configured_checks is None
|
||||
or self._check_overlays_stale
|
||||
):
|
||||
|
||||
self._refresh_configured_checks = False
|
||||
|
||||
overlays = self._get_check_overlays()
|
||||
@@ -934,7 +933,6 @@ class SoftwareUpdatePlugin(
|
||||
return 9
|
||||
|
||||
def on_settings_migrate(self, target, current=None):
|
||||
|
||||
if current is None or current < 6:
|
||||
# up until & including config version 5 we didn't set the method parameter for the octoprint check
|
||||
# configuration
|
||||
@@ -1657,7 +1655,6 @@ class SoftwareUpdatePlugin(
|
||||
continue
|
||||
|
||||
for future in futures.as_completed(futures_to_result):
|
||||
|
||||
target, populated_check = futures_to_result[future]
|
||||
if future.exception() is not None:
|
||||
self._logger.error(
|
||||
@@ -2034,7 +2031,6 @@ class SoftwareUpdatePlugin(
|
||||
return to_be_updated, check_data
|
||||
|
||||
def _update_worker(self, checks, check_targets, force):
|
||||
|
||||
restart_type = None
|
||||
|
||||
credentials = self._settings.get(["credentials"], merged=True)
|
||||
|
||||
@@ -232,7 +232,7 @@ def _rescue_changes(git_executable, folder):
|
||||
)
|
||||
)
|
||||
|
||||
with open(patch, "wt", encoding="utf-8", errors="replace") as f:
|
||||
with open(patch, "w", encoding="utf-8", errors="replace") as f:
|
||||
for line in stdout:
|
||||
f.write(line)
|
||||
|
||||
|
||||
@@ -1817,7 +1817,7 @@ class VirtualPrinter:
|
||||
|
||||
handle = None
|
||||
try:
|
||||
handle = open(file, "wt", encoding="utf-8")
|
||||
handle = open(file, "w", encoding="utf-8")
|
||||
except Exception:
|
||||
self._send("error writing to file")
|
||||
self._writingToSdHandle = handle
|
||||
@@ -2150,7 +2150,7 @@ class VirtualEEPROM:
|
||||
else:
|
||||
# no eeprom file, make new one with defaults
|
||||
data = self.get_default_settings()
|
||||
with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file:
|
||||
with open(self._eeprom_file_path, "w", encoding="utf-8") as eeprom_file:
|
||||
eeprom_file.write(to_unicode(json.dumps(data)))
|
||||
return data
|
||||
|
||||
@@ -2261,7 +2261,7 @@ class VirtualEEPROM:
|
||||
|
||||
def save_settings(self):
|
||||
# M500 behind-the-scenes
|
||||
with open(self._eeprom_file_path, "wt", encoding="utf-8") as eeprom_file:
|
||||
with open(self._eeprom_file_path, "w", encoding="utf-8") as eeprom_file:
|
||||
eeprom_file.write(to_unicode(json.dumps(self._eeprom)))
|
||||
|
||||
def read_settings(self):
|
||||
|
||||
@@ -197,7 +197,6 @@ class PrintTimeEstimator:
|
||||
|
||||
|
||||
class TimeEstimationHelper:
|
||||
|
||||
STABLE_THRESHOLD = 0.1
|
||||
STABLE_COUNTDOWN = 250
|
||||
STABLE_ROLLING_WINDOW = 250
|
||||
|
||||
@@ -360,7 +360,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
for name, hook in self._handle_connect_hooks.items():
|
||||
try:
|
||||
if hook(
|
||||
self, port=port, baudrate=baudrate, profile=profile, *args, **kwargs
|
||||
self, *args, port=port, baudrate=baudrate, profile=profile, **kwargs
|
||||
):
|
||||
self._logger.info(f"Connect signalled as handled by plugin {name}")
|
||||
return
|
||||
@@ -403,7 +403,6 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._firmware_info = None
|
||||
|
||||
def get_transport(self, *args, **kwargs):
|
||||
|
||||
if self._comm is None:
|
||||
return None
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ class RatioEnum(str, Enum):
|
||||
|
||||
@with_attrs_docs
|
||||
class WebcamCompatibility(BaseModel):
|
||||
|
||||
streamTimeout: int = 5
|
||||
"""The timeout of the stream in seconds"""
|
||||
|
||||
@@ -43,7 +42,6 @@ class WebcamCompatibility(BaseModel):
|
||||
|
||||
@with_attrs_docs
|
||||
class Webcam(BaseModel):
|
||||
|
||||
name: str
|
||||
"""Identifier of this webcam"""
|
||||
|
||||
|
||||
@@ -2726,10 +2726,10 @@ class Server:
|
||||
permission = PluginOctoPrintPermission(
|
||||
permission_name(plugin_info.name, definition),
|
||||
description,
|
||||
*roles_and_permissions,
|
||||
plugin=plugin_info.key,
|
||||
dangerous=dangerous,
|
||||
default_groups=default_groups,
|
||||
*roles_and_permissions,
|
||||
)
|
||||
setattr(
|
||||
octoprint.access.permissions.Permissions,
|
||||
@@ -2737,10 +2737,10 @@ class Server:
|
||||
PluginOctoPrintPermission(
|
||||
permission_name(plugin_info.name, definition),
|
||||
description,
|
||||
*roles_and_permissions,
|
||||
plugin=plugin_info.key,
|
||||
dangerous=dangerous,
|
||||
default_groups=default_groups,
|
||||
*roles_and_permissions,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ def uploadLanguagePack():
|
||||
@no_firstrun_access
|
||||
@Permissions.SETTINGS.require(403)
|
||||
def deleteInstalledLanguagePack(locale, pack):
|
||||
|
||||
if pack == "_core":
|
||||
target_path = os.path.join(settings().getBaseFolder("translations"), locale)
|
||||
else:
|
||||
|
||||
@@ -274,7 +274,6 @@ class ReverseProxiedEnvironment:
|
||||
server=None,
|
||||
port=None,
|
||||
):
|
||||
|
||||
# sensible defaults
|
||||
if header_prefix is None:
|
||||
header_prefix = ["x-script-name", "x-forwarded-prefix"]
|
||||
@@ -1720,7 +1719,6 @@ class PluginAssetResolver(flask_assets.FlaskResolver):
|
||||
|
||||
|
||||
class SettingsCheckUpdater(webassets.updater.BaseUpdater):
|
||||
|
||||
updater = "always"
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -77,7 +77,6 @@ class PrinterStateConnection(
|
||||
LoginStatusListener,
|
||||
GroupChangeListener,
|
||||
):
|
||||
|
||||
_event_permissions = {
|
||||
Events.USER_LOGGED_IN: [Permissions.ADMIN],
|
||||
Events.USER_LOGGED_OUT: [Permissions.ADMIN],
|
||||
|
||||
@@ -92,7 +92,6 @@ def fix_websocket_check_origin():
|
||||
|
||||
|
||||
class RequestlessExceptionLoggingMixin(tornado.web.RequestHandler):
|
||||
|
||||
LOG_REQUEST = False
|
||||
|
||||
def log_exception(self, typ, value, tb, *args, **kwargs):
|
||||
@@ -1616,7 +1615,6 @@ class SystemInfoBundleHandler(CorsSupportMixin, tornado.web.RequestHandler):
|
||||
|
||||
|
||||
class GlobalHeaderTransform(tornado.web.OutputTransform):
|
||||
|
||||
HEADERS = {}
|
||||
FORCED_HEADERS = {}
|
||||
REMOVED_HEADERS = []
|
||||
|
||||
@@ -966,7 +966,6 @@ class Settings:
|
||||
self.remove_overlay(key)
|
||||
|
||||
if deprecated is not None:
|
||||
|
||||
self._logger.debug(
|
||||
f"Marking all (recursive) paths in this overlay as deprecated: {overlay}"
|
||||
)
|
||||
@@ -2114,7 +2113,7 @@ def _validate_folder(folder, create=True, check_writable=True, deep_check_writab
|
||||
# to determine whether things are *actually* writable
|
||||
testfile = os.path.join(folder, ".testballoon.txt")
|
||||
try:
|
||||
with open(testfile, "wt", encoding="utf-8") as f:
|
||||
with open(testfile, "w", encoding="utf-8") as f:
|
||||
f.write("test")
|
||||
os.remove(testfile)
|
||||
except Exception:
|
||||
|
||||
@@ -23,7 +23,6 @@ def system_command_manager():
|
||||
|
||||
|
||||
class SystemCommandManager:
|
||||
|
||||
SERVER_RESTART_COMMAND = "serverRestartCommand"
|
||||
SYSTEM_RESTART_COMMAND = "systemRestartCommand"
|
||||
SYSTEM_SHUTDOWN_COMMAND = "systemShutdownCommand"
|
||||
|
||||
@@ -536,7 +536,7 @@ class Timelapse:
|
||||
eventManager().subscribe(Events.PRINT_FAILED, self.on_print_done)
|
||||
eventManager().subscribe(Events.PRINT_DONE, self.on_print_done)
|
||||
eventManager().subscribe(Events.PRINT_RESUMED, self.on_print_resumed)
|
||||
for (event, callback) in self.event_subscriptions():
|
||||
for event, callback in self.event_subscriptions():
|
||||
eventManager().subscribe(event, callback)
|
||||
|
||||
@property
|
||||
@@ -560,7 +560,7 @@ class Timelapse:
|
||||
eventManager().unsubscribe(Events.PRINT_FAILED, self.on_print_done)
|
||||
eventManager().unsubscribe(Events.PRINT_DONE, self.on_print_done)
|
||||
eventManager().unsubscribe(Events.PRINT_RESUMED, self.on_print_resumed)
|
||||
for (event, callback) in self.event_subscriptions():
|
||||
for event, callback in self.event_subscriptions():
|
||||
eventManager().unsubscribe(event, callback)
|
||||
|
||||
def on_print_started(self, event, payload):
|
||||
@@ -951,7 +951,6 @@ class TimedTimelapse(Timelapse):
|
||||
|
||||
|
||||
class TimelapseRenderJob:
|
||||
|
||||
render_job_lock = threading.RLock()
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -881,7 +881,6 @@ def dict_filter(dictionary, filter_function):
|
||||
# Source: http://stackoverflow.com/a/6190500/562769
|
||||
class DefaultOrderedDict(collections.OrderedDict):
|
||||
def __init__(self, default_factory=None, *a, **kw):
|
||||
|
||||
if default_factory is not None and not callable(default_factory):
|
||||
raise TypeError("first argument must be callable")
|
||||
collections.OrderedDict.__init__(self, *a, **kw)
|
||||
|
||||
@@ -2717,7 +2717,6 @@ class MachineCom:
|
||||
or line.startswith("T0:")
|
||||
or ((" B:" in line or line.startswith("B:")) and "A:" not in line)
|
||||
):
|
||||
|
||||
if (
|
||||
not disable_external_heatup_detection
|
||||
and not self._temperature_autoreporting
|
||||
@@ -3052,7 +3051,6 @@ class MachineCom:
|
||||
else:
|
||||
self._consecutive_not_sd_printing = 0
|
||||
if self.isSdFileSelected():
|
||||
|
||||
# If we are not yet sd printing, the current does not equal the total, is larger
|
||||
# than zero and has increased since the last time we saw a position report, then
|
||||
# yes, this looks like we just started printing due to an external trigger.
|
||||
@@ -4488,7 +4486,7 @@ class MachineCom:
|
||||
enqueued_something = False
|
||||
|
||||
# process all but the last ...
|
||||
for (cmd, cmd_type, gcode, subcode, tags) in results:
|
||||
for cmd, cmd_type, gcode, subcode, tags in results:
|
||||
enqueued_something = (
|
||||
process(cmd, cmd_type, gcode, subcode, tags=tags)
|
||||
or enqueued_something
|
||||
|
||||
@@ -219,7 +219,6 @@ def is_prerelease(version):
|
||||
|
||||
|
||||
def normalize_version(version):
|
||||
|
||||
# Debian has the python version set to 2.7.15+ which is not PEP440 compliant (bug 914072)
|
||||
if version.endswith("+"):
|
||||
version = version[:-1]
|
||||
|
||||
@@ -31,7 +31,7 @@ def load_from_file(
|
||||
def _save_to_file_base(data, file=None, path=None, pretty=False, **kwargs):
|
||||
if path is not None:
|
||||
assert file is None
|
||||
with open(path, "wt", encoding="utf-8") as f:
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
return _save_to_file_base(data, file=f, pretty=pretty, **kwargs)
|
||||
|
||||
if file is not None:
|
||||
|
||||
@@ -833,7 +833,7 @@ class LocalStorageTest(unittest.TestCase):
|
||||
# prepare
|
||||
import yaml
|
||||
|
||||
with open(yaml_path, "wt") as f:
|
||||
with open(yaml_path, "w") as f:
|
||||
yaml.safe_dump(metadata, f)
|
||||
|
||||
# migrate
|
||||
|
||||
@@ -34,7 +34,7 @@ def _load_yaml(fname):
|
||||
|
||||
|
||||
def _dump_yaml(fname, config):
|
||||
with open(fname, "wt", encoding="utf-8") as f:
|
||||
with open(fname, "w", encoding="utf-8") as f:
|
||||
yaml.safe_dump(config, f)
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ class ExpectedExit(BaseException):
|
||||
|
||||
class DaemonTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
||||
run_method = mock.MagicMock()
|
||||
echo_method = mock.MagicMock()
|
||||
error_method = mock.MagicMock()
|
||||
@@ -19,10 +18,10 @@ class DaemonTest(unittest.TestCase):
|
||||
def run(self):
|
||||
run_method()
|
||||
|
||||
def echo(cls, line):
|
||||
def echo(self, line):
|
||||
echo_method(line)
|
||||
|
||||
def error(cls, line):
|
||||
def error(self, line):
|
||||
error_method(line)
|
||||
|
||||
self.pidfile = "/my/pid/file"
|
||||
@@ -132,8 +131,8 @@ class DaemonTest(unittest.TestCase):
|
||||
mock_open.mock_calls,
|
||||
[
|
||||
mock.call(mock_devnull, encoding="utf-8"),
|
||||
mock.call(mock_devnull, "at+", encoding="utf-8"),
|
||||
mock.call(mock_devnull, "at+", encoding="utf-8"),
|
||||
mock.call(mock_devnull, "a+", encoding="utf-8"),
|
||||
mock.call(mock_devnull, "a+", encoding="utf-8"),
|
||||
],
|
||||
)
|
||||
self.assertListEqual(
|
||||
@@ -448,7 +447,7 @@ class DaemonTest(unittest.TestCase):
|
||||
self.daemon.set_pid(pid)
|
||||
|
||||
# assert
|
||||
m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8")
|
||||
m.assert_called_once_with(self.pidfile, "w+", encoding="utf-8")
|
||||
handle = m()
|
||||
handle.write.assert_called_once_with(f"{pid}\n")
|
||||
|
||||
@@ -461,7 +460,7 @@ class DaemonTest(unittest.TestCase):
|
||||
self.daemon.set_pid(pid)
|
||||
|
||||
# assert
|
||||
m.assert_called_once_with(self.pidfile, "wt+", encoding="utf-8")
|
||||
m.assert_called_once_with(self.pidfile, "w+", encoding="utf-8")
|
||||
handle = m()
|
||||
handle.write.assert_called_once_with(f"{pid}\n")
|
||||
|
||||
|
||||
@@ -129,7 +129,6 @@ class TimelapseTest(unittest.TestCase):
|
||||
|
||||
@mock.patch("os.scandir")
|
||||
def test_get_finished_timelapses(self, mock_listdir):
|
||||
|
||||
## prepare
|
||||
|
||||
mocked_path = "/path/to/timelapse"
|
||||
@@ -215,7 +214,6 @@ class TimelapseTest(unittest.TestCase):
|
||||
return result
|
||||
|
||||
def test_ffmpeg_parse(self):
|
||||
|
||||
# Test strings
|
||||
noChange1Str = " built on Jan 7 2014 22:07:02 with gcc 4.8.2 (GCC)"
|
||||
durationStr = (
|
||||
|
||||
@@ -548,7 +548,7 @@ class IsHiddenPathTest(unittest.TestCase):
|
||||
"path_always_hidden",
|
||||
):
|
||||
path = getattr(self, attr)
|
||||
with open(path, "wt+", encoding="utf-8") as f:
|
||||
with open(path, "w+", encoding="utf-8") as f:
|
||||
f.write(attr)
|
||||
|
||||
if sys.platform == "win32":
|
||||
|
||||
Reference in new issue
Block a user