Debug.py 765 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python2
  2. #
  3. # Copyright 2011 Nick Mathewson, Michael Stone
  4. # Copyright 2013 The Tor Project
  5. #
  6. # You may do anything with this work that copyright law would normally
  7. # restrict, so long as you retain the above notice(s) and this license
  8. # in all redistributed copies and derived works. There is no warranty.
  9. from __future__ import print_function
  10. import cgitb
  11. import os
  12. # Get verbose tracebacks, so we can diagnose better.
  13. cgitb.enable(format="plain")
  14. # Set debug_flag=True in order to debug this program or to get hints
  15. # about what's going wrong in your system.
  16. debug_flag = os.environ.get("CHUTNEY_DEBUG", "") != ""
  17. def debug(s):
  18. "Print a debug message on stdout if debug_flag is True."
  19. if debug_flag:
  20. print("DEBUG: %s" % s)