ソースを参照

fix autoextract

master
Jeong Geol Kim 4年前
コミット
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,10 +2,14 @@ import os
2 2
 import sys
3 3
 import glob
4 4
 import time
5
+import threading
5 6
 
6 7
 
7 8
 hdd_root = '/hdd/*'
8 9
 
10
+def cmd_run(shell_cmd):
11
+    os.system(str(shell_cmd))
12
+
9 13
 def main():
10 14
     surgery_list = glob.glob(hdd_root)
11 15
 
@@ -16,19 +20,23 @@ def main():
16 20
             pass
17 21
 
18 22
     for id in surgery_list:
23
+        
19 24
         file_list=glob.glob(id + '/*')
20 25
         for file in file_list:
21 26
             if 'log.txt' in file:
22 27
                 f = open(file, 'rt')
23 28
                 logs = f.readlines()
24
-                f.close()
29
+                f.close()                
25 30
                 if len(logs) == 2:
31
+                    thread_list = []
26 32
                     f = open(file, 'at')
27 33
                     r_time = time.ctime(time.time())
28 34
                     f.write('exectue is successfully starts at ' + str(r_time) + '\n')
29 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 40
                     f = open(file, 'at')
33 41
                     r_time = time.ctime(time.time())
34 42
                     f.write('exectue is successfully ends at ' + str(r_time) + '\n')

+ 1
- 1
extract_01.py ファイルの表示

@@ -16,7 +16,7 @@ for svo in svo_list:
16 16
   if svo[-5:] == '1.svo':   
17 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 18
   else:
19
-    continue
19
+    pass
20 20
 
21 21
 full_list = os.listdir(target_dir)
22 22
 csv_1_list = [file for file in full_list if file.endswith("1.csv")]

+ 1
- 1
extract_02.py ファイルの表示

@@ -15,7 +15,7 @@ for svo in svo_list:
15 15
   if svo[-5:] == '2.svo':
16 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 17
   else:
18
-    continue
18
+    pass
19 19
 
20 20
 full_list = os.listdir(target_dir)
21 21
 csv_2_list = [file for file in full_list if file.endswith("2.csv")]

読み込み中…
キャンセル
保存