So basically I have a script that downloads python files from my webserver then runs them. What I'm looking for now is a way to detect if the downloaded python script is done running as then I want the original python script to run again to download the next file and so on. I'm trying to do this completely automated with no user input. I attempted to do this by checking to see if a text file has changed but realized that that would require any user attempting to upload their code to add a file change feature to their code.
Here's some of my code for reference:
import time
import wget
import os
import requests
def lookForFile():
oldNumber=len(os.listdir("./upload"))
while True:
time.sleep(20)
NumberOfFiles = len(os.listdir("./upload"))
if NumberOfFiles != oldNumber:
os.system('python ./upload/1.py')
oldNumber = NumberOfFiles
def isRunning():
file = "save.txt"
with open(file) as f:
lines = f.readlines()
print(lines)
def notRunning():
f = open("save.txt", "w")
f.write("NotRunning")
f.close()
# open and read the file after the appending:
f = open("save.txt", "r")
print(f.read())
def updateRobot():
url = "url/1.py"
response = requests.get(url)
angel = response.json()
print(angel["currentNumber"])
def downloadScript():
url = "url/1.py"
wget.download(url, './upload/')
def main():
pass