From 42caed7330ea14197ebd316a0b1bb49568b4aa79 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Tue, 28 Jan 2014 04:42:41 +0100 Subject: [PATCH] =?utf8?q?[server]=20Meilleur=20d=C3=A9bugging=20des=20exc?= =?utf8?q?eptions?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- today_server.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/today_server.py b/today_server.py index abff785..882b43b 100755 --- a/today_server.py +++ b/today_server.py @@ -18,6 +18,8 @@ import sys import urllib import json import traceback +import inspect +import pprint os.chdir('/home/vincent/scripts/today/') sys.path.append("/home/vincent/scripts/dtc/") import dtc @@ -182,8 +184,14 @@ def fetch_all(): try: news[k] = f() except Exception as e: - print "Erreur à la récupération de %s :" % k - traceback.print_exc() + errmsg = "Erreur à la récupération de %s :\n" % k + errmsg += traceback.format_exc() + # On dumpe le contenu local de la mémoire au moment de l'exception + fobj = inspect.trace()[-1][0] + # On fait un peu de ménage + d = {k:v for (k,v) in fobj.f_locals.items() if not k.startswith("_")} + errmsg += "\nContexte : %s\n\n" % (pprint.pformat(d)) + print errmsg return news def sync(): -- 2.39.2