Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stone <michael@laptop.org>2010-12-18 22:16:51 (GMT)
committer Michael Stone <michael@laptop.org>2010-12-19 00:43:53 (GMT)
commitef5b822063b937352cf6a76bb471cf6fbc3e61ec (patch)
tree834324e0b2a438ec2abba806199d11712b3a9490
parent9b9131cec86312818dc39b19206915c9d4d20b21 (diff)
Use cgitb for verbose tracebacks.ms/sh2py
-rwxr-xr-xbin/rainbow-easy4
-rwxr-xr-xbin/rainbow-gc4
-rwxr-xr-xbin/rainbow-resume4
-rwxr-xr-xbin/rainbow-run5
-rwxr-xr-xbin/rainbow-sugarize4
-rwxr-xr-xbin/rainbow-xify4
-rw-r--r--rainbow/util.py20
7 files changed, 20 insertions, 25 deletions
diff --git a/bin/rainbow-easy b/bin/rainbow-easy
index e97b254..9955007 100755
--- a/bin/rainbow-easy
+++ b/bin/rainbow-easy
@@ -6,9 +6,9 @@ import sys
from os.path import join
from optparse import OptionParser
-from rainbow.util import make_reporter, trace, EnvMerge
+from rainbow.util import enable_verbose_tracebacks, make_reporter, EnvMerge
-sys.excepthook = trace
+enable_verbose_tracebacks()
usage = "usage: sudo %prog [options] ACTIVITY /path/to/program"
diff --git a/bin/rainbow-gc b/bin/rainbow-gc
index 6f1d99a..efcec8f 100755
--- a/bin/rainbow-gc
+++ b/bin/rainbow-gc
@@ -8,7 +8,9 @@ from os.path import join, isdir, islink, exists
from optparse import OptionParser
from glob import glob
-from rainbow.util import trace, make_reporter
+from rainbow.util import make_reporter, enable_verbose_tracebacks
+
+enable_verbose_tracebacks()
def active_uid(uid):
cmd = ['/usr/bin/pgrep', '-U', uid]
diff --git a/bin/rainbow-resume b/bin/rainbow-resume
index b787990..1cf919a 100755
--- a/bin/rainbow-resume
+++ b/bin/rainbow-resume
@@ -6,9 +6,9 @@ import sys
from os.path import join
from optparse import OptionParser
-from rainbow.util import make_reporter, trace, EnvMerge
+from rainbow.util import make_reporter, enable_verbose_tracebacks, EnvMerge
-sys.excepthook = trace
+enable_verbose_tracebacks()
usage = "usage: sudo %prog [options] RESUME_UID /path/to/program"
diff --git a/bin/rainbow-run b/bin/rainbow-run
index 70ba823..fc5aed5 100755
--- a/bin/rainbow-run
+++ b/bin/rainbow-run
@@ -12,9 +12,10 @@ from pprint import pformat
from rainbow.inject import inject
from rainbow.permissions import PermissionSet
-from rainbow.util import make_reporter, trace, unshare, CLONE_NEWNS, read_envdir
+from rainbow.util import make_reporter, enable_verbose_tracebacks
+from rainbow.util import unshare, CLONE_NEWNS, read_envdir
-sys.excepthook = trace
+enable_verbose_tracebacks()
def main():
parser = OptionParser(version='0.1')
diff --git a/bin/rainbow-sugarize b/bin/rainbow-sugarize
index ec0f119..694f261 100755
--- a/bin/rainbow-sugarize
+++ b/bin/rainbow-sugarize
@@ -8,9 +8,9 @@ from os.path import join, isdir, dirname, exists
from optparse import OptionParser
from shutil import copyfile
-from rainbow.util import make_reporter, trace, make_dirs
+from rainbow.util import make_reporter, enable_verbose_tracebacks, make_dirs
-sys.excepthook = trace
+enable_verbose_tracebacks()
def main():
parser = OptionParser(version='0.1')
diff --git a/bin/rainbow-xify b/bin/rainbow-xify
index c2f633e..2aafb76 100755
--- a/bin/rainbow-xify
+++ b/bin/rainbow-xify
@@ -8,9 +8,9 @@ from os.path import join, isdir, dirname, exists
from optparse import OptionParser
from shutil import copyfile
-from rainbow.util import make_reporter, trace, make_dirs
+from rainbow.util import make_reporter, enable_verbose_tracebacks, make_dirs
-sys.excepthook = trace
+enable_verbose_tracebacks()
def main():
parser = OptionParser(version='0.1')
diff --git a/rainbow/util.py b/rainbow/util.py
index d0a56e8..8217d3c 100644
--- a/rainbow/util.py
+++ b/rainbow/util.py
@@ -1,6 +1,6 @@
from __future__ import with_statement
-import os
+import os, sys
from stat import ST_MODE, ST_UID, ST_GID, S_ISREG
@@ -75,19 +75,11 @@ def profile(profiler):
return inner
return wrapper
-def trace(etype=None, value=None, tb=None):
- try:
- from IPython.ultraTB import AutoFormattedTB
- trace_any = AutoFormattedTB(mode='Verbose', color_scheme='NoColor', call_pdb=0)
- trace_exact = trace_any
- except:
- from traceback import print_exc, print_exception
- trace_any = print_exc
- trace_exact = print_exception
- if etype or value or tb:
- trace_exact(etype, value, tb)
- else:
- trace_any()
+def enable_verbose_tracebacks():
+ import sys, cgitb
+ cgitb.enable(format="plain")
+ cgitb.handler = sys.excepthook.handle
+ return cgitb.handler
### File mode checking.