[yum-commits] Branch 'yum-3_2_X' - 2 commits - utils.py yummain.py

skvidal at osuosl.org skvidal at osuosl.org
Thu Sep 17 20:09:03 UTC 2009


 utils.py   |   13 ++++++++++++-
 yummain.py |    8 +++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit 4cfd80c51944cf0d2488633c761361e39b84db73
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Sep 17 16:02:42 2009 -0400

    move the sys.excepthook over to utils.py and hook it up there.
    
     1. b/c it is tidier over therw
     2. b/c now yum-utils using that class get it by default

diff --git a/utils.py b/utils.py
index aebb959..945aa65 100644
--- a/utils.py
+++ b/utils.py
@@ -15,6 +15,7 @@
 
 import sys
 import time
+import exceptions
 
 import yum
 from cli import *
@@ -26,6 +27,16 @@ from optparse import OptionGroup
 import yum.plugins as plugins
 
 
+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
 
 class YumUtilBase(YumBaseCli):
     def __init__(self,name,ver,usage):
@@ -36,7 +47,7 @@ class YumUtilBase(YumBaseCli):
         self._utilVer = ver
         self._option_group = OptionGroup(self._parser, "%s options" % self._utilName,"")
         self._parser.add_option_group(self._option_group)
-
+        suppress_keyboard_interrupt_message()
         
     def getOptionParser(self):
         return self._parser        
diff --git a/yummain.py b/yummain.py
index 029a0ad..b2a09cc 100755
--- a/yummain.py
+++ b/yummain.py
@@ -31,19 +31,7 @@ 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
-
+from utils import suppress_keyboard_interrupt_message
 
 def main(args):
     """This does all the real work"""
commit 2c6f0029326a2381fa1cec2b5916d6be9b95b783
Author: Seth Vidal <skvidal at fedoraproject.org>
Date:   Thu Sep 17 14:47:11 2009 -0400

     add a way to run yum inside pdb like we do with the profiler and capture the keyboardinterrupt in sys.excepthook
    
    pdb is just handy sometimes
    sys.excepthook keeps urlgrabber/yum from spewing crap across the screen when someone hits ctrl-c

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)


More information about the Yum-commits mailing list