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
1=== modified file 'askubuntu_bridge.py'
2--- askubuntu_bridge.py 2011-09-16 01:02:38 +0000
3+++ askubuntu_bridge.py 2011-10-18 02:25:25 +0000
4@@ -24,7 +24,7 @@
5 import json
6 import functools
7 import time
8-
9+import random
10
11 DEFAULT_SITE = "askubuntu.com"
12 SE_API_KEY = "BmtlCGm1UU-Cmn8FAvfT4Q"
13@@ -103,10 +103,16 @@
14 print "api.%s/\33[1;31m%s\33[m" % (site, query)
15 if query.startswith("similar?title") and site == "askubuntu.com":
16 try:
17- result = json.loads(urllib2.urlopen(
18- "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),
19- timeout=0.5).read())
20- print "\33[1mused ec2 service\33[m"
21+ if random.random() > 0.5:
22+ result = json.loads(urllib2.urlopen(
23+ "http://50.19.108.78:8080/%s" % query.replace(" ", "%20"),
24+ timeout=0.5).read())
25+ print "\33[1mused ec2 service\33[m"
26+ else:
27+ result = json.loads(urllib2.urlopen(
28+ "http://audata.quickmediasolutions.com:8046/%s" % query.replace(" ", "%20"),
29+ timeout=0.5).read())
30+ print "\33[1mused AU Data Server service\33[m"
31 return result
32 except Exception as e:
33 print "\33[1;31m%s\33[m" % repr(e)

Subscribers

People subscribed via source and target branches

to all changes: