Kaynağa Gözat

automation code

master
Ellis Huntingmoon 4 yıl önce
ebeveyn
işleme
4f1c372b4d
3 değiştirilmiş dosya ile 138 ekleme ve 0 silme
  1. 41
    0
      auto_coordinate.py
  2. 41
    0
      auto_extract.py
  3. 56
    0
      auto_kpi.py

+ 41
- 0
auto_coordinate.py Dosyayı Görüntüle

1
+import os
2
+import sys
3
+import glob
4
+import time
5
+
6
+
7
+hdd_root = '/hdd/*'
8
+
9
+def main():
10
+    surgery_list = glob.glob(hdd_root)
11
+
12
+    for id in surgery_list:
13
+        if 'lost+found' in id:
14
+            surgery_list.remove(id)
15
+        else:
16
+            pass
17
+
18
+    for id in surgery_list:
19
+        file_list=glob.glob(id + '/*')
20
+        for file in file_list:
21
+            if 'log.txt' in file:
22
+                f = open(file, 'rt')
23
+                logs = f.readlines()
24
+                f.close()
25
+                if len(logs) == 4:
26
+                    f = open(file, 'ar')
27
+                    r_time = time.ctime(time.time())
28
+                    f.write('global coordinate successfully starts at ' + str(r_time) + '\n')
29
+                    f.close()
30
+                    #FIXME: change coordinate_g.py when IMU sensor works
31
+                    os.system('run --rm --name coordinate --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/coordinate_g.py ' + id + '/ >> /dev/null')
32
+                    f = open(file, 'ar')
33
+                    r_time = time.ctime(time.time())
34
+                    f.write('global coordinate successfully ends at ' + str(r_time) + '\n')
35
+                    f.close()
36
+                else:
37
+                    pass
38
+
39
+if __name__ == '__main__':
40
+    while True:
41
+        main()

+ 41
- 0
auto_extract.py Dosyayı Görüntüle

1
+import os
2
+import sys
3
+import glob
4
+import time
5
+
6
+
7
+hdd_root = '/hdd/*'
8
+
9
+def main():
10
+    surgery_list = glob.glob(hdd_root)
11
+
12
+    for id in surgery_list:
13
+        if 'lost+found' in id:
14
+            surgery_list.remove(id)
15
+        else:
16
+            pass
17
+
18
+    for id in surgery_list:
19
+        file_list=glob.glob(id + '/*')
20
+        for file in file_list:
21
+            if 'log.txt' in file:
22
+                f = open(file, 'rt')
23
+                logs = f.readlines()
24
+                f.close()
25
+                if len(logs) == 2:
26
+                    f = open(file, 'ar')
27
+                    r_time = time.ctime(time.time())
28
+                    f.write('exectue is successfully starts at ' + str(r_time) + '\n')
29
+                    f.close()
30
+                    os.system('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('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')
32
+                    f = open(file, 'ar')
33
+                    r_time = time.ctime(time.time())
34
+                    f.write('exectue is successfully ends at ' + str(r_time) + '\n')
35
+                    f.close()
36
+                else:
37
+                    pass
38
+
39
+if __name__ == '__main__':
40
+    while True:
41
+        main()

+ 56
- 0
auto_kpi.py Dosyayı Görüntüle

1
+import os
2
+import sys
3
+import glob
4
+import time
5
+import paramiko
6
+
7
+
8
+
9
+hdd_root = '/hdd/*'
10
+
11
+
12
+hdd_root = '/hdd/*'
13
+
14
+def main():
15
+    surgery_list = glob.glob(hdd_root)
16
+
17
+    for id in surgery_list:
18
+        if 'lost+found' in id:
19
+            surgery_list.remove(id)
20
+        else:
21
+            pass
22
+
23
+    for id in surgery_list:
24
+        file_list=glob.glob(id + '/*')
25
+        for file in file_list:
26
+            if 'log.txt' in file:
27
+                f = open(file, 'rt')
28
+                logs = f.readlines()
29
+                f.close()
30
+                if len(logs) == 6:
31
+                    f = open(file, 'ar')
32
+                    r_time = time.ctime(time.time())
33
+                    f.write('kpi successfully starts at ' + str(r_time) + '\n')
34
+                    f.close()
35
+                    #FIXME: change coordinate_g.py when IMU sensor works and get generic optimizer for DBSCAN
36
+                    os.system('run --rm --name kpi --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.4 python3 /sources/kpi.py ' + id + '/ >> /dev/null')
37
+                    f = open(file, 'ar')
38
+                    r_time = time.ctime(time.time())
39
+                    f.write('kpi successfully ends at ' + str(r_time) + '\n')
40
+                    f.close()
41
+
42
+                    transport = paramiko.Transport(('365mc.iptime.org', '63122'))
43
+                    transport.connect(username='mc365', password='tkadbrdhmc1!')
44
+                    sftp = paramiko.SFTPClient.from_transport(transport)
45
+                    #FIXME: send file recursively
46
+
47
+                    #sftp.put(filepath, data_root_dir + filepath[1:])
48
+                    sftp.close()
49
+                    transport.close()
50
+                
51
+                else:
52
+                    pass
53
+
54
+if __name__ == '__main__':
55
+    while True:
56
+        main()

Loading…
İptal
Kaydet