This is a simplified example, the python program run on a device and wait for a text file to understand how to execute the next step, the text file will be upload to the device frequently.
How to let the python program "translate" the text file (in this example, steps.txt
only has one line "z = x + y"
) into the executable script?
import os
import time
x = 3
y = 9
s = None
while 1:
time.sleep(1)
try:
with open("steps.txt", 'r') as f:
s = f.readline()#s = "z = x + y"
f.close()
break
except:
pass
os.system(s)#'z' is not recognized as an internal or external command,operable program or batch file.