Example #1
0
def export_schematic():
    schematic_file = os.path.join(electronics_root, 'splitflap.sch')
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir,
                                          'export_schematic_screencast.ogv')
    schematic_output_pdf_file = os.path.join(output_dir, 'splitflap.pdf')
    schematic_output_png_file = os.path.join(output_dir, 'schematic.png')

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file,
                           width=800,
                           height=600,
                           colordepth=24):
            with PopenContext(['eeschema', schematic_file],
                              close_fds=True) as eeschema_proc:
                eeschema_plot_schematic(output_dir)
                eeschema_proc.terminate()

    logger.info('Rasterize')
    subprocess.check_call([
        'convert',
        '-density',
        '96',
        schematic_output_pdf_file,
        '-background',
        'white',
        '-alpha',
        'remove',
        schematic_output_png_file,
    ])
Example #2
0
def cleanup(args):
    board_file_path = os.path.dirname(args.brd)
    board_file_name = os.path.basename(args.brd)
    board_file = os.path.join(project_root,
                              args.brd + '_' + args.variant + '.kicad_pcb')

    board = pcbnew.LoadBoard(board_file)

    output_dir = os.path.join(
        project_root,
        'CI-BUILD/' + board_file_name + '_' + args.variant + '/DLF')
    file_util.mkdir_p(output_dir)

    #TODO: Remove when stable or add debug flag
    screencast_output_file = os.path.join(output_dir,
                                          'dlf' + args.variant + '.ogv')

    with recorded_xvfb(screencast_output_file,
                       width=800,
                       height=600,
                       colordepth=24):
        with PopenContext(['pcbnew', board_file],
                          close_fds=True) as pcbnew_proc:
            pcbnew_cleanup(args.footprints, args.wait_init)
            pcbnew_proc.terminate()
Example #3
0
def export_schematic(prjfile, wait_init):
    """Print schematics to file in PDF format

    Keyword arguments:
    prjfile -- The project file name including relative path
    from project_root WITHOUT extension.
    """
    sch_file_path = os.path.dirname(prjfile)
    sch_file_name = os.path.basename(prjfile)
    schematic_file = os.path.join(project_root, prjfile + '.sch')

    output_dir = os.path.join(project_root,
                              'CI-BUILD/' + sch_file_name + '/SCH')
    file_util.mkdir_p(output_dir)

    #TODO: Remove when stable or add debug flag
    screencast_output_file = os.path.join(output_dir,
                                          'export_schematic_screencast.ogv')
    schematic_output_pdf_file = os.path.join(output_dir,
                                             sch_file_name + '.pdf')

    with recorded_xvfb(screencast_output_file,
                       width=800,
                       height=600,
                       colordepth=24):
        with PopenContext(['eeschema', schematic_file],
                          close_fds=True) as eeschema_proc:
            eeschema_plot_schematic(schematic_output_pdf_file, wait_init)
            eeschema_proc.terminate()
Example #4
0
def export_schematic(schematic_file, kicad_4):
    # Use absolute path - eeschema handles libraries differently with full path vs filename
    schematic_file = os.path.abspath(schematic_file)
    filename, _ = os.path.splitext(os.path.basename(schematic_file))
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, 'export_schematic_screencast.ogv')
    schematic_output_pdf_file = os.path.join(output_dir, filename + '.pdf')
    schematic_output_png_file = os.path.join(output_dir, filename + '.png')

    settings = {
        'PlotFormat': '4',  # PDF
    }
    with patch_config(os.path.expanduser('~/.config/kicad/eeschema'), settings):
        with versioned_file(schematic_file):
            with recorded_xvfb(screencast_output_file, width=WIDTH, height=HEIGHT, colordepth=24):
                with PopenContext(['eeschema', schematic_file], close_fds=True) as eeschema_proc:
                    eeschema_plot_schematic(output_dir, kicad_4)
                    eeschema_proc.terminate()

    logger.info('Rasterize')
    subprocess.check_call([
        'convert',
        '-density', '96',
        schematic_output_pdf_file,
       '-background', 'white',
       '-alpha', 'remove',
       schematic_output_png_file,
   ])
Example #5
0
def export_3d(filename):
    pcb_file = os.path.abspath(filename)
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir,
                                          'export_3d_screencast.ogv')

    name, _ = os.path.splitext(os.path.basename(pcb_file))
    output_file = os.path.join(output_dir, f'{name}-3d.png')

    settings = {
        'canvas_type': '1',
        'SMaskColor_Red': '0.1',
        'SMaskColor_Green': '0.1',
        'SMaskColor_Blue': '0.1',
        'RenderEngine': '1',
        'Render_RAY_ProceduralTextures': '0',
    }
    with patch_config(os.path.expanduser('~/.config/kicad/pcbnew'), settings):
        with versioned_file(pcb_file):
            with recorded_xvfb(screencast_output_file,
                               width=WIDTH,
                               height=HEIGHT,
                               colordepth=24):
                with PopenContext(['pcbnew', pcb_file],
                                  close_fds=True) as pcbnew_proc:
                    _pcbnew_export_3d(output_file)
                    pcbnew_proc.terminate()
Example #6
0
def export_bom(schematic_file):
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir,
                                          'export_bom_screencast.ogv')

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file,
                           width=800,
                           height=600,
                           colordepth=24):
            with PopenContext(['eeschema', schematic_file],
                              close_fds=True) as eeschema_proc:
                eeschema_export_bom()
                eeschema_proc.terminate()
Example #7
0
def export_bom():
    schematic_file = os.path.join(electronics_root, 'splitflap.sch')
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, 'export_bom_screencast.ogv')

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file, width=800, height=600, colordepth=24):
            with PopenContext(['eeschema', schematic_file], close_fds=True) as eeschema_proc:
                eeschema_export_bom(output_dir)
                eeschema_proc.terminate()

    logger.info('Convert component XML to useful BOM CSV file...')
    subprocess.check_call([
        'python',
        '-u',
        os.path.join(electronics_root, 'bom', 'generate_bom_csv.py'),
        os.path.join(electronics_root, 'splitflap.xml'),
        os.path.join(output_dir, 'bom.csv'),
    ])
Example #8
0
def export_bom():
    schematic_file = os.path.join(electronics_root, 'splitflap.sch')
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, 'export_bom_screencast.ogv')

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file, width=800, height=600, colordepth=24):
            with PopenContext(['eeschema', schematic_file], close_fds=True) as eeschema_proc:
                eeschema_export_bom(output_dir)
                eeschema_proc.terminate()

    logger.info('Convert component XML to useful BOM CSV file...')
    subprocess.check_call([
        'python',
        '-u',
        os.path.join(electronics_root, 'bom', 'generate_bom_csv.py'),
        os.path.join(electronics_root, 'splitflap.xml'),
        os.path.join(output_dir, 'bom.csv'),
    ])
Example #9
0
def export_bom(prjfile, wait_init):
    """Creates the BOM in xml

    Keyword arguments:
    prjfile -- The project file name including relative path
    from project_root WITHOUT extension.
    """
    sch_file_path = os.path.dirname(prjfile)
    sch_file_name = os.path.basename(prjfile)
    schematic_file = os.path.join(project_root, prjfile + '.sch')

    output_dir = os.path.join(project_root,
                              'CI-BUILD/' + sch_file_name + '/BOM')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir,
                                          'export_bom_screencast.ogv')

    with recorded_xvfb(screencast_output_file,
                       width=800,
                       height=600,
                       colordepth=24):
        with PopenContext(['eeschema', schematic_file],
                          close_fds=True) as eeschema_proc:
            eeschema_export_bom(output_dir, wait_init)
            eeschema_proc.terminate()

    # Copy xml BOM to CI Folder
    subprocess.check_call([
        'mv',
        prjfile + '.xml',
        output_dir,
    ])

    # Copy csv BOM to CI Folder
    subprocess.check_call([
        'mv',
        prjfile,
        output_dir + '/' + sch_file_name + '.csv',
    ])
Example #10
0
def export_bom():
    schematic_file = os.path.join(electronics_root, "splitflap.sch")
    output_dir = os.path.join(electronics_root, "build")
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, "export_bom_screencast.ogv")

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file, width=800, height=600, colordepth=24):
            with PopenContext(["eeschema", schematic_file], close_fds=True) as eeschema_proc:
                eeschema_export_bom(output_dir)
                eeschema_proc.terminate()

    logger.info("Convert component XML to useful BOM CSV file...")
    subprocess.check_call(
        [
            "python",
            "-u",
            os.path.join(electronics_root, "bom", "generate_bom_csv.py"),
            os.path.join(electronics_root, "splitflap.xml"),
            os.path.join(output_dir, "bom.csv"),
        ]
    )
Example #11
0
def export_schematic():
    schematic_file = os.path.join(electronics_root, 'splitflap.sch')
    output_dir = os.path.join(electronics_root, 'build')
    file_util.mkdir_p(output_dir)

    screencast_output_file = os.path.join(output_dir, 'export_schematic_screencast.ogv')
    schematic_output_pdf_file = os.path.join(output_dir, 'splitflap.pdf')
    schematic_output_png_file = os.path.join(output_dir, 'schematic.png')

    with versioned_schematic(schematic_file):
        with recorded_xvfb(screencast_output_file, width=800, height=600, colordepth=24):
            with PopenContext(['eeschema', schematic_file], close_fds=True) as eeschema_proc:
                eeschema_plot_schematic(output_dir)
                eeschema_proc.terminate()

    logger.info('Rasterize')
    subprocess.check_call([
        'convert',
        '-density', '96',
        schematic_output_pdf_file,
       '-background', 'white',
       '-alpha', 'remove',
       schematic_output_png_file,
   ])