01-09-2024, 10:01 PM
(01-09-2024, 09:54 AM)Nutul Wrote: Just like it is done in the script:
until (subprocess.popen( ... ) == "1")
or == 1
depending on the subsystem.popen return type (string/char vs int), I am not proficient in Python...
I know this looks like a hack job (I'm not a coder by any stretch) but it works. Any suggestions on how to make it more elegant?
Code:
#!/usr/bin/env python
import RPi.GPIO as GPIO
import os
import subprocess
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.OUT)
result = subprocess.run (["/usr/local/bin/moodeutl", "-q","select value from cfg_system where param='wrkready'"],capture_output=True,text=True )
x = (result.stdout)
y = int(x)
print (y)
if y == 1:
GPIO.output(16,True)
else:
GPIO.output(16,False)