From b89f0955649c289329419091f0d62b8788e5309f Mon Sep 17 00:00:00 2001 From: Chris Northwood Date: Tue, 9 Nov 2010 15:08:52 +0000 Subject: [PATCH] Correctly create an issue when an exception is raised --- .gitignore | 2 ++ django_jira/middleware.py | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..27ffc2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +build diff --git a/django_jira/middleware.py b/django_jira/middleware.py index f0f9c68..f63871e 100644 --- a/django_jira/middleware.py +++ b/django_jira/middleware.py @@ -1,9 +1,10 @@ import traceback import hashlib +import sys from django.conf import settings from django.core.exceptions import MiddlewareNotUsed -import SOAPpy +import suds.client class JiraExceptionReporterMiddleware: @@ -23,10 +24,10 @@ def __init__(self): settings.JIRA_ISSUE_DEFAULTS # Set up SOAP - self._soap = SOAPpy.WSDL.Proxy(settings.JIRA_URL + 'rpc/soap/jirasoapservice-v2?wsdl') + self._soap = suds.client.Client(settings.JIRA_URL + 'rpc/soap/jirasoapservice-v2?wsdl') # Authenticate - self._auth = self._soap.login(JIRA_USER, JIRA_PASSWORD) + self._auth = self._soap.service.login(settings.JIRA_USER, settings.JIRA_PASSWORD) except AttributeError: raise MiddlewareNotUsed @@ -41,8 +42,10 @@ def process_exception(self, request, exc): # Otherwise, create it issue = settings.JIRA_ISSUE_DEFAULTS.copy() - issue['summary'] = traceback.format_exception_only(type(exc))[0] - issue['description'] = traceback.format_exc() + print exc + issue['summary'] = traceback.format_exception_only(type(exc), exc)[0] + issue['description'] = '{noformat:title=Traceback}\n' + traceback.format_exc() + '\n{noformat}\n\n' + \ + '{noformat:title=Request}\n' + repr(request) + '\n{noformat}' - self._soap.createIssue(self._auth, issue) + print self._soap.service.createIssue(self._auth, issue) \ No newline at end of file