1212import shutil
1313from sys import exit , exc_info
1414from tempfile import mkdtemp
15+ from time import sleep
1516from threading import Thread
1617import time
1718from traceback import extract_stack , format_list , print_tb
@@ -600,6 +601,14 @@ def dismiss_remap_symbols(cfg, title):
600601 unknown_dialog (cfg , title , msgs )
601602
602603
604+ def dismiss_remap_layers (cfg , title ):
605+ """ KiCad 9 importing Altium files """
606+ wait_queue (cfg , 'GTK:Main:In' )
607+ dismiss_dialog (cfg , title , ['alt+l' ])
608+ time .sleep (1 )
609+ dismiss_dialog (cfg , title , ['alt+l' , 'alt+o' ])
610+
611+
603612def dismiss_save_changes (cfg , title ):
604613 """ KiCad 5/6 asking for save changes to disk """
605614 msgs = collect_dialog_messages (cfg , title )
@@ -621,6 +630,13 @@ def dismiss_pcb_info(cfg, title):
621630 cfg .logger .warning (msg )
622631 found = True
623632 break
633+ else :
634+ ma = re .search (r"Font '(.*)' not found; substituting '(.*)'" , msg )
635+ if ma :
636+ cfg .logger .warning (f"Missing '{ ma .group (1 )} ' font" )
637+ cfg .logger .warning ("KiCad message: " + msg )
638+ found = True
639+ break
624640 if not found :
625641 unknown_dialog (cfg , title , msgs , fatal = False )
626642 dismiss_dialog (cfg , title , 'Return' )
@@ -709,21 +725,43 @@ def wait_start_by_msg(cfg):
709725 prg_name = 'Eeschema'
710726 unsaved = ' noname.sch'
711727 cfg .logger .info ('Waiting for {} window ...' .format (prg_name ))
712- pre = 'GTK:Window Title:'
713- pre_l = len (pre )
728+ pre1 = 'GTK:Window Title:'
729+ pre1_l = len (pre1 )
730+ pre2 = 'GTK:Window Set Modal:'
731+ pre2_l = len (pre2 )
714732 cfg .logger .debug ('Waiting {} to start and load the {}' .format (prg_name , kind ))
715733 # Inform the elapsed time for slow loads
716- pres = [pre , 'PANGO:0:' ]
734+ pres = [pre1 , pre2 , 'PANGO:0:' ]
717735 elapsed_r = re .compile (r'PANGO:(\d:\d\d:\d\d)' )
718736 loading_msg = 'Loading ' + kind
719737 prg_msg = prg_name + ' —'
720738 with_elapsed = False
739+ modals = []
721740 while True :
722741 # Wait for any window
723742 res = wait_queue (cfg , pres , starts = True , timeout = cfg .wait_start , with_windows = True )
724743 cfg .logger .debug ('wait_start_by_msg got ' + res )
725744 match = elapsed_r .match (res )
726- title = res [pre_l :]
745+ title = res [pre1_l :]
746+ # The following code deals with the elusive "Report" dialog
747+ # This dialog is always created, but if filled it becomes modal
748+ if res .startswith (pre2 ):
749+ modal = res [pre2_l :]
750+ cfg .logger .debug (f"Detected window changing modal status: `{ modal } `" )
751+ if modal [- 1 ] == '1' :
752+ modals .append (modal [:- 2 ])
753+ elif modal [- 1 ] == '0' :
754+ modals .remove (modal [:- 2 ])
755+ if len (modals ):
756+ name = modals [- 1 ]
757+ cfg .logger .error (f'Insisting with nested modal `{ name } `' )
758+ dismiss_dialog (cfg , modals [- 1 ], ['Tab' , 'Return' ] if name == 'Report' else 'Return' )
759+ if modal == 'Report 1' :
760+ # Return is not enough, OK is not the default
761+ dismiss_dialog (cfg , 'Report' , ['Tab' , 'Return' ])
762+ elif modal == 'Edit Mapping of Imported Layers 1' :
763+ dismiss_remap_layers (cfg , modal [:- 2 ])
764+ continue
727765 if not match and with_elapsed :
728766 log .flush_info ()
729767 if not cfg .ki5 and title .endswith (cfg .window_title_end ):
@@ -780,5 +818,8 @@ def wait_start_by_msg(cfg):
780818 elif title == 'Report' :
781819 # KiCad 8.0.3 bogus hidden dialog
782820 pass
821+ elif title == 'Edit Mapping of Imported Layers' :
822+ # KiCad 9 import, we handle it on modal 1
823+ pass
783824 else :
784825 unknown_dialog (cfg , title )
0 commit comments