diff --git a/mainwindow.py b/mainwindow.py index 4b18b29..3bd90e9 100644 --- a/mainwindow.py +++ b/mainwindow.py @@ -383,7 +383,11 @@ def __init__(self, parent, kicad_provider=KicadProvider()): align=wx.ALIGN_CENTER, ) params = self.footprint_list.AppendTextColumn( - "LCSC Params", 10, width=150, mode=dv.DATAVIEW_CELL_INERT, align=wx.ALIGN_CENTER + "LCSC Params", + 10, + width=150, + mode=dv.DATAVIEW_CELL_INERT, + align=wx.ALIGN_CENTER, ) lcsc = self.footprint_list.AppendTextColumn( "LCSC", 3, width=100, mode=dv.DATAVIEW_CELL_INERT, align=wx.ALIGN_CENTER @@ -544,7 +548,9 @@ def assign_parts(self, e): fp = board.FindFootprintByReference(reference) set_lcsc_value(fp, e.lcsc) params = params_for_part(self.library.get_part_details(e.lcsc)) - self.partlist_data_model.set_lcsc(reference, e.lcsc, e.type, e.stock, params) + self.partlist_data_model.set_lcsc( + reference, e.lcsc, e.type, e.stock, params + ) def display_message(self, e): """Dispaly a message with the data from the event.""" @@ -823,11 +829,16 @@ def select_part(self, *_): def check_order_number(self): """Verify that the JLC order number placeholder is present.""" try: - with open(self.pcbnew.GetBoard().GetFileName()) as f: + # We open with errors="replace because we're only interested in the occurance of the JLC magic string" + with open(self.pcbnew.GetBoard().GetFileName(), errors="replace") as f: data = f.read() return "JLCJLCJLCJLC" in data except OSError: pass + except UnicodeDecodeError: + self.logger.debug( + "Failed to check JLC order number due to UnicodeDecodeError" + ) return True def generate_fabrication_data(self, *_):