[ERC][KiCad 7][Fixed] Problems when creating a report without ext
- Workaround for KiCad 7 explicitly creating a different file Fixes #529
This commit is contained in:
parent
89365a8d5d
commit
4745baccc4
|
|
@ -119,6 +119,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
temporal, generating problems with the plot outputs, like pcb_print
|
||||
- Project options not preserved, i.e. set_text_variables failing
|
||||
- Bottom QRs should be mirrored in the Y axis
|
||||
- ERC:
|
||||
- Problems creating report files without extension (KiCad 7 odd behavior)
|
||||
(#529)
|
||||
|
||||
|
||||
## [1.6.3] - 2023-06-26
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ Dependencies:
|
|||
version: 2.2.1
|
||||
"""
|
||||
import os
|
||||
from shutil import move
|
||||
from sys import exit
|
||||
from tempfile import NamedTemporaryFile
|
||||
from .macros import macros, pre_class # noqa: F401
|
||||
from .gs import GS
|
||||
from .optionable import Optionable
|
||||
|
|
@ -52,8 +54,12 @@ class Run_ERC(BasePreFlight): # noqa: F821
|
|||
# But here we need data from it.
|
||||
output = self.get_targets()[0]
|
||||
os.makedirs(os.path.dirname(output), exist_ok=True)
|
||||
logger.debug('ERC report: '+output)
|
||||
cmd = [command, 'run_erc', '-o', output, '-g', str(GS.global_erc_grid)]
|
||||
# Workaround for KiCad 7 odd behavior: it forces a file extension
|
||||
# Note: One thing is adding the extension before you enter a name, other is add something you removed on purpose
|
||||
with NamedTemporaryFile(mode='w', delete=False, suffix='.rpt', prefix='erc_report') as f:
|
||||
tmp_name = f.name
|
||||
logger.debug('ERC report: '+tmp_name)
|
||||
cmd = [command, 'run_erc', '-o', tmp_name, '-g', str(GS.global_erc_grid)]
|
||||
if BasePreFlight.get_option('erc_warnings'): # noqa: F821
|
||||
cmd.append('-w')
|
||||
if GS.filter_file:
|
||||
|
|
@ -63,6 +69,10 @@ class Run_ERC(BasePreFlight): # noqa: F821
|
|||
cmd = self.add_extra_options(cmd)
|
||||
logger.info('- Running the ERC')
|
||||
ret = self.exec_with_retry(cmd)
|
||||
try:
|
||||
move(tmp_name, output)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if ret:
|
||||
if ret > 127:
|
||||
ret = -(256-ret)
|
||||
|
|
|
|||
Loading…
Reference in New Issue