Merge lp:~stefanor/ibid/none-response-377574 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 645
Merged at revision: 655
Proposed branch: lp:~stefanor/ibid/none-response-377574
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/none-response-377574
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6908@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Debugging this one was a bitch because the bug stopped Dazzle from logging the statements that caused it.

In hindsight, it was obvious that the statement would have been "fml"

Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/event.py'
--- ibid/event.py 2009-05-02 19:29:44 +0000
+++ ibid/event.py 2009-05-30 18:26:08 +0000
@@ -18,7 +18,10 @@
18 self[name] = value18 self[name] = value
1919
20 def addresponse(self, response, params={}, processed=True):20 def addresponse(self, response, params={}, processed=True):
21 if isinstance(response, basestring) and params:21 if response is None:
22 # We want to detect this now, so we know which plugin is to blame
23 raise Exception("Can't have a None response")
24 elif isinstance(response, basestring) and params:
22 self.responses.append(response % params)25 self.responses.append(response % params)
23 else:26 else:
24 self.responses.append(response)27 self.responses.append(response)
2528
=== modified file 'ibid/plugins/lookup.py'
--- ibid/plugins/lookup.py 2009-05-12 07:13:41 +0000
+++ ibid/plugins/lookup.py 2009-05-30 18:29:42 +0000
@@ -129,6 +129,9 @@
129 u"Sorry, it's broken, the FML admins must having a really bad day",129 u"Sorry, it's broken, the FML admins must having a really bad day",
130 )130 )
131131
132 class FMLException(Exception):
133 pass
134
132 def remote_get(self, id):135 def remote_get(self, id):
133 url = urljoin(self.api_url, 'view/%s?%s' % (136 url = urljoin(self.api_url, 'view/%s?%s' % (
134 id.isalnum() and id + '/nocomment' or quote(id),137 id.isalnum() and id + '/nocomment' or quote(id),
@@ -137,7 +140,7 @@
137 dom = parse(urlopen(url))140 dom = parse(urlopen(url))
138141
139 if dom.getElementsByTagName('error'):142 if dom.getElementsByTagName('error'):
140 return143 raise FMLException(dom.getElementsByTagName('error')[0]childNodes[0].nodeValue)
141144
142 items = dom.getElementsByTagName('item')145 items = dom.getElementsByTagName('item')
143 if items: 146 if items:
@@ -162,6 +165,9 @@
162 def fml(self, event, id):165 def fml(self, event, id):
163 try:166 try:
164 quote = self.remote_get(id)167 quote = self.remote_get(id)
168 except FMLException:
169 event.addresponse(choice(self.failure_messages) % event.sender)
170 return
165 except HTTPError:171 except HTTPError:
166 event.addresponse(choice(self.failure_messages) % event.sender)172 event.addresponse(choice(self.failure_messages) % event.sender)
167 return173 return
@@ -175,9 +181,10 @@
175 def fml_default(self, event):181 def fml_default(self, event):
176 try:182 try:
177 event.addresponse(self.remote_get('random'))183 event.addresponse(self.remote_get('random'))
184 except FMLException:
185 event.addresponse(choice(self.failure_messages) % event.sender)
178 except HTTPError:186 except HTTPError:
179 event.addresponse(choice(self.failure_messages) % event.sender)187 event.addresponse(choice(self.failure_messages) % event.sender)
180 return
181188
182 @match(r'^fml\s+categories$')189 @match(r'^fml\s+categories$')
183 def list_categories(self, event):190 def list_categories(self, event):

Subscribers

People subscribed via source and target branches