Skip to content

Commit e5264b2

Browse files
committed
Catch error when trying to launch browser
1 parent 8ef6986 commit e5264b2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

InteractiveHtmlBom/generate_interactive_bom.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,15 @@ def parse_modules(pcb_modules):
500500

501501
def open_file(filename):
502502
import subprocess
503-
if sys.platform.startswith('win'):
504-
os.startfile(filename)
505-
elif sys.platform.startswith('darwin'):
506-
subprocess.call(('open', filename))
507-
elif sys.platform.startswith('linux'):
508-
subprocess.call(('xdg-open', filename))
503+
try:
504+
if sys.platform.startswith('win'):
505+
os.startfile(filename)
506+
elif sys.platform.startswith('darwin'):
507+
subprocess.call(('open', filename))
508+
elif sys.platform.startswith('linux'):
509+
subprocess.call(('xdg-open', filename))
510+
except OSError as oe:
511+
logwarn('Failed to open browser: {}'.format(oe.message))
509512

510513

511514
def generate_file(pcb_file_dir, pcbdata, config):

0 commit comments

Comments
 (0)