示例#1
0
    # Delete the merged version
    rm('-f', '{}.pdf'.format(sch))

    # Something broke in Eagle with the section specifiers and command blocking,
    # so work around by just making new scr files that includes a traling quit
    print("  Generating schematic pdf")
    with tempfile.NamedTemporaryFile() as temp_scr:
        with open(pdfscrSch) as source:
            for line in source:
                temp_scr.write(line.encode('utf-8'))
        temp_scr.write('\nquit;'.encode('utf-8'))
        temp_scr.flush()

        # Generate the schematic pdfs
        eagle('-S', temp_scr.name, sch)

    print("  Generating board pdf")
    with tempfile.NamedTemporaryFile() as temp_scr:
        with open(pdfscrBrd) as source:
            for line in source:
                temp_scr.write(line.encode('utf-8'))
        temp_scr.write('\nquit;'.encode('utf-8'))
        temp_scr.flush()

        # Generate the board pdfs
        eagle('-S', temp_scr.name, brd)

    # If a bom is present also convert it to pdf
    if include_bom:
        print("  Generating BOM pdf")
示例#2
0
with open(tmpscr, 'w') as f:
	f.write(contents)

# Figure out the name of the schematic to run this on.
for sch in glob('*.sch'):
	sch_name, sch_ext = os.path.splitext(sch)

	# Delete the old pdfs if they exist
	for pdf in pdf_files + ['layer_test']:
		rm('-f', '{}_{}.pdf'.format(sch_name, pdf))

	# Delete the merged version
	rm ('-f', '{}.pdf'.format(sch))

	# Generate the pdfs
	eagle('-S', tmpscr, sch)

	# If a bom is present also convert it to pdf
	if include_bom:
		boms = glob('*bom*xls*')
		if len(boms) > 0:
			bom_tries = 3
			while bom_tries > 0:
				if platform.system().lower() == 'darwin':
					call(['/bin/rm', '-rf', 'osx_bom_to_pdf'])
					os.mkdir('osx_bom_to_pdf')
					call(['qlmanage','-o','osx_bom_to_pdf','-p',boms[0]])
					qldir = boms[0] + '.qlpreview'
					os.chdir("%s/%s" % ('osx_bom_to_pdf',qldir))
					call(['/Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf',
						'Preview.html', '{}_bom.pdf'.format(sch_name)])
示例#3
0
from glob import glob
import os
import sys
import sh

# Display the help if any arguments are provided.
if len(sys.argv) > 1:
    print(HELP)
    sys.exit(0)

# Determine the location of this script and the .ulp file
here = os.path.dirname(os.path.realpath(__file__))
ulp = os.path.join(here, '..', 'ulp', 'centroid-smd.ulp')
scr = os.path.join(here, '..', 'scr', 'ulp-brd.scr')
tmpscr = os.path.join('/', 'tmp', 'ulp.scr')

contents = ''
with open(scr, 'r') as f:
    contents = f.read()

contents = contents.replace('%ULP_PATH%', ulp)

with open(tmpscr, 'w') as f:
    f.write(contents)

# Figure out the name of the schematic to run this on.
for brd in glob('*.brd'):
    # Generate the centroid file
    eagle('-S', tmpscr, brd)
示例#4
0
with open(pngscr, 'r') as f:
    pngscr_contents = f.read()

# Create script to run the pdf script
contents = ''
with open(scr, 'r') as f:
    contents = f.read()
contents = contents.replace('%SCRIPT_PATH%', tmppng)
with open(tmpscr, 'w') as f:
    f.write(contents)

# Figure out the name of the schematic to run this on.
for sch in glob('*.sch'):
    sch_name, sch_ext = os.path.splitext(sch)

    png_name = '{}_pcb.png'.format(sch_name)
    rm('-f', png_name)

    pngscr_contents = pngscr_contents.replace('%N', sch_name)
    with open(tmppng, 'w') as f:
        f.write(pngscr_contents)

    # Generate the png
    eagle('-S', tmpscr, sch)

    # Trip whitespace
    sh.convert(png_name, '-trim', png_name)

rm('-f', tmpscr)
rm('-f', tmppng)
示例#5
0
from glob import glob
import os
import sys
import sh

# Display the help if any arguments are provided.
if len(sys.argv) > 1:
	print(HELP)
	sys.exit(0)

# Determine the location of this script and the .ulp file
here = os.path.dirname(os.path.realpath(__file__))
ulp = os.path.join(here, '..', 'ulp', 'centroid-smd.ulp')
scr = os.path.join(here, '..', 'scr', 'ulp-brd.scr')
tmpscr = os.path.join('/', 'tmp', 'ulp.scr')

contents = ''
with open(scr, 'r') as f:
	contents = f.read()

contents = contents.replace('%ULP_PATH%', ulp)

with open(tmpscr, 'w') as f:
	f.write(contents)


# Figure out the name of the schematic to run this on.
for brd in glob('*.brd'):
	# Generate the centroid file
	eagle('-S', tmpscr, brd)