[Yum-devel] [PATCH 2/2] move the sys.excepthook over to utils.py and hook it up there.
Tim Lauridsen
tim.lauridsen at googlemail.com
Fri Sep 18 06:41:37 UTC 2009
On 09/17/2009 10:05 PM, Seth Vidal wrote:
> 1. b/c it is tidier over therw
> 2. b/c now yum-utils using that class get it by default
> ---
> utils.py | 13 ++++++++++++-
> yummain.py | 14 +-------------
> 2 files changed, 13 insertions(+), 14 deletions(-)
>
> 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"""
ACK
Tim
More information about the Yum-devel
mailing list