Good day all. I am trying to set an IF function with time, where it will check if something is working for a set amount of time and IF it isn't working then it will reset/restart a script.
if ledBlue.off() >= 10 seconds
command="sudo python3 project-2.py"
However, I get the feeling that I would be using a counter instead But I am definitely not sure how I would go about this.
The code that I currently have for this section is as follows:
if failed:
ledBlue.off()
if ledBlue.off() >= 10 seconds
command="sudo python3 project.py"
time.sleep(2)
command="sudo restart service"
os.system(command)
else:
ledBlue.on()
If what I am thinking about the timer is true I would have to implement a time.counter()
function to see how long ledBlue.off()
is before it implements the code.
How do I go about getting this right please...
I am not trying to pause the script for a period of time but to see how long the ledBlue.off() has been running then implement a script if it has been off for more than 10 seconds...