diff options
| author | viega | 1998-06-14 00:58:33 +0000 |
|---|---|---|
| committer | viega | 1998-06-14 00:58:33 +0000 |
| commit | 8dfd4643c7d8216cfbf6e180ed7b868715b9e775 (patch) | |
| tree | 9b4856eea1d6dfc3afb2a055fe71c61328197e72 /Mailman/runcgi.py | |
| parent | c29ba417e715cce7f70c195bf437755639a85ed6 (diff) | |
| download | mailman-8dfd4643c7d8216cfbf6e180ed7b868715b9e775.tar.gz mailman-8dfd4643c7d8216cfbf6e180ed7b868715b9e775.tar.zst mailman-8dfd4643c7d8216cfbf6e180ed7b868715b9e775.zip | |
Provides a method wrap_func(func, debug, print_env). If debug is off,
the StampedLogger is initialized. If debug is on, or the
StampedLogger errors, func is run in a try-except block. If there's
an error, it's printed to the web page, along with the environment if
print_env is on.
Based off Michael McLay's subscribe script, but I wanted to avoid as
much code duplication as possible, which led to this strategy.
Diffstat (limited to 'Mailman/runcgi.py')
| -rw-r--r-- | Mailman/runcgi.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Mailman/runcgi.py b/Mailman/runcgi.py new file mode 100644 index 000000000..d35c70ae4 --- /dev/null +++ b/Mailman/runcgi.py @@ -0,0 +1,23 @@ +from Mailman.debug import * + +def wrap_func(func, debug=1, print_env=1): + if not debug: + try: + sys.stderr = mm_utils.StampedLogger("error", label = 'admin', + manual_reprime=1, nofail=0) + except: + # Error opening log, show thru anyway! + wrap_func(func, print_env=print_env, debug=1) + return + func() + return + else: + try: + func() + except SystemExit: + pass + except: + print_trace() + if print_env: + print_environ() + |
