[et-mgmt-tools] [PATCH] Fix traceback on commands run with -h

Michael DeHaan mdehaan at redhat.com
Tue Feb 19 18:47:45 UTC 2008


Jeremy Rosengren wrote:
> Jeremy Rosengren wrote:
>> Michael DeHaan wrote:
>>> I don't agree with the patch, but it looks like your particular 
>>> version of optparse is throwing system.exit in a way that cobbler 
>>> doesn't like and we need to catch that /also/.
>>>
>>> I'll look into it.   Thanks.
>>>
> I looked through the Python documentation and it looks like the 
> SystemExit exception needs to be caught, so I added that to the other 
> exception handling in cobbler.py
>
> I don't claim to know for sure that this is the best way to do it, 
> just that it solves the problem better than my last attempt.
>
> Thanks,
>
> -- j
>
> ---
> cobbler/cobbler.py |    2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
> index fb9b273..9f95f1e 100755
> --- a/cobbler/cobbler.py
> +++ b/cobbler/cobbler.py
> @@ -52,7 +52,7 @@ def main():
>     try:
>         # FIXME: redo locking code?
>         return BootCLI().run(sys.argv)
> -    except CX, exc:
> +    except (CX, SystemExit), exc:
>         print str(exc)[1:-1]  # remove framing air quotes
>     except Exception, exc2:
>         if str(type(exc2)).find("CX") == -1:

Will apply -- (not sure if the double exception catching on one line is 
legal syntax -- but something like it anyway).

Thanks.





More information about the et-mgmt-tools mailing list