Skip to content

Commit

Permalink
fix(check_order_number): catch system exceptions (#555)
Browse files Browse the repository at this point in the history
When empty board is used, pcbnew.GetBoard().GetFileName() returns
FileNotFound exception which was not handled in check_order_number
function.

Signed-off-by: Andrej Valek <andy@skyrain.eu>
  • Loading branch information
andy9a9 authored Dec 13, 2024
1 parent e553877 commit 080c907
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,13 @@ def select_part(self, *_):

def check_order_number(self):
"""Verify that the JLC order number placeholder is present."""
with open(self.pcbnew.GetBoard().GetFileName()) as f:
data = f.read()
return "JLCJLCJLCJLC" in data
try:
with open(self.pcbnew.GetBoard().GetFileName()) as f:
data = f.read()
return "JLCJLCJLCJLC" in data
except OSError:
pass
return True

def generate_fabrication_data(self, *_):
"""Generate fabrication data."""
Expand Down

0 comments on commit 080c907

Please sign in to comment.