Debug.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from . import StringFormat
  4. import sys
  5. import platform
  6. platformName = platform.system()
  7. if platformName == 'Linux':
  8. from .Linux import LinuxCMDColorPrint
  9. PrintTool = LinuxCMDColorPrint.LinuxCMDColorPrint()
  10. elif platformName == 'Windows':
  11. from .Windows import WindowsCMDColorPrint
  12. PrintTool = WindowsCMDColorPrint.WindowsCMDColorPrint()
  13. elif platformName == 'Darwin':
  14. from .Linux import LinuxCMDColorPrint
  15. PrintTool = LinuxCMDColorPrint.LinuxCMDColorPrint()
  16. else:
  17. PrintTool = None
  18. def Log(content, noTag=True):
  19. """
  20. 打印信息,需要格式化的String,请使用LogFormat
  21. """
  22. if noTag:
  23. content = StringFormat.FormatStdoutString(
  24. str(content))
  25. else:
  26. content = StringFormat.FormatStdoutString(
  27. str("Debug : %s" % content))
  28. print(content)
  29. def LogSuccess(content, noTag=True):
  30. """
  31. 打印警告信息
  32. """
  33. if noTag:
  34. content = StringFormat.FormatStdoutString(
  35. str(content))
  36. else:
  37. content = StringFormat.FormatStdoutString(
  38. str("Debug : %s" % content))
  39. if PrintTool:
  40. PrintTool.printGreen(content)
  41. else:
  42. print(content)
  43. def LogWaring(content, noTag=False):
  44. """
  45. 打印警告信息
  46. """
  47. if noTag:
  48. content = StringFormat.FormatStdoutString(
  49. str(content))
  50. else:
  51. content = StringFormat.FormatStdoutString(
  52. str("Waring : %s" % content))
  53. if PrintTool:
  54. PrintTool.printYellow(content)
  55. else:
  56. print(content)
  57. def LogError(content, noTag=False):
  58. """
  59. 打印错误信息
  60. """
  61. if noTag:
  62. content = StringFormat.FormatStdoutString(
  63. str(content))
  64. else:
  65. content = StringFormat.FormatStdoutString(
  66. str("Error : %s" % content))
  67. if PrintTool:
  68. PrintTool.printRed(content)
  69. else:
  70. print(content)
  71. def LogException(content, noTag=False):
  72. """
  73. 打印错误信息
  74. """
  75. if noTag:
  76. content = StringFormat.FormatStdoutString(
  77. str(content))
  78. else:
  79. content = StringFormat.FormatStdoutString(
  80. str("Exception : %s" % content))
  81. if PrintTool:
  82. PrintTool.printRed(content)
  83. else:
  84. print(content)