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 3.9KB

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