From c751dcfcf915a67b87306ac0e6a8e93e683a3668 Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Tue, 14 Nov 2023 00:48:01 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Python=20;=20cleanup=20(#26426)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ftdi_eve_lib/scripts/file2cpp.py | 2 +- .../ftdi_eve_lib/scripts/font2cpp.py | 2 +- .../ftdi_eve_lib/scripts/img2cpp.py | 8 +++---- .../share/PlatformIO/scripts/chitu_crypt.py | 6 ++--- .../share/PlatformIO/scripts/configuration.py | 2 +- .../scripts/fix_framework_weakness.py | 2 +- .../jgaurora_a5s_a1_with_bootloader.py | 2 +- buildroot/share/PlatformIO/scripts/marlin.py | 2 +- .../PlatformIO/scripts/preflight-checks.py | 2 +- .../share/scripts/MarlinBinaryProtocol.py | 24 +++++++++---------- buildroot/share/vscode/auto_build.py | 2 +- 11 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py index 6aa8947b98..1b84f171d9 100755 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py @@ -30,7 +30,7 @@ if __name__ == "__main__": parser.add_argument("-d", "--deflate", action="store_true", help="Packs the data using the deflate algorithm") args = parser.parse_args() - varname = os.path.splitext(os.path.basename(args.input))[0]; + varname = os.path.splitext(os.path.basename(args.input))[0] with open(args.input, "rb") as in_file: data = in_file.read() diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py index 0c4499e9aa..1d11b9307a 100755 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py @@ -77,7 +77,7 @@ class WriteSource: if len(self.values): self.blocks.append(self.values) - block_strs = []; + block_strs = [] for b in self.blocks: data = self.convert_to_4bpp(b) data = ', '.join(data) diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py index 74be574300..131141079a 100755 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py @@ -44,12 +44,12 @@ class WriteSource: def append_rgb565(self, color): value = ((color[0] & 0xF8) << 8) + ((color[1] & 0xFC) << 3) + ((color[2] & 0xF8) >> 3) - self.values.append((value & 0x00FF) >> 0); - self.values.append((value & 0xFF00) >> 8); + self.values.append((value & 0x00FF) >> 0) + self.values.append((value & 0xFF00) >> 8) def append_rgb332(self, color): value = (color[0] & 0xE0) + ((color[1] & 0xE0) >> 3) + ((color[2] & 0xC0) >> 6) - self.values.append(value); + self.values.append(value) def append_grayscale(self, color, bits): luminance = int(0.2126 * color[0] + 0.7152 * color[1] + 0.0722 * color[2]) @@ -99,7 +99,7 @@ if __name__ == "__main__": parser.add_argument("-m", "--mode", default="l1", help="Mode, can be l1, l2, l4, l8, rgb332 or rgb565") args = parser.parse_args() - varname = os.path.splitext(os.path.basename(args.input))[0]; + varname = os.path.splitext(os.path.basename(args.input))[0] writer = WriteSource(args.mode) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 4e81061a19..1458e5f850 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -9,7 +9,7 @@ if pioutil.is_pio_build(): board = marlin.env.BoardConfig() def calculate_crc(contents, seed): - accumulating_xor_value = seed; + accumulating_xor_value = seed for i in range(0, len(contents), 4): value = struct.unpack('> 8) + cs_low) % 255) << 8) | cs_low; + cs_low = (((cs & 0xFF) + value) % 255) + return ((((cs >> 8) + cs_low) % 255) << 8) | cs_low def build_checksum(self, buffer): cs = 0 @@ -270,7 +270,7 @@ class Protocol(object): def response_ok(self, data): try: - packet_id = int(data); + packet_id = int(data) except ValueError: return if packet_id != self.sync: @@ -279,7 +279,7 @@ class Protocol(object): self.packet_status = 1 def response_resend(self, data): - packet_id = int(data); + packet_id = int(data) self.errors += 1 if not self.syncronised: print("Retrying syncronisation") @@ -330,7 +330,7 @@ class FileTransferProtocol(object): return self.responses.popleft() def connect(self): - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.QUERY); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.QUERY) token, data = self.await_response() if token != 'PFT:version:': @@ -352,7 +352,7 @@ class FileTransferProtocol(object): timeout = TimeOut(5000) token = None - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload) while token != 'PFT:success' and not timeout.timedout(): try: token, data = self.await_response(1000) @@ -363,7 +363,7 @@ class FileTransferProtocol(object): print("Broken transfer detected, purging") self.abort() time.sleep(0.1) - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.OPEN, payload) timeout.reset() elif token == 'PFT:fail': raise Exception("Can not open file on client") @@ -372,10 +372,10 @@ class FileTransferProtocol(object): raise ReadTimeout() def write(self, data): - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.WRITE, data); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.WRITE, data) def close(self): - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.CLOSE); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.CLOSE) token, data = self.await_response(1000) if token == 'PFT:success': print("File closed") @@ -388,7 +388,7 @@ class FileTransferProtocol(object): return False def abort(self): - self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT); + self.protocol.send(FileTransferProtocol.protocol_id, FileTransferProtocol.Packet.ABORT) token, data = self.await_response() if token == 'PFT:success': print("Transfer Aborted") @@ -432,7 +432,7 @@ class FileTransferProtocol(object): self.close() print("Transfer aborted due to protocol errors") #raise Exception("Transfer aborted due to protocol errors") - return False; + return False print("\r{0:2.0f}% {1:4.2f}KiB/s {2} Errors: {3}".format(100, kibs, "[{0:4.2f}KiB/s]".format(kibs * cratio) if compression else "", self.protocol.errors)) # no one likes transfers finishing at 99.8% if not self.close(): diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index 31ef271551..25bd79cc7c 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -499,7 +499,7 @@ def get_starting_env(board_name_full, version): possible_envs = None for i, line in enumerate(pins_h): if 0 < line.find("Unknown MOTHERBOARD value set in Configuration.h"): - invalid_board(); + invalid_board() if list_start_found == False and 0 < line.find('1280'): list_start_found = True elif list_start_found == False: # skip lines until find start of CPU list