From 783f4fc077b864b51ecbe0c472bd2b47a142e0bc Mon Sep 17 00:00:00 2001 From: Julianne Swinoga Date: Sat, 22 Feb 2025 12:09:57 -0500 Subject: [PATCH 1/3] Fix spurious warning in hot patch comment --- OATFWGUI/gui_logic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OATFWGUI/gui_logic.py b/OATFWGUI/gui_logic.py index 0529a26..a5c43a1 100644 --- a/OATFWGUI/gui_logic.py +++ b/OATFWGUI/gui_logic.py @@ -248,7 +248,8 @@ def open_local_config_file(self): def do_hot_patches(self): # Before logging anything, check that we need to do something ini_lines = read_platformio_ini_file(self.logic_state) - bad_git_tag_re = re.compile(r'(github\.com.+)@') + + bad_git_tag_re = re.compile(r'(^[^;\n]+github\.com.+)@') if any(bad_git_tag_re.search(ini_line) for ini_line in ini_lines): log.warning('Hot patching git tag specifiers!!!') def patch_line(in_str: str) -> str: From 581c92158b2f2e7d8980d33730e287f61ad55634 Mon Sep 17 00:00:00 2001 From: Julianne Swinoga Date: Sat, 22 Feb 2025 12:17:31 -0500 Subject: [PATCH 2/3] Add SSD1306 revision hot patch --- OATFWGUI/gui_logic.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/OATFWGUI/gui_logic.py b/OATFWGUI/gui_logic.py index a5c43a1..4e356b9 100644 --- a/OATFWGUI/gui_logic.py +++ b/OATFWGUI/gui_logic.py @@ -282,6 +282,23 @@ def patch_line(in_str: str) -> str: with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp: fp.writelines(ini_lines) + bad_ssd_1306_revision_re = re.compile(r'(ClutchplateDude/esp8266-oled-ssd1306\s*#\s*4\.6\.0)') + if any(bad_ssd_1306_revision_re.search(ini_line) for ini_line in ini_lines): + log.warning('Hot patching oled-ssd1306 revision!!!') + def patch_line(in_str: str) -> str: + if bad_ssd_1306_revision_re.search(in_str): + out_str = bad_ssd_1306_revision_re.sub(r'ClutchplateDude/esp8266-oled-ssd1306#4f596c75', in_str) + log.warning(f'Replacing {in_str} with {out_str}') + return out_str + else: + return in_str + ini_lines = [ + patch_line(line) + for line in ini_lines + ] + with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp: + fp.writelines(ini_lines) + def build_fw(self): self.main_app.wSpn_build.setState(BusyIndicatorState.BUSY) From e492dcac0db0550e53fc471e905401836175b637 Mon Sep 17 00:00:00 2001 From: Julianne Swinoga Date: Sat, 22 Feb 2025 12:25:45 -0500 Subject: [PATCH 3/3] Minor refactor, only write out file if it changed --- OATFWGUI/gui_logic.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OATFWGUI/gui_logic.py b/OATFWGUI/gui_logic.py index 4e356b9..f66cefd 100644 --- a/OATFWGUI/gui_logic.py +++ b/OATFWGUI/gui_logic.py @@ -263,8 +263,6 @@ def patch_line(in_str: str) -> str: patch_line(line) for line in ini_lines ] - with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp: - fp.writelines(ini_lines) if self.logic_state.env_is_avr_based(): # hard match the entire line @@ -279,8 +277,6 @@ def patch_line(in_str: str) -> str: good_platform_line if line == bad_platform_line else line for line in ini_lines ] - with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp: - fp.writelines(ini_lines) bad_ssd_1306_revision_re = re.compile(r'(ClutchplateDude/esp8266-oled-ssd1306\s*#\s*4\.6\.0)') if any(bad_ssd_1306_revision_re.search(ini_line) for ini_line in ini_lines): @@ -296,8 +292,14 @@ def patch_line(in_str: str) -> str: patch_line(line) for line in ini_lines ] + + # Just re-read the ini file to see if we changed anything + if ini_lines != read_platformio_ini_file(self.logic_state): + log.debug('Writing out patched ini file') with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp: fp.writelines(ini_lines) + else: + log.debug('No patches applied') def build_fw(self): self.main_app.wSpn_build.setState(BusyIndicatorState.BUSY)