How to keep a copy of the uploaded program and be sure to find it months later?

OK. I think it is now working the way I want it. I will post the code in a separate Reply for ease of viewing, but please use the attachment if you want to try it because I have used tabs and the Forum software loses them. Also, please change the file name from PyArduinoBuilder.txt to PyArduinoBuilder.py

Be sure to read through the code before trying it to make sure it will not do something you object to

You can run the program with python path/to/PyArduinoBuilder.py path/to/myArdinoProg.ino

I use the program with the Geany text editor. Select Build/Set Build Commands and in the bottom section Execute Commands give it a name (I use ArduinoBuild) and enter the coomand in the middle box. My command is
/mnt/sdb1/SGT-Prog/Arduino/PythonUploader/PyArduinoBuilder.py "%d/%f".
Then you can verify or upload the Arduino code by clicking Build/ArduinoBuild.

Note that you could create the command in the C++ Commands section but that does not open a terminal window which is very inconvenient when there is a Java error. Without the terminal window I have to find the process and kill it. With the terminal window I can just click Ctrl-C.

As written the Python program creates (if they don't exist) two directories alongside itself. One ArduinoTemp is where the .ino file is copied before the IDE is called to compile it. The other ArduinoUploadArchive is where the archive copies of the Arduino code are stored.

I hope there are sufficient comments in the program to make sense of it. You need to include comments at the top of your Arduino program which the Python program reads so it knows what to do. These are described in the Python code.

Please remember that this is something I created for my own use, without any attempt at "polish". Also, please keep in mind that it is a script that is intended to run once from top to bottom. Consequently there did not seem any reason to put the code into functions.

This code is an evolution of the system in this Thread.

As usual, comments are welcome.

...R

PyArduinoBuilder.txt (7.06 KB)