Jeong Geol Kim 4 лет назад
Родитель
Сommit
5d0977f6c0
3 измененных файлов: 13 добавлений и 5 удалений
  1. 11
    3
      auto_extract.py
  2. 1
    1
      extract_01.py
  3. 1
    1
      extract_02.py

+ 11
- 3
auto_extract.py Просмотреть файл

2
 import sys
2
 import sys
3
 import glob
3
 import glob
4
 import time
4
 import time
5
+import threading
5
 
6
 
6
 
7
 
7
 hdd_root = '/hdd/*'
8
 hdd_root = '/hdd/*'
8
 
9
 
10
+def cmd_run(shell_cmd):
11
+    os.system(str(shell_cmd))
12
+
9
 def main():
13
 def main():
10
     surgery_list = glob.glob(hdd_root)
14
     surgery_list = glob.glob(hdd_root)
11
 
15
 
16
             pass
20
             pass
17
 
21
 
18
     for id in surgery_list:
22
     for id in surgery_list:
23
+        
19
         file_list=glob.glob(id + '/*')
24
         file_list=glob.glob(id + '/*')
20
         for file in file_list:
25
         for file in file_list:
21
             if 'log.txt' in file:
26
             if 'log.txt' in file:
22
                 f = open(file, 'rt')
27
                 f = open(file, 'rt')
23
                 logs = f.readlines()
28
                 logs = f.readlines()
24
-                f.close()
29
+                f.close()                
25
                 if len(logs) == 2:
30
                 if len(logs) == 2:
31
+                    thread_list = []
26
                     f = open(file, 'at')
32
                     f = open(file, 'at')
27
                     r_time = time.ctime(time.time())
33
                     r_time = time.ctime(time.time())
28
                     f.write('exectue is successfully starts at ' + str(r_time) + '\n')
34
                     f.write('exectue is successfully starts at ' + str(r_time) + '\n')
29
                     f.close()
35
                     f.close()
30
-                    os.system('docker run --rm --name extract_1 --gpus '"device=0"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/extract_01.py ' + id + '/ >> /dev/null')
31
-                    os.system('docker run --rm --name extract_2 --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/extract_02.py ' + id + '/ >> /dev/null')
36
+                    cmd_list = ['docker run --rm --name extract_1 --gpus '"device=0"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/extract_01.py ' + id + '/ >> /dev/null', 'docker run --rm --name extract_2 --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/extract_02.py ' + id + '/ >> /dev/null']
37
+                    for index in range(0, len(cmd_list)):
38
+                        thread_list.append(threading.Thread(target=cmd_run,args=cmd_list))
39
+                        thread_list[index].start()                    
32
                     f = open(file, 'at')
40
                     f = open(file, 'at')
33
                     r_time = time.ctime(time.time())
41
                     r_time = time.ctime(time.time())
34
                     f.write('exectue is successfully ends at ' + str(r_time) + '\n')
42
                     f.write('exectue is successfully ends at ' + str(r_time) + '\n')

+ 1
- 1
extract_01.py Просмотреть файл

16
   if svo[-5:] == '1.svo':   
16
   if svo[-5:] == '1.svo':   
17
     os.system('python3 /sources/depthsensing.py -c /sources/cfg.cfg -w /sources/mailsys.weights -m /sources/data.data -s ' + target_dir + svo + ' -o ' + target_dir + svo[:5] + '.csv')
17
     os.system('python3 /sources/depthsensing.py -c /sources/cfg.cfg -w /sources/mailsys.weights -m /sources/data.data -s ' + target_dir + svo + ' -o ' + target_dir + svo[:5] + '.csv')
18
   else:
18
   else:
19
-    continue
19
+    pass
20
 
20
 
21
 full_list = os.listdir(target_dir)
21
 full_list = os.listdir(target_dir)
22
 csv_1_list = [file for file in full_list if file.endswith("1.csv")]
22
 csv_1_list = [file for file in full_list if file.endswith("1.csv")]

+ 1
- 1
extract_02.py Просмотреть файл

15
   if svo[-5:] == '2.svo':
15
   if svo[-5:] == '2.svo':
16
     os.system('python3 /sources/depthsensing.py -c /sources/cfg.cfg -w /sources/mailsys.weights -m /sources/data.data -s ' + target_dir + svo + ' -o ' + target_dir + svo[:5] + '.csv')
16
     os.system('python3 /sources/depthsensing.py -c /sources/cfg.cfg -w /sources/mailsys.weights -m /sources/data.data -s ' + target_dir + svo + ' -o ' + target_dir + svo[:5] + '.csv')
17
   else:
17
   else:
18
-    continue
18
+    pass
19
 
19
 
20
 full_list = os.listdir(target_dir)
20
 full_list = os.listdir(target_dir)
21
 csv_2_list = [file for file in full_list if file.endswith("2.csv")]
21
 csv_2_list = [file for file in full_list if file.endswith("2.csv")]

Загрузка…
Отмена
Сохранить