[SCH Print][Netlist][Fixed] Problems with name collisions

- When the name chosen by KiCad was an alredy existing file (from
  another output) it was removed by KiAuto. So then KiCad created
  the file, we renamed it to what the user selected and ... well,
  the original file was lost. Now KiAuto takes care of this.
Fixes #244
This commit is contained in:
Salvador E. Tropea 2022-08-11 13:31:26 -03:00
parent 99d35922c6
commit 5785fd3e0f
6 changed files with 16 additions and 25 deletions

View File

@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SCH Variants on KiCad 6: Problems with missing values in the title block.
- Report: Converted file wasn't stored at `dir` (#238)
- Datasheet download: Time-outs on some servers expecting modern browsers (#240)
- SCH Print and Netlist: name collisions. When the default name used by KiCad
belongs to an already existing file. (#244)
### Changed
- The order in which main sections are parsed is now fixed.

View File

@ -62,7 +62,7 @@ class Any_SCH_PrintOptions(VariantOptions):
else:
sch_dir = None
sch_file = GS.sch_file
cmd = [command, 'export', '--file_format', self._expand_ext]
cmd = [command, 'export', '--file_format', self._expand_ext, '-o', name]
if self.monochrome:
cmd.append('--monochrome')
if not self.frame:
@ -75,10 +75,6 @@ class Any_SCH_PrintOptions(VariantOptions):
if ret:
logger.error(command+' returned %d', ret)
exit(self._exit_error)
if self.output:
cur = self._parent.expand_filename(output_dir, '%f.%x')
logger.debug('Moving '+cur+' -> '+name)
os.rename(cur, name)
# Remove the temporal dir if needed
if sch_dir:
logger.debug('Removing temporal variant dir `{}`'.format(sch_dir))

View File

@ -8,7 +8,7 @@ Dependencies:
- from: KiAuto
role: mandatory
command: eeschema_do
version: 1.6.11
version: 2.0.0
"""
import os
from .gs import GS
@ -48,26 +48,19 @@ class NetlistOptions(BaseOptions):
if self.format == 'ipc':
command = command.replace('eeschema_do', 'pcbnew_do')
subcommand = 'ipc_netlist'
extra = ['--output_name', name]
file = GS.pcb_file
else:
subcommand = 'netlist'
extra = []
file = GS.sch_file
output_dir = os.path.dirname(name)
# Output file name
cmd = [command, subcommand]+extra+[file, output_dir]
cmd = [command, subcommand, '--output_name', name, file, output_dir]
cmd, video_remove = add_extra_options(cmd)
# Execute it
ret = exec_with_retry(cmd)
if ret:
logger.error(command+' returned %d', ret)
exit(FAILED_EXECUTE)
# Rename the output if needed
if not extra:
cur = self._parent.expand_filename(output_dir, '%f.%x')
logger.debug('Moving '+cur+' -> '+name)
os.rename(cur, name)
# Remove the video if needed
if video_remove:
video_name = os.path.join(self.expand_filename_pcb(GS.out_dir), command[:-3]+'_'+subcommand+'_screencast.ogv')

View File

@ -8,7 +8,7 @@ Dependencies:
- from: KiAuto
role: mandatory
command: eeschema_do
version: 1.5.4
version: 2.0.0
"""
from .gs import GS
from .out_any_sch_print import Any_SCH_PrintOptions

View File

@ -9,7 +9,7 @@ Dependencies:
- from: KiAuto
role: mandatory
command: eeschema_do
version: 1.5.4
version: 2.0.0
"""
from .gs import GS
from .out_any_sch_print import Any_SCH_PrintOptions

View File

@ -270,9 +270,9 @@ deps = '{\
"mandatory": true,\
"output": "netlist",\
"version": [\
1,\
6,\
11\
2,\
0,\
0\
]\
},\
{\
@ -300,9 +300,9 @@ deps = '{\
"mandatory": true,\
"output": "pdf_sch_print",\
"version": [\
1,\
5,\
4\
2,\
0,\
0\
]\
},\
{\
@ -340,9 +340,9 @@ deps = '{\
"mandatory": true,\
"output": "svg_sch_print",\
"version": [\
1,\
5,\
4\
2,\
0,\
0\
]\
},\
{\