Repository for M.A.I.L system's analysis server.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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', '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']
  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. f = open(file, 'at')
  35. r_time = time.ctime(time.time())
  36. f.write('exectue is successfully ends at ' + str(r_time) + '\n')
  37. f.close()
  38. #NOTE: Starting global coordinate
  39. f = open(file, 'at')
  40. r_time = time.ctime(time.time())
  41. f.write('global coordinate successfully starts at ' + str(r_time) + '\n')
  42. f.close()
  43. #FIXME: change coordinate_g.py when IMU sensor works
  44. 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')
  45. f = open(file, 'at')
  46. r_time = time.ctime(time.time())
  47. f.write('global coordinate successfully ends at ' + str(r_time) + '\n')
  48. f.close()
  49. #NOTE:
  50. f = open(file, 'at')
  51. r_time = time.ctime(time.time())
  52. f.write('kpi successfully starts at ' + str(r_time) + '\n')
  53. f.close()
  54. #FIXME: change coordinate_g.py when IMU sensor works and get generic optimizer for DBSCAN
  55. 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')
  56. f = open(file, 'at')
  57. r_time = time.ctime(time.time())
  58. f.write('kpi successfully ends at ' + str(r_time) + '\n')
  59. f.close()
  60. transport = paramiko.Transport(('365mc.iptime.org', 63122))
  61. transport.connect(username='mc365', password='tkadbrdhMC1!')
  62. sftp = paramiko.SFTPClient.from_transport(transport)
  63. #FIXME: send file recursively
  64. for file in file_list:
  65. sftp.put(file,'/data/'+str(file[5:]))
  66. sftp.close()
  67. transport.close()
  68. os.system('rm -rf '+id)
  69. else:
  70. pass
  71. if __name__ == '__main__':
  72. while True:
  73. main()