《操作系统》的实验代码。
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.

29 lines
822 B

  1. #!/usr/bin/env python
  2. #
  3. # Note: This script is intended to be executed at labcodes/labX
  4. import sys, os
  5. import re
  6. if len(sys.argv) < 2:
  7. print 'Usage: split_score_log.py <raw log file> <lab>'
  8. sys.exit()
  9. raw_log_f = sys.argv[1]
  10. test_entry_title = re.compile('^([\w][\w -]+): *\([0-9.]*s\)')
  11. raw_log = open(raw_log_f, 'r')
  12. current_test = ''
  13. for line in raw_log.readlines():
  14. line = line.strip('\n')
  15. m = test_entry_title.match(line)
  16. if m:
  17. print line
  18. current_test = m.group(1)
  19. error_log = open('.' + current_test.lower().replace(' ', '_') + '.error', 'w+')
  20. print >> error_log, line
  21. continue
  22. if (not line or line[0] == ' ') and current_test != '':
  23. print >> error_log, line
  24. if (line and line[0] != ' ') or line.find('-check') >= 0:
  25. print line