Kicad 5.1.9 on Windows 10
I am trying to write a python script to convert the netlist to an unsupported format (Intergraph)
Something doe not work right and I need to debug it.
The problem is that when running the script from within Kicad the terminal screen “blips” and closes immediately.
Is there a way to keep it open?
Another thing - what exactly does Kicad pass to the script as the “%I” and “%o” arguments?
I haven’t used Python in KiCad yet, but what happens if you just add a line in your Python script to wait for a key press, or add a delay of a few seconds before it exits?
When you’re finished debugging you can delete that again of course.
I think you are talking about eeschema bom dialog. It’s not a real terminal, it’s not designed to stay open. You can run exact same command from normal terminal though. %I is path to the xml file that eeschema generates and %o is output file name, i.e. project name.
Yes, this is the eeschema bom dialog.
The thing is that my script works ok if I run it from a terminal and provide the arguments manually, but does not work if I place the same command in the dialog with the %I and %O as arguments
Well, this is actually the only thing that this script does - reads the XML file and writes to a text file.
If inside a windows command terminal I go to the Kicad project directory and run
python path-to-python-script.py project.xml project.out
then everything works - the project XML file is read and the netlist output file written
But if inside the Kicad netlist dialog I put
python “path-to-paython-script.py” “%I” “%O”
I get the dialog for selecting the output file, but then it does not work - the output file is not generated
This is what I am trying to debug and can not figure how
Maybe write debug data to a second text file, or push it to a socket or serial port?
You can use netcat telnet or putty to listen to a port and then send debug data to it.
seems to be something “built in” the dialog - it asks you for a file name (the output file name) whether you put the %0 argument or not. I assume that it you pu the %O argument it puts the name of the file that you selected into this argument to pass it to the script
Good idea - did it and now it starts making sense.
I though that the argument passed is the file name only and I added the path to it in my code - but the arguments appear as full path, so my addition of the path corrupted everything
Odd, but the input file path is given in Windows format () while the output file path is given in Linux format (/), so I guess my script is able to open the XML file for reading but tries to create an invalid file path for the output file.
I’ll continue from this point to try and solve the problem
Windows understands both forward and backslash as path separator.
One more thing. python run from eeschema launches kicad’s bundled pyton binary that is in kicad’s bin directory. python run from terminal is most likely your system python which may have different sets of libs or be a different version altogether (py3 vs py2).
Thanks, was not aware of this
Indeed if I go into kicad\bin and execute the bundled python I see that it is version 2.7 and I get an error for my script.