Repository for M.A.I.L system's analysis server.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

auto_extract.py 1.8KB

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