summaryrefslogtreecommitdiffstats
path: root/cobbler/utils.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-08-18 17:40:37 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-08-18 17:40:37 -0400
commit7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb (patch)
tree05431684d09bb86e6128a55ec88b4388379fabd8 /cobbler/utils.py
parentb0ad5cf706d1040b88726c28741b888b8d04e22d (diff)
downloadcobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.tar.gz
cobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.tar.xz
cobbler-7bb7a308a9e8adaaadeb3b2ee2634ac9655fa7eb.zip
Use pxesystem and pxeprofile templates correctly
Diffstat (limited to 'cobbler/utils.py')
-rw-r--r--cobbler/utils.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/cobbler/utils.py b/cobbler/utils.py
index d55cf149..be1c416e 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -85,19 +85,33 @@ def log_exc(logger):
logger.info("Exception occured: %s" % t )
logger.info("Exception value: %s" % v)
logger.info("Exception Info:\n%s" % string.join(traceback.format_list(traceback.extract_tb(tb))))
+
-def print_exc(exc,full=False):
+def get_exc(exc,full=True):
(t, v, tb) = sys.exc_info()
+ buf = ""
try:
getattr(exc, "from_cobbler")
- print >> sys.stderr, str(exc)[1:-1]
+ buf = str(exc)[1:-1] + "\n"
except:
- print >> sys.stderr, t
- print >> sys.stderr, v
+ buf = buf + "%s" % exc.message
+ buf = sys.stderr, t
+ buf = "%s\n%s" % (buf,v)
if full:
- print >> sys.stderr, string.join(traceback.format_list(traceback.extract_tb(tb)))
- return 1
+ buf = buf + "\n" + "\n".join(traceback.format_list(traceback.extract_tb(tb)))
+ return buf
+def print_exc(exc,full=False):
+ buf = get_exc(exc)
+ sys.stderr.write(buf+"\n")
+ return buf
+
+def cheetah_exc(exc,full=False):
+ lines = get_exc(exc).split("\n")
+ buf = ""
+ for l in lines:
+ buf = buf + "# %s\n" % l
+ return buf
def trace_me():
x = traceback.extract_stack()