HI,
I have no python experience and am completely lost trying to fathom things out.
Running a pizero using buster and fitted with a blinkt module.
I’d like to have blinkt show me, using four leds, if four processes are still running or have completed.
I’d like a green led for running and a red led to show it’s completed.
For arguments sake the processes are called one, two, three and four.
It would save me having to constantly use putty or vnc to check. A nice quick visual indication.
Is there anyone out there kind enough to help write me something to accomplish this?
my python code is fairly rudimentary, but maybe something like the following :
#!/usr/bin/python
import os
import time # to allow the process to sleep
from blinkt import set_pixel, set_brightness, show, clear
set_brightness(0.2)
clear()
process1 = os.system(“ps -A | grep ‘one’”) # search running processes, case sensitive
if (process1 == 0): # it's found a match
set_pixel(0,0,255,0)
else:
set_pixel(0,255,0,0) # no match
process2 = os.system(“ps -A | grep ‘two’”)
if (process2 == 0):
set_pixel(1,0,255,0)
else:
set_pixel(1,255,0,0)
# and show the result
show()
time.sleep (300)