Merge lp:~stefanor/ibid/google-380918 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 644
Merged at revision: 654
Proposed branch: lp:~stefanor/ibid/google-380918
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/google-380918
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6910@code.launchpad.net
To post a comment you must log in.
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
1=== modified file 'ibid/plugins/google.py'
2--- ibid/plugins/google.py 2009-05-01 12:17:57 +0000
3+++ ibid/plugins/google.py 2009-05-30 18:53:10 +0000
4@@ -45,7 +45,12 @@
5
6 @match(r'^google\s+(?:for\s+)?(.+?)$')
7 def search(self, event, query):
8- items = self._google_api_search(query)
9+ try:
10+ items = self._google_api_search(query)
11+ except BadStatusLine:
12+ event.addresponse(u"Google appears to be broken (or more likely, my connection to it)")
13+ return
14+
15 results = []
16 for item in items["responseData"]["results"]:
17
18@@ -60,8 +65,13 @@
19
20 @match(r'^(?:rank|(?:google(?:fight|compare|cmp)))\s+(?:for\s+)?(.+?)\s+and\s+(.+?)$')
21 def googlefight(self, event, term1, term2):
22- count1 = int(self._google_api_search(term1, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
23- count2 = int(self._google_api_search(term2, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
24+ try:
25+ count1 = int(self._google_api_search(term1, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
26+ count2 = int(self._google_api_search(term2, "small")["responseData"]["cursor"].get("estimatedResultCount", 0))
27+ except BadStatusLine:
28+ event.addresponse(u"Google appears to be broken (or more likely, my connection to it)")
29+ return
30+
31 event.addresponse(u'%(firstterm)s wins with %(firsthits)i hits, %(secondterm)s had %(secondhits)i hits',
32 (count1 > count2 and {
33 'firstterm': term1,

Subscribers

People subscribed via source and target branches