I am wondering if something i do is state-of-the art, although the app works perfectly.
Setup: a Rpi Zero W is designed to be a numeric keyboard witth a 3x4 matrix input keyboard.
Power comes from an USB connection and any data captured, is collected by a desktop program (via SSH)
On the Rpi runs a Python3 data capture program that also validates, etc...
This program runs continuously, UNTIL a "secret code" is typed on the matrix keyboard.
Then the python program executes the following statement, shutting down the Rpi completely.
os.system('sudo shutdown -h now')
This is kinda "brutal" . Should i not terminate the python program properly first? How can it terminate it's own execution?
But then i still need to somehow issue the shutdown statement (?).
Any thoughts on this ? Some equivalent of the old ".BAT' files in DOS : first terminate the program, then shut down the Rpi?
Yes , i could issue the commands from the desktop, but i would prefer to contain it in the Rpi.