From 105c625e1e24e259fbdf11e0a88566a77698c7a0 Mon Sep 17 00:00:00 2001 From: oysteini Date: Tue, 11 May 2010 16:38:30 +0000 Subject: [PATCH] Konfigurasjonsflagg for hvorvidt tracebacks skal vises. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fjernet et str-kall som fikk Python til å krangle om tegnkoding. --- conf.py | 1 + text_based.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/conf.py b/conf.py index 083f4f8..1830813 100644 --- a/conf.py +++ b/conf.py @@ -1,2 +1,3 @@ db_url = 'sqlite:///data' quit_allowed = True +show_tracebacks = True diff --git a/text_based.py b/text_based.py index 65d17df..f68e6ba 100644 --- a/text_based.py +++ b/text_based.py @@ -3,6 +3,7 @@ import sqlalchemy import re import sys +import traceback from helpers import * exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death'] @@ -68,7 +69,7 @@ class Menu(): elif isinstance(self.items[i], tuple): return self.items[i][1] else: - return str(self.items[i]) + return self.items[i] def item_value(self, i): if isinstance(self.items[i], tuple): @@ -645,6 +646,8 @@ while True: except: print 'Something went wrong.' print '%s: %s' % sys.exc_info()[0:2] + if conf.show_tracebacks: + traceback.print_tb(sys.exc_info()[2]) else: break print 'Restarting main menu.'