Ejemplo n.º 1
0
                    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)
                    ])
                    mv('{}_bom.pdf'.format(sch_name), '../../')
                    os.chdir('../..')
                    call(['/bin/rm', '-rf', 'osx_bom_to_pdf'])
                    break
                else:
                    try:
                        unoconv('-f', 'pdf', '-o',
                                '{}_bom.pdf'.format(sch_name), boms[0])
                        break
                    except sh.ErrorReturnCode:
                        print(
                            'Unable to convert bom on this go. Will try again \ because that seems to fix it.'
                        )
                bom_tries -= 1
                if bom_tries == 0:
                    # Failed to convert bom. Exclude it
                    print(
                        'Just could not convert bom. You\'ll have to go \ without it.'
                    )
                    include_bom = False
        else:
            include_bom = False
Ejemplo n.º 2
0
	if os.path.exists(txt):
		with open(txt, 'r') as f:
			for l in f:
				if 'Generated by bom_to_text.py' in l:
					break
			else:
				print('Found existing {} that this script didn\'t create. \
Don\'t want to just overwrite it. Please move it or remove it.'.format(txt))
				sys.exit(1)

	# Convert the bom to csv
	bom_tries = 3
	while bom_tries > 0:
		try:
			unoconv('-f', 'csv', '-o', csv, b)
			break
		except sh.ErrorReturnCode:
			print('Unable to convert bom on this go. Will try again \
because that seems to fix it.')
		bom_tries -= 1
		if bom_tries == 0:
			# Failed to convert bom. Exclude it
			print('Converting bom to csv failed. Not much we can do now.')
			sys.exit(1)

	# Convert CSV to txt
	rows = []
	with open(csv,'rb') as f:
		csvreader = csvr.reader(f)
		for row in csvreader:
Ejemplo n.º 3
0
    if os.path.exists(txt):
        with open(txt, 'r') as f:
            for l in f:
                if 'Generated by bom_to_text.py' in l:
                    break
            else:
                print('Found existing {} that this script didn\'t create. \
Don\'t want to just overwrite it. Please move it or remove it.'.format(txt))
                sys.exit(1)

    # Convert the bom to csv
    bom_tries = 3
    while bom_tries > 0:
        try:
            unoconv('-f', 'csv', '-o', csv, b)
            break
        except sh.ErrorReturnCode:
            print('Unable to convert bom on this go. Will try again \
because that seems to fix it.')
        bom_tries -= 1
        if bom_tries == 0:
            # Failed to convert bom. Exclude it
            print('Converting bom to csv failed. Not much we can do now.')
            sys.exit(1)

    # Convert CSV to txt
    rows = []
    with open(csv, 'rb') as f:
        csvreader = csvr.reader(f)
        for row in csvreader:
Ejemplo n.º 4
0
			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)])
					mv('{}_bom.pdf'.format(sch_name), '../../')
					os.chdir('../..')
					call(['/bin/rm', '-rf', 'osx_bom_to_pdf'])
					break
				else:
					try:
						unoconv('-f', 'pdf', '-o', '{}_bom.pdf'.format(sch_name), boms[0])
						break
					except sh.ErrorReturnCode:
						print('Unable to convert bom on this go. Will try again \ because that seems to fix it.')
				bom_tries -= 1
				if bom_tries == 0:
					# Failed to convert bom. Exclude it
					print('Just could not convert bom. You\'ll have to go \ without it.')
					include_bom = False
		else:
			include_bom = False

	# Check if it is a four layer board by determining if the layer2 or layer3
	# pdf is bigger than the test pdf
	test_size = os.stat('{}_layer_test.pdf'.format(sch_name)).st_size
	layer2_size = os.stat('{}_layer2_copper.pdf'.format(sch_name)).st_size