From 182617c03fe5e44c384d61bfe1bf80a6df3852c1 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Mon, 13 Nov 2023 22:31:20 -0500 Subject: [PATCH 1/3] Remove `;` from **buildroot/scripts** _.py_ files unneeded ; --- .../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 +++++++++---------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 4e81061a19ad..1458e5f8509d 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -9,7 +9,7 @@ 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 @@ def disconnect(self): 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 @@ def response_ok(self, data): 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 @@ def await_response(self, timeout = None): 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 @@ def open(self, filename, compression, dummy): 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 @@ def open(self, filename, compression, dummy): 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 @@ def open(self, filename, compression, dummy): 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 @@ def close(self): 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 @@ def copy(self, filename, dest_filename, compression, dummy): 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(): From 6f648789823154431357b81b97bd0e0d5a4482a9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 13 Nov 2023 23:46:47 -0600 Subject: [PATCH 2/3] Replace ';[ \t]*$' in .py with '' --- .../ftdi_eve_touch_ui/ftdi_eve_lib/scripts/file2cpp.py | 2 +- .../ftdi_eve_touch_ui/ftdi_eve_lib/scripts/font2cpp.py | 2 +- .../ftdi_eve_touch_ui/ftdi_eve_lib/scripts/img2cpp.py | 8 ++++---- buildroot/share/vscode/auto_build.py | 2 +- 4 files changed, 7 insertions(+), 7 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 6aa8947b9858..1b84f171d954 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 @@ def deflate(data): 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 0c4499e9aadf..1d11b9307a5b 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 @@ def write(self): 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 74be57430049..131141079a21 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 @@ def add_bits_to_byte(self, value, size = 1): 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 @@ def write(self, varname, deflate): 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/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index 31ef2715515b..25bd79cc7c80 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 From b5620f67181afa62d3de4a77e7c6209101280f39 Mon Sep 17 00:00:00 2001 From: classicrocker883 Date: Tue, 14 Nov 2023 01:42:50 -0500 Subject: [PATCH 3/3] Fix `queue`, `Marlin_ver` --- buildroot/share/vscode/auto_build.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildroot/share/vscode/auto_build.py b/buildroot/share/vscode/auto_build.py index 25bd79cc7c80..80b8b2e6c119 100644 --- a/buildroot/share/vscode/auto_build.py +++ b/buildroot/share/vscode/auto_build.py @@ -1103,7 +1103,7 @@ def update(self): else: try: temp_text = IO_queue.get(block=False) - except Queue.Empty: + except queue.Empty: continue_updates = False # queue is exhausted so no need for further updates else: self.insert('end', temp_text[0], temp_text[1]) @@ -1267,6 +1267,7 @@ def main(): global build_type global target_env global board_name + global Marlin_ver board_name, Marlin_ver = get_board_name()