Repository for M.A.I.L system's analysis server.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

auto_extract.py 4.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import os
  2. import sys
  3. import glob
  4. import time
  5. import threading
  6. import paramiko
  7. hdd_root = '/hdd/*'
  8. def cmd_run(index, shell_cmd):
  9. sh = shell_cmd[index]
  10. os.system(sh)
  11. def main():
  12. surgery_list = glob.glob(hdd_root)
  13. for id in surgery_list:
  14. if 'lost+found' in id:
  15. surgery_list.remove(id)
  16. else:
  17. pass
  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. thread_list = []
  27. f = open(file, 'at')
  28. r_time = time.ctime(time.time())
  29. f.write('exectue is successfully starts at ' + str(r_time) + '\n')
  30. f.close()
  31. cmd_list = ['docker run --rm --name extract_2 --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.5 python3 /sources/extract_02.py ' + id + '/', 'echo ext_1 start']
  32. for index in range(0, len(cmd_list)):
  33. thread_list.append(threading.Thread(target=cmd_run,args=(index,cmd_list)))
  34. thread_list[index].start()
  35. 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.5 python3 /sources/extract_01.py ' + id + '/')
  36. f = open(file, 'at')
  37. r_time = time.ctime(time.time())
  38. f.write('exectue is successfully ends at ' + str(r_time) + '\n')
  39. f.close()
  40. #NOTE: Starting global coordinate
  41. f = open(file, 'at')
  42. r_time = time.ctime(time.time())
  43. f.write('global coordinate successfully starts at ' + str(r_time) + '\n')
  44. f.close()
  45. #FIXME: change coordinate_g.py when IMU sensor works
  46. os.system('docker run --rm --name coordinate --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.5 python3 /sources/coordinate_g.py ' + id + '/ >> /dev/null')
  47. f = open(file, 'at')
  48. r_time = time.ctime(time.time())
  49. f.write('global coordinate successfully ends at ' + str(r_time) + '\n')
  50. f.close()
  51. #NOTE:
  52. f = open(file, 'at')
  53. r_time = time.ctime(time.time())
  54. f.write('kpi successfully starts at ' + str(r_time) + '\n')
  55. f.close()
  56. #FIXME: change coordinate_g.py when IMU sensor works and get generic optimizer for DBSCAN
  57. os.system('docker run --rm --name kpi --gpus '"device=1"' -v /dev:/dev -v /home/mc365/sources:/sources -v /hdd:/hdd ellishuntingmoon/mailsys:0.5 python3 /sources/kpi.py ' + id + '/ >> /dev/null')
  58. f = open(file, 'at')
  59. r_time = time.ctime(time.time())
  60. f.write('kpi successfully ends at ' + str(r_time) + '\n')
  61. f.close()
  62. transport = paramiko.Transport(('365mc.iptime.org', 63122))
  63. transport.connect(username='mc365', password='tkadbrdhMC1!')
  64. sftp = paramiko.SFTPClient.from_transport(transport)
  65. #FIXME: send file recursively
  66. full_list = glob.glob(id + "/*")
  67. for f in full_list:
  68. print(f)
  69. print(f[5:])
  70. sftp.put(f,'/data/'+str(f[5:]))
  71. sftp.close()
  72. transport.close()
  73. os.system('rm -rf '+id)
  74. else:
  75. pass
  76. if __name__ == '__main__':
  77. while True:
  78. main()
  79. time.sleep(900)