From a7ca3749558a263eb2b20d53d46b9522e57efa82 Mon Sep 17 00:00:00 2001 From: Matthias Urlichs Date: Tue, 5 Feb 2019 17:52:40 +0100 Subject: [PATCH] Fix additional flake8 nits --- src/octoprint/events.py | 2 +- src/octoprint/plugins/announcements/__init__.py | 2 +- src/octoprint/plugins/backup/__init__.py | 2 +- src/octoprint/printer/standard.py | 4 ++-- src/octoprint/server/__init__.py | 2 +- src/octoprint/server/util/flask.py | 2 +- src/octoprint/timelapse.py | 4 ++-- src/octoprint/util/avr_isp/stk500v2.py | 2 +- src/octoprint/util/comm.py | 2 +- src/octoprint/vendor/sockjs/tornado/session.py | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/octoprint/events.py b/src/octoprint/events.py index da0d89f8b..cae1b493d 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -377,7 +377,7 @@ class CommandTrigger(GenericEventListener): else: processedCommand = self._processCommand(command, payload) self.executeCommand(processedCommand, commandType, debug=debug) - except KeyError as e: + except KeyError: self._logger.warning("There was an error processing one or more placeholders in the following command: %s" % command) def executeCommand(self, command, commandType, debug=False): diff --git a/src/octoprint/plugins/announcements/__init__.py b/src/octoprint/plugins/announcements/__init__.py index e9257c371..da67159bf 100644 --- a/src/octoprint/plugins/announcements/__init__.py +++ b/src/octoprint/plugins/announcements/__init__.py @@ -381,7 +381,7 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin, r = requests.get(url, timeout=30) r.raise_for_status() self._logger.info("Loaded channel {} from {} in {:.2}s".format(key, config["url"], time.time() - start)) - except Exception as e: + except Exception: self._logger.exception( "Could not fetch channel {} from {}".format(key, config["url"])) return None diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 4680553f8..a41b7c41a 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -707,7 +707,7 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if callable(on_backup_done): on_backup_done(name, final_path, exclude) - except Exception as exc: + except Exception as exc: ## noqa: F841 # TODO py3: use the exception, not sys.exc_info() if callable(on_backup_error): exc_info = sys.exc_info() diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index 5b3082da4..e20b55136 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -340,7 +340,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): if not axis in PrinterInterface.valid_axes: raise ValueError("Invalid axis {}, valid axes are {}".format(axis, ", ".join(PrinterInterface.valid_axes))) - command = "G1 {}".format(" ".join(["{}{}".format(axis.upper(), amount) for axis, amount in axes.items()])) + command = "G1 {}".format(" ".join(["{}{}".format(axis.upper(), amt) for axis, amt in axes.items()])) if speed is None: printer_profile = self._printerProfileManager.get_current_or_default() @@ -936,7 +936,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): try: fileData = self._fileManager.get_metadata(FileDestinations.SDCARD if sd else FileDestinations.LOCAL, path_on_disk) - except Exception as exc: + except Exception: self._logger.exception("Error generating fileData") fileData = None if fileData is not None: diff --git a/src/octoprint/server/__init__.py b/src/octoprint/server/__init__.py index 4816b616b..036008b4b 100644 --- a/src/octoprint/server/__init__.py +++ b/src/octoprint/server/__init__.py @@ -391,7 +391,7 @@ class Server(object): try: clazz = octoprint.util.get_class(group_manager_name) groupManager = clazz() - except AttributeError as e: + except AttributeError: self._logger.exception("Could not instantiate group manager {}, " "falling back to FilebasedGroupManager!".format(group_manager_name)) groupManager = octoprint.access.groups.FilebasedGroupManager() diff --git a/src/octoprint/server/util/flask.py b/src/octoprint/server/util/flask.py index b6ca4c23b..e9f7f96e6 100644 --- a/src/octoprint/server/util/flask.py +++ b/src/octoprint/server/util/flask.py @@ -670,7 +670,7 @@ class LessSimpleCache(BaseCache): def calculate_timeout(self, timeout=None): if timeout is None: timeout = self.default_timeout - if timeout is -1: + if timeout == -1: return None return time.time() + timeout diff --git a/src/octoprint/timelapse.py b/src/octoprint/timelapse.py index 460ff38c8..187041624 100644 --- a/src/octoprint/timelapse.py +++ b/src/octoprint/timelapse.py @@ -914,7 +914,7 @@ class TimelapseRenderJob(object): for line in lines: # We should be getting the time more often, so try it first current_time = _ffmpeg_current_regex.search(line) - if current_time is not None and self._parsed_duration is not 0: + if current_time is not None and self._parsed_duration != 0: current_s = self._convert_time(*current_time.groups()) progress = current_s / float(self._parsed_duration) * 100 @@ -922,7 +922,7 @@ class TimelapseRenderJob(object): for callback in _update_callbacks: try: callback.sendRenderProgress(progress) - except Exception as ex: + except Exception: self._logger.exception("Exception while pushing render progress") else: diff --git a/src/octoprint/util/avr_isp/stk500v2.py b/src/octoprint/util/avr_isp/stk500v2.py index 455d9f375..651ad5a4a 100644 --- a/src/octoprint/util/avr_isp/stk500v2.py +++ b/src/octoprint/util/avr_isp/stk500v2.py @@ -21,7 +21,7 @@ class Stk500v2(ispBase.IspBase): self.close() try: self.serial = Serial(str(port), speed, timeout=1, writeTimeout=10000) - except SerialException as e: + except SerialException: raise ispBase.IspError("Failed to open serial port") except Exception: raise ispBase.IspError("Unexpected error while connecting to serial port:" + port + ":" + str(sys.exc_info()[0])) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 03b5704ca..62b3cae8c 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1565,7 +1565,7 @@ class MachineCom(object): now = time.time() - if line.strip() is not "": + if line.strip() != "": self._consecutive_timeouts = 0 self._timeout = self._get_new_communication_timeout() diff --git a/src/octoprint/vendor/sockjs/tornado/session.py b/src/octoprint/vendor/sockjs/tornado/session.py index c88c33c7e..7af5d586c 100644 --- a/src/octoprint/vendor/sockjs/tornado/session.py +++ b/src/octoprint/vendor/sockjs/tornado/session.py @@ -182,7 +182,7 @@ class BaseSession(object): `stats` If set to True, will update statistics after operation completes """ - raise NotImplemented() + raise NotImplementedError() def send_jsonified(self, msg, stats=True): """Send or queue outgoing message which was json-encoded before. Used by the `broadcast` @@ -193,7 +193,7 @@ class BaseSession(object): `stats` If set to True, will update statistics after operation completes """ - raise NotImplemented() + raise NotImplementedError() def broadcast(self, clients, msg): """Optimized `broadcast` implementation. Depending on type of the session, will json-encode