Merge lp:~george-edison55/askubuntu-lens/added-au-data-server into lp:~markjtully/askubuntu-lens/oneiric

Proposed by Nathan Osman
Status: Merged
Merge reported by: Mark Tully
Merged at revision: not available
Proposed branch: lp:~george-edison55/askubuntu-lens/added-au-data-server
Merge into: lp:~markjtully/askubuntu-lens/oneiric
Diff against target: 33 lines (+11/-5)
1 file modified
askubuntu_bridge.py (+11/-5)
To merge this branch: bzr merge lp:~george-edison55/askubuntu-lens/added-au-data-server
Reviewer Review Type Date Requested Status
Mark Tully Approve
Review via email: mp+79642@code.launchpad.net

Description of the change

I have added another server to the list of services that provide a cached set of data from the Ask Ubuntu API. I have used random.random() to select a server at random to send the request to.

To post a comment you must log in.
Revision history for this message
Stefano Palazzo (stefano-palazzo) wrote :

Fantastic. Did you test if both respond quickly?

Revision history for this message
Nathan Osman (george-edison55) wrote :

Unfortunately, I'm using my Windows machine ATM - so I can't test the lens directly. However, direct queries on the server are working fine.

Revision history for this message
Mark Tully (markjtully) wrote :

Well, it's been merged now. And it works. So, Approve!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'askubuntu_bridge.py'
--- askubuntu_bridge.py 2011-09-16 01:02:38 +0000
+++ askubuntu_bridge.py 2011-10-18 02:25:25 +0000
@@ -24,7 +24,7 @@
24import json24import json
25import functools25import functools
26import time26import time
2727import random
2828
29DEFAULT_SITE = "askubuntu.com"29DEFAULT_SITE = "askubuntu.com"
30SE_API_KEY = "BmtlCGm1UU-Cmn8FAvfT4Q"30SE_API_KEY = "BmtlCGm1UU-Cmn8FAvfT4Q"
@@ -103,10 +103,16 @@
103 print "api.%s/\33[1;31m%s\33[m" % (site, query)103 print "api.%s/\33[1;31m%s\33[m" % (site, query)
104 if query.startswith("similar?title") and site == "askubuntu.com":104 if query.startswith("similar?title") and site == "askubuntu.com":
105 try:105 try:
106 result = json.loads(urllib2.urlopen(106 if random.random() > 0.5:
107 "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),107 result = json.loads(urllib2.urlopen(
108 timeout=0.5).read())108 "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),
109 print "\33[1mused ec2 service\33[m"109 timeout=0.5).read())
110 print "\33[1mused ec2 service\33[m"
111 else:
112 result = json.loads(urllib2.urlopen(
113 "http://audata.quickmediasolutions.com:8046/%s" % query.replace(" ", "%20"),
114 timeout=0.5).read())
115 print "\33[1mused AU Data Server service\33[m"
110 return result116 return result
111 except Exception as e:117 except Exception as e:
112 print "\33[1;31m%s\33[m" % repr(e)118 print "\33[1;31m%s\33[m" % repr(e)

Subscribers

People subscribed via source and target branches

to all changes: