예제 #1
0
def main():
    if len(sys.argv) < 4:
        print("Usage: %s schematic.sch bom.csv partdb.yaml" % sys.argv[0])
        sys.exit(1)

    ulpFile = os.path.abspath(os.path.dirname(__file__) + "/tenshi-bom.ulp")
    schematicPath = os.path.abspath(sys.argv[1])
    outfilePath = os.path.abspath(sys.argv[2])
    partDbFileName = os.path.abspath(sys.argv[3])

    # Load the part database
    partDbFile = open(partDbFileName, 'r')
    partDb = yaml.load(partDbFile)
    partDbFile.close()

    # Start up Xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temp directory (work around EAGLE running the ULP in BRD instead
    # of in the SCH). Also will chdir into it.
    tmpdir = eagle_util_funcs.setup_tmp_dir()
    shutil.copyfile(schematicPath, "input.sch")

    # Run the BOM-generating ULP
    run_eagle_bom_ulp("input.sch", "bom-temp.csv", ulpFile)

    # TODO(rqou): There should probably be some error checking somewhere here

    # Match up stuff with the parts database
    fill_bom_with_db_info('bom-temp.csv', outfilePath, partDb)

    # Cleanup
    eagle_util_funcs.remove_tmp_dir(tmpdir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #2
0
def main():
    if len(sys.argv) < 4:
        print("Usage: %s schematic.sch bom.csv partdb.yaml" % sys.argv[0])
        sys.exit(1)

    ulpFile = os.path.abspath(os.path.dirname(__file__) + "/tenshi-bom.ulp")
    schematicPath = os.path.abspath(sys.argv[1])
    outfilePath = os.path.abspath(sys.argv[2])
    partDbFileName = os.path.abspath(sys.argv[3])

    # Load the part database
    partDbFile = open(partDbFileName, 'r')
    partDb = yaml.load(partDbFile)
    partDbFile.close()

    # Start up Xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temp directory (work around EAGLE running the ULP in BRD instead
    # of in the SCH). Also will chdir into it.
    tmpdir = eagle_util_funcs.setup_tmp_dir()
    shutil.copyfile(schematicPath, "input.sch")

    # Run the BOM-generating ULP
    run_eagle_bom_ulp("input.sch", "bom-temp.csv", ulpFile)

    # TODO(rqou): There should probably be some error checking somewhere here

    # Match up stuff with the parts database
    fill_bom_with_db_info('bom-temp.csv', outfilePath, partDb)

    # Cleanup
    eagle_util_funcs.remove_tmp_dir(tmpdir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #3
0
def main():
    # We're in the $proj-root/angel-player directory, get $proj-root directory
    proj_root = os.path.abspath(os.path.join(sys.path[0], '..'))

    testing_working_dir, testing_profile_dir = prep_testing_dir(proj_root)

    xulrunner_path = os.path.abspath(os.path.join(
        proj_root,
        'build/angel-player/angel-player.app/xul-lin64/xulrunner'))
    print(xulrunner_path)

    # Start xvfb
    xvfb, display_num = start_xvfb()

    xulrunner_p = subprocess.Popen([
        xulrunner_path,
        os.path.join(testing_working_dir, 'application.ini'),
        '-profile',
        testing_profile_dir,
    ], stderr = subprocess.STDOUT, stdout = subprocess.PIPE)
    log_results = xulrunner_p.communicate()[0]

    kill_xvfb(xvfb)

    # Print out log results
    print("*" * 80)
    print(log_results)
    print("*" * 80)

    tests_passed = "All tests passed!" in log_results

    if tests_passed:
        sys.exit(0)
    else:
        sys.exit(1)
예제 #4
0
def main():
    if len(sys.argv) < 3:
        print("Usage: %s in.sch|in.brd out.pdf" % (sys.argv[0]))
        sys.exit(1)

    scr_dir = os.path.abspath(os.path.dirname(sys.argv[0]))

    base_name = os.path.splitext(os.path.abspath(sys.argv[1]))[0]
    out_name = os.path.join(os.getcwd(), os.path.abspath(sys.argv[2]))

    sch_name = os.path.join(os.getcwd(), base_name + ".sch")
    brd_name = os.path.join(os.getcwd(), base_name + ".brd")

    have_sch = os.path.isfile(sch_name)
    have_brd = os.path.isfile(brd_name)

    # Start xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temporary directory
    tmp_dir = eagle_util_funcs.setup_tmp_dir()

    # Copy scripts to the temporary directory
    # Eagle's default location for saving exported images is unrelated to the
    # current working directory, so the scripts must be modified to hardcode
    # the output file paths
    copy_and_replace(os.path.join(scr_dir, "docu-packet-schematic.scr"),
                     os.path.join(tmp_dir, "schematic.scr"),
                     "%PATH%",
                     tmp_dir)
    copy_and_replace(os.path.join(scr_dir, "docu-packet-board.scr"),
                     os.path.join(tmp_dir, "board.scr"),
                     "%PATH%",
                     tmp_dir)

    inputs = []

    # Generate schematic image
    if have_sch:
        dst_sch_name = os.path.join(tmp_dir, "file.sch")
        shutil.copy(sch_name, dst_sch_name)
        run_script(dst_sch_name, "schematic.scr")
        os.remove(dst_sch_name)
        inputs.append(os.path.join(tmp_dir, "schematic.pdf"))

    # Generate board images
    if have_brd:
        dst_brd_name = os.path.join(tmp_dir, "file.brd")
        shutil.copy(brd_name, dst_brd_name)
        run_script(dst_brd_name, "board.scr")
        os.remove(dst_brd_name)
        inputs.append(os.path.join(tmp_dir, "top.pdf"))
        inputs.append(os.path.join(tmp_dir, "bottom.pdf"))

    # Compile final pdf
    compile_pdf(inputs, out_name)

    # Clean up
    eagle_util_funcs.remove_tmp_dir(tmp_dir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #5
0
def main():
    if len(sys.argv) < 3:
        print("Usage: %s in.sch|in.brd out.pdf" % (sys.argv[0]))
        sys.exit(1)

    scr_dir = os.path.abspath(os.path.dirname(sys.argv[0]))

    base_name = os.path.splitext(os.path.abspath(sys.argv[1]))[0]
    out_name = os.path.join(os.getcwd(), os.path.abspath(sys.argv[2]))

    sch_name = os.path.join(os.getcwd(), base_name + ".sch")
    brd_name = os.path.join(os.getcwd(), base_name + ".brd")

    have_sch = os.path.isfile(sch_name)
    have_brd = os.path.isfile(brd_name)

    # Start xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temporary directory
    tmp_dir = eagle_util_funcs.setup_tmp_dir()

    # Copy scripts to the temporary directory
    # Eagle's default location for saving exported images is unrelated to the
    # current working directory, so the scripts must be modified to hardcode
    # the output file paths
    copy_and_replace(os.path.join(scr_dir, "docu-packet-schematic.scr"),
                     os.path.join(tmp_dir, "schematic.scr"), "%PATH%", tmp_dir)
    copy_and_replace(os.path.join(scr_dir, "docu-packet-board.scr"),
                     os.path.join(tmp_dir, "board.scr"), "%PATH%", tmp_dir)

    inputs = []

    # Generate schematic image
    if have_sch:
        dst_sch_name = os.path.join(tmp_dir, "file.sch")
        shutil.copy(sch_name, dst_sch_name)
        run_script(dst_sch_name, "schematic.scr")
        os.remove(dst_sch_name)
        inputs.append(os.path.join(tmp_dir, "schematic.pdf"))

    # Generate board images
    if have_brd:
        dst_brd_name = os.path.join(tmp_dir, "file.brd")
        shutil.copy(brd_name, dst_brd_name)
        run_script(dst_brd_name, "board.scr")
        os.remove(dst_brd_name)
        inputs.append(os.path.join(tmp_dir, "top.pdf"))
        inputs.append(os.path.join(tmp_dir, "bottom.pdf"))

    # Compile final pdf
    compile_pdf(inputs, out_name)

    # Clean up
    eagle_util_funcs.remove_tmp_dir(tmp_dir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #6
0
def main():
    if len(sys.argv) < 3:
        print("Usage: %s schematic.sch bom.csv" % sys.argv[0])
        sys.exit(1)

    ulpFile = os.path.abspath(
        os.path.join(os.path.dirname(__file__), "tenshi-bom.ulp"))
    schematicPath = os.path.abspath(sys.argv[1])
    outfilePath = os.path.abspath(sys.argv[2])

    # Start up Xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temp directory (work around EAGLE running the ULP in BRD instead
    # of in the SCH). Also will chdir into it.
    tmpdir = eagle_util_funcs.setup_tmp_dir()
    shutil.copyfile(schematicPath, "input.sch")

    # Run the BOM-generating ULP
    run_eagle_bom_ulp("input.sch", outfilePath, ulpFile)

    # Cleanup
    eagle_util_funcs.remove_tmp_dir(tmpdir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #7
0
def main():
    if len(sys.argv) < 3:
        print("""Usage: {} [in.sch] [in.brd] [in.csv] out.pdf


	Generates a PDF documentation packet based on the input files.
At least one input file is required.
""".format(sys.argv[0]))
        sys.exit(1)

    # print("ARGUMENTS:", sys.argv)
    # return

    scr_dir = os.path.abspath(os.path.dirname(sys.argv[0]))

    sch_name = None
    brd_name = None
    csv_name = None
    out_name = None

    for arg in sys.argv[1:]:
        ext = os.path.splitext(arg)[1]
        arg_abs = os.path.abspath(arg)
        if not os.path.isfile(arg_abs) and not ext == ".pdf":
            raise IOError("File not found: {}".format(arg))

        if ext == ".sch":
            sch_name = arg_abs
        elif ext == ".brd":
            brd_name = arg_abs
        elif ext == ".csv":
            csv_name = arg_abs
        elif ext == ".pdf":
            out_name = arg_abs
        else:
            raise Exception("Unsupported input filetype: {}".format(ext))

    #make sure that there is an output PDF.
    if out_name is None:
        raise Exception("No output PDF specified")

    # Start xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temporary directory
    tmp_dir = eagle_util_funcs.setup_tmp_dir()

    # Copy scripts to the temporary directory
    # Eagle's default location for saving exported images is unrelated to the
    # current working directory, so the scripts must be modified to hardcode
    # the output file paths
    copy_and_replace(os.path.join(scr_dir, "docu-packet-schematic.scr"),
                     os.path.join(tmp_dir, "schematic.scr"), "%PATH%", tmp_dir)
    copy_and_replace(os.path.join(scr_dir, "docu-packet-board.scr"),
                     os.path.join(tmp_dir, "board.scr"), "%PATH%", tmp_dir)

    inputs = []

    # Generate schematic image
    if sch_name:
        dst_sch_name = os.path.join(tmp_dir, "file.sch")
        shutil.copy(sch_name, dst_sch_name)
        run_script(dst_sch_name, "schematic.scr")
        os.remove(dst_sch_name)
        inputs.append(os.path.join(tmp_dir, "schematic.pdf"))

    # Generate board images
    if brd_name:
        dst_brd_name = os.path.join(tmp_dir, "file.brd")
        shutil.copy(brd_name, dst_brd_name)
        run_script(dst_brd_name, "board.scr")
        os.remove(dst_brd_name)
        inputs.append(os.path.join(tmp_dir, "top_silk.pdf"))
        inputs.append(os.path.join(tmp_dir, "top_copper.pdf"))
        inputs.append(os.path.join(tmp_dir, "bottom_silk.pdf"))
        inputs.append(os.path.join(tmp_dir, "bottom_copper.pdf"))
        inputs.append(os.path.join(tmp_dir, "top_stencil.pdf"))

    # Generate bill of materials
    if csv_name and reportlab_available:
        gen_bom_pdf(csv_name, os.path.join(tmp_dir, "bom.pdf"))
        inputs.append(os.path.join(tmp_dir, "bom.pdf"))

    # Compile final pdf
    compile_pdf(inputs, out_name)

    # Clean up
    eagle_util_funcs.remove_tmp_dir(tmp_dir)
    eagle_util_funcs.kill_xvfb(xvfb)
예제 #8
0
def main():
    if len(sys.argv) < 3:
        print("""Usage: {} [in.sch] [in.brd] [in.csv] out.pdf

Generates a PDF documentation packet based on the input files.
At least one input file is required.
""".format(sys.argv[0]))
        sys.exit(1)

    # print("ARGUMENTS:", sys.argv)
    # return

    scr_dir = os.path.abspath(os.path.dirname(sys.argv[0]))

    sch_name = None
    brd_name = None
    csv_name = None
    for arg in sys.argv[1:-1]:
        ext = os.path.splitext(arg)[1]
        arg_abs = os.path.abspath(arg)
        if not os.path.isfile(arg_abs):
            raise IOError("File not found: {}".format(arg))

        if ext == ".sch":
            sch_name = arg_abs
        elif ext == ".brd":
            brd_name = arg_abs
        elif ext == ".csv":
            csv_name = arg_abs
        else:
            raise Exception("Unsupported input filetype: {}".format(ext))

    out_name = os.path.abspath(sys.argv[-1])

    # Start xvfb
    xvfb, display_num = eagle_util_funcs.start_xvfb()

    # Create temporary directory
    tmp_dir = eagle_util_funcs.setup_tmp_dir()

    # Copy scripts to the temporary directory
    # Eagle's default location for saving exported images is unrelated to the
    # current working directory, so the scripts must be modified to hardcode
    # the output file paths
    copy_and_replace(os.path.join(scr_dir, "docu-packet-schematic.scr"),
                     os.path.join(tmp_dir, "schematic.scr"),
                     "%PATH%",
                     tmp_dir)
    copy_and_replace(os.path.join(scr_dir, "docu-packet-board.scr"),
                     os.path.join(tmp_dir, "board.scr"),
                     "%PATH%",
                     tmp_dir)

    inputs = []

    # Generate schematic image
    if sch_name:
        dst_sch_name = os.path.join(tmp_dir, "file.sch")
        shutil.copy(sch_name, dst_sch_name)
        run_script(dst_sch_name, "schematic.scr")
        os.remove(dst_sch_name)
        inputs.append(os.path.join(tmp_dir, "schematic.pdf"))

    # Generate board images
    if brd_name:
        dst_brd_name = os.path.join(tmp_dir, "file.brd")
        shutil.copy(brd_name, dst_brd_name)
        run_script(dst_brd_name, "board.scr")
        os.remove(dst_brd_name)
        inputs.append(os.path.join(tmp_dir, "top.pdf"))
        inputs.append(os.path.join(tmp_dir, "bottom.pdf"))

    # Generate bill of materials
    if csv_name and reportlab_available:
        gen_bom_pdf(csv_name, os.path.join(tmp_dir, "bom.pdf"))
        inputs.append(os.path.join(tmp_dir, "bom.pdf"))

    # Compile final pdf
    compile_pdf(inputs, out_name)

    # Clean up
    eagle_util_funcs.remove_tmp_dir(tmp_dir)
    eagle_util_funcs.kill_xvfb(xvfb)