-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor_version_6.py
More file actions
39 lines (30 loc) · 999 Bytes
/
executor_version_6.py
File metadata and controls
39 lines (30 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from os import listdir
from os.path import isfile, join
import subprocess
import time
path='/home/pi/Projects/remote_bot/execBot/'
print("executor")
def execute(filename):
print("running:",filename)
process_to_execute=subprocess.Popen(["python3", path+"codes/{}".format(filename)])
process_to_execute.wait()
#return process_to_execute
return
while(True):
time.sleep(0.5)
#print('hi')
file= open(path+"registry/total_back_index.txt","r")
total_index=int(file.read())
file.close()
mypath='codes/'
code_list = [f for f in listdir(path+mypath) if isfile(join(path+mypath, f))]
code_list=sorted(code_list, key=lambda x: int(x.split(" ")[0]))
#print(code_list)
for i in code_list:
if int(i.split(" ")[0])> total_index:
time.sleep(0.1)
file= open(path+"registry/total_back_index.txt","w")
total_index=total_index+1
file.write(str(total_index))
file.close()
execute(i)