def create_kicad_config(cfg): logger.debug('Creating a KiCad common config') with open(cfg.conf_kicad, "wt") as text_file: if cfg.conf_kicad_json: kiconf = {"environment": {"show_warning_dialog": False}} kiconf['graphics'] = { "cairo_antialiasing_mode": 0, "opengl_antialiasing_mode": 0 } kiconf['system'] = {"editor_name": "/bin/cat"} # Copy the environment vars if available if cfg.conf_kicad_bkp: vars = Config.get_config_vars_json(cfg.conf_kicad_bkp) if vars: kiconf['environment']['vars'] = vars text_file.write(json.dumps(kiconf)) logger.debug(json.dumps(kiconf)) else: text_file.write('ShowEnvVarWarningDialog=0\n') text_file.write('Editor=/bin/cat\n') # Copy the environment vars if available if cfg.conf_kicad_bkp: vars = Config.get_config_vars_ini(cfg.conf_kicad_bkp) if vars: text_file.write('[EnvironmentVariables]\n') for key in vars: text_file.write(key.upper() + '=' + vars[key] + '\n')
def test_print_pcb_good_dwg_dism(): ctx = context.TestContext('Print_Good_with_Dwg_Dism', 'good-project') pdf = 'good_pcb_with_dwg.pdf' # Create the output to force and overwrite with open(ctx.get_out_path(pdf), 'w') as f: f.write('dummy') cfg = Config(logging) # Run pcbnew in parallel to get 'Dismiss pcbnew already running' with ctx.start_kicad(cfg.pcbnew, cfg): cmd = [PROG, '-v', '--wait_start', '5', 'export', '--output_name', pdf] layers = ['F.Cu', 'F.SilkS', 'Dwgs.User', 'Edge.Cuts'] ctx.run(cmd, extra=layers) ctx.stop_kicad() ctx.expect_out_file(pdf) ctx.compare_image(pdf) assert ctx.search_err(r"Dismiss pcbnew already running") is not None ctx.clean_up()
def test_erc_ok_eeschema_running(): """ 1) Test eeschema already running 2) Test logger colors on TTYs """ prj = 'good-project' rep = prj + '.erc' ctx = context.TestContextSCH('ERC_Ok_eeschema_running', prj) cfg = Config(logging) # Run eeschema in parallel to get 'Dismiss eeschema already running' with ctx.start_kicad(cfg.eeschema, cfg): # Enable DEBUG logs cmd = [PROG, '-vv', '-r', 'run_erc'] # Use a TTY to get colors in the DEBUG logs ctx.run(cmd, use_a_tty=True) ctx.stop_kicad() ctx.expect_out_file(rep) logging.debug('Checking for colors in DEBUG logs') assert ctx.search_err(r"\[36;1mDEBUG:") is not None assert ctx.search_err(r"Dismiss eeschema already running") is not None ctx.clean_up()
def test_drc_ok_pcbnew_running(): """ 1) Test to overwrite the .erc file 2) Test pcbnew already running On KiCad 6 we don't run pcbnew """ ctx = context.TestContext('DRC_Ok_pcbnew_running', 'good-project') # Create a report to force and overwrite with open(ctx.get_out_path(REPORT), 'w') as f: f.write('dummy') cfg = Config(logging) # Run pcbnew in parallel to get 'Dismiss pcbnew already running' with ctx.start_kicad(cfg.pcbnew, cfg): # Enable DEBUG logs cmd = [PROG, '-vv', 'run_drc'] # Use a TTY to get colors in the DEBUG logs ctx.run(cmd, use_a_tty=True) ctx.stop_kicad() ctx.expect_out_file(REPORT) logging.debug('Checking for colors in DEBUG logs') if ctx.kicad_version < context.KICAD_VERSION_5_99: assert ctx.search_err(r"Dismiss pcbnew already running") is not None assert ctx.search_err(r"\[36;1mDEBUG:") is not None ctx.clean_up()
'-s', help='Save after DRC (updating filled zones)', action='store_true') drc_parser.add_argument('kicad_pcb_file', help='KiCad PCB file') drc_parser.add_argument('output_dir', help='Output directory') args = parser.parse_args() # Set the specified verbosity log.set_level(logger, args.verbose) if args.command is None: logger.error('No command selected') parser.print_help() exit(WRONG_ARGUMENTS) cfg = Config(logger, args.kicad_pcb_file, args) set_time_out_scale(cfg.time_out_scale) # Empty values by default, we'll fill them for export cfg.fill_zones = False cfg.layers = [] cfg.save = args.command == 'run_drc' and args.save cfg.input_file = args.kicad_pcb_file # Get local versions for the GTK window names gettext.textdomain('gtk30') cfg.select_a_filename = gettext.gettext('Select a filename') cfg.print_dlg_name = gettext.gettext('Print') logger.debug('Select a filename -> ' + cfg.select_a_filename) logger.debug('Print -> ' + cfg.print_dlg_name) # Force english + UTF-8