|
@@ -11,6 +11,7 @@ from __future__ import print_function
|
|
|
|
|
|
import cgitb
|
|
|
import os
|
|
|
+import sys
|
|
|
|
|
|
# Get verbose tracebacks, so we can diagnose better.
|
|
|
cgitb.enable(format="plain")
|
|
@@ -24,3 +25,18 @@ def debug(s):
|
|
|
"Print a debug message on stdout if debug_flag is True."
|
|
|
if debug_flag:
|
|
|
print("DEBUG: %s" % s)
|
|
|
+
|
|
|
+
|
|
|
+def main():
|
|
|
+ global debug_flag
|
|
|
+ debug("This message should appear if $CHUTNEY_DEBUG is true.")
|
|
|
+ debug_flag = True
|
|
|
+ debug("This message should always appear.")
|
|
|
+ debug_flag = False
|
|
|
+ debug("This message should never appear.")
|
|
|
+ # We don't test tracebacks, because it's hard to know what to expect
|
|
|
+ # (and they make python exit with a non-zero exit status)
|
|
|
+ return 0
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ sys.exit(main())
|