From c364ddd185d7b45dfabc3a68a050fd615647b2fc Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Wed, 19 Sep 2007 15:55:56 +0000 Subject: [PATCH] make solr.py work with current server git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@577338 13f79535-47bb-0310-9956-ffa450edef68 --- client/python/solr.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/client/python/solr.py b/client/python/solr.py index 9dc4be44961..8edd3e1d2bd 100644 --- a/client/python/solr.py +++ b/client/python/solr.py @@ -37,10 +37,18 @@ import urllib class SolrException(Exception): - def __init__(self, httpcode, appcode=None, reason=None, body=None): - self.httpcode,self.appcode,self.reason,self.body = httpcode,appcode,reason,body - def __str__(self): - return 'HTTP code=%s, Application code=%s, Reason=%s, body=%s' % (self.httpcode,self.appcode,self.reason,self.body) + """ An exception thrown by solr connections """ + def __init__(self, httpcode, reason=None, body=None): + self.httpcode = httpcode + self.reason = reason + self.body = body + + def __repr__(self): + return 'HTTP code=%s, Reason=%s, body=%s' % ( + self.httpcode, self.reason, self.body) + + def __str__(self): + return 'HTTP code=%s, reason=%s' % (self.httpcode, self.reason) class SolrConnection: @@ -72,7 +80,7 @@ class SolrConnection: def __errcheck(self,rsp): if rsp.status != 200: - ex = SolrException(rsp.status) + ex = SolrException(rsp.status, rsp.reason) try: ex.body = rsp.read() except: @@ -99,14 +107,15 @@ class SolrConnection: data = rsp.read() finally: if not self.persistent: self.conn.close() - #fast path... don't parse XML if we recognize response as success - if not data.startswith('