[Yum-devel] [PATCH 1/2] add a way to run yum inside pdb like we do with the profiler and capture the keyboardinterrupt in sys.excepthook
Seth Vidal
skvidal at fedoraproject.org
Thu Sep 17 20:05:45 UTC 2009
pdb is just handy sometimes
sys.excepthook keeps urlgrabber/yum from spewing crap across the screen when someone hits ctrl-c
---
yummain.py | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/yummain.py b/yummain.py
index 964975b..029a0ad 100755
--- a/yummain.py
+++ b/yummain.py
@@ -31,6 +31,18 @@ from yum import _
from yum.i18n import to_unicode
import yum.misc
import cli
+import exceptions
+
+def suppress_keyboard_interrupt_message():
+ old_excepthook = sys.excepthook
+
+ def new_hook(type, value, traceback):
+ if type != exceptions.KeyboardInterrupt:
+ old_excepthook(type, value, traceback)
+ else:
+ pass
+
+ sys.excepthook = new_hook
def main(args):
@@ -307,12 +319,18 @@ def user_main(args, exit_code=False):
errcode = cprof(main, args)
if os.environ['YUM_PROF'] == 'hotshot':
errcode = hotshot(main, args)
+ if 'YUM_PDB' in os.environ:
+ import pdb
+ pdb.run(main(args))
+
if errcode is None:
errcode = main(args)
if exit_code:
sys.exit(errcode)
return errcode
+suppress_keyboard_interrupt_message()
+
if __name__ == "__main__":
try:
user_main(sys.argv[1:], exit_code=True)
--
1.6.2.5
More information about the Yum-devel
mailing list