squashlog.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. #
  9. # Initial Contributors:
  10. # Nokia Corporation - initial contribution.
  11. #
  12. # Contributors:
  13. #
  14. # Description:
  15. # squash a raptor log file by removing commands from successful recipes
  16. #
  17. import sys
  18. inRecipe = False
  19. for line in sys.stdin.readlines():
  20. # escape % characters otherwise print will fail
  21. line = line.replace("%", "%%")
  22. # detect the start of a recipe
  23. if line.startswith("<recipe "):
  24. inRecipe = True
  25. recipeLines = [line]
  26. squashRecipe = True
  27. continue
  28. # detect the status report from a recipe
  29. if line.startswith("<status "):
  30. if not "exit='ok'" in line:
  31. # only squash ok recipes
  32. squashRecipe = False
  33. recipeLines.append(line)
  34. continue
  35. # detect the end of a recipe
  36. if line.startswith("</recipe>"):
  37. # print the recipe
  38. if squashRecipe:
  39. for text in recipeLines:
  40. if not text.startswith("+"):
  41. print text,
  42. else:
  43. for text in recipeLines:
  44. print text,
  45. print line,
  46. continue
  47. # remember the lines during a recipe
  48. if inRecipe:
  49. recipeLines.append(line)
  50. else:
  51. # print all lines outside a recipe
  52. print line,
  53. # end