From d50bca8c9e61b6a6471eb79d12d49e92449a5688 Mon Sep 17 00:00:00 2001 From: Alice Grey Date: Sat, 29 Aug 2020 13:13:27 -0500 Subject: [PATCH] Initial Python2 to Python3 Conversion Initial Python2 to Python3 Conversion using automated 2to3 tool. --- .gitignore | 2 ++ octoprint_klipper/__init__.py | 10 ++++++---- octoprint_klipper/modules/KlipperLogAnalyzer.py | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ecfcd6f..5d59104 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ dist *.egg* .DS_Store *.zip + +*.bak \ No newline at end of file diff --git a/octoprint_klipper/__init__.py b/octoprint_klipper/__init__.py index 95ad1da..d60a0ac 100644 --- a/octoprint_klipper/__init__.py +++ b/octoprint_klipper/__init__.py @@ -5,7 +5,7 @@ # # This file may be distributed under the terms of the GNU GPLv3 license. -from __future__ import absolute_import + import datetime import logging import octoprint.plugin @@ -23,7 +23,7 @@ class KlipperPlugin( octoprint.plugin.AssetPlugin, octoprint.plugin.SimpleApiPlugin, octoprint.plugin.EventHandlerPlugin): - + _parsing_response = False _message = "" @@ -93,7 +93,7 @@ class KlipperPlugin( self._settings.get(["configuration", "path"]) ) # Check for Unicode config file and convert to String, if so. - if type(data["config"]) == unicode: + if type(data["config"]) == str: data["config"] = data["config"].encode('utf-8') f = open(filepath, "w") @@ -339,10 +339,12 @@ class KlipperPlugin( def logError(self, error): self.sendMessage("log", "error", error) +__plugin_name__ = "OctoKlipper" +__plugin_pythoncompat__ = ">=2.7,<4" + def __plugin_load__(): global __plugin_implementation__ global __plugin_hooks__ - __plugin_implementation__ = KlipperPlugin() __plugin_hooks__ = { "octoprint.comm.protocol.gcode.received": __plugin_implementation__.on_parse_gcode, diff --git a/octoprint_klipper/modules/KlipperLogAnalyzer.py b/octoprint_klipper/modules/KlipperLogAnalyzer.py index 62cf520..ce8f372 100644 --- a/octoprint_klipper/modules/KlipperLogAnalyzer.py +++ b/octoprint_klipper/modules/KlipperLogAnalyzer.py @@ -83,7 +83,7 @@ class KlipperLogAnalyzer(): if last_runoff_start: runoff_samples[last_runoff_start][0] = True last_print_stall = print_stall - sample_resets = {sampletime: 1 for stall, samples in runoff_samples.values() + sample_resets = {sampletime: 1 for stall, samples in list(runoff_samples.values()) for sampletime in samples if not stall} return sample_resets @@ -143,7 +143,7 @@ class KlipperLogAnalyzer(): basetime = lasttime = data[0]['#sampletime'] for d in data: st = d['#sampletime'] - for key, (times, values) in graph_keys.items(): + for key, (times, values) in list(graph_keys.items()): val = d.get(key) if val not in (None, '0', '1'): times.append(st)