diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-05-06 12:30:03 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-05-06 12:30:03 -0400 |
commit | 31645710cbb926f6859f38e5feb11e3263925478 (patch) | |
tree | a6dec900508a14204d1dab88bf2a17ca9d0bc6ea /cobbler | |
parent | 66d034de6a272f24c4afe023c211c4857e64dc72 (diff) | |
download | third_party-cobbler-31645710cbb926f6859f38e5feb11e3263925478.tar.gz third_party-cobbler-31645710cbb926f6859f38e5feb11e3263925478.tar.xz third_party-cobbler-31645710cbb926f6859f38e5feb11e3263925478.zip |
Redo exception handling code for older python to eliminate tracebacks that
should not be printed.
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/cexceptions.py | 3 | ||||
-rwxr-xr-x | cobbler/cobbler.py | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/cobbler/cexceptions.py b/cobbler/cexceptions.py index a78f7f2..dba2857 100644 --- a/cobbler/cexceptions.py +++ b/cobbler/cexceptions.py @@ -20,6 +20,9 @@ class CobblerException(exceptions.Exception): def __init__(self, value, *args): self.value = value % args + # this is a hack to work around some odd exception handling + # in older pythons + self.from_cobbler = 1 def __str__(self): return repr(self.value) diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py index 627e398..160dbc5 100755 --- a/cobbler/cobbler.py +++ b/cobbler/cobbler.py @@ -52,13 +52,11 @@ def main(): try: return BootCLI().run(sys.argv) except Exception, exc: - if isinstance(exc, cexceptions.CobblerException) or \ - isinstance(exc, cexceptions.CX) or \ - str(type(exc)).find("CX") != -1 or \ - str(type(exc)).find("CobblerException") != -1: - print str(exc)[1:-1] # remove framing air quotes - else: - traceback.print_exc() + try: + getattr(exc, "from_cobbler") + print str(exc)[1:-1] + except: + traceback.print_exc() return 1 if __name__ == "__main__": |