Merge lp:~stevanr/linaro-android-frontend/bug-1071153 into lp:linaro-android-frontend

Proposed by Stevan Radaković
Status: Merged
Approved by: Georgy Redkozubov
Approved revision: 288
Merged at revision: 289
Proposed branch: lp:~stevanr/linaro-android-frontend/bug-1071153
Merge into: lp:linaro-android-frontend
Diff against target: 136 lines (+45/-32)
4 files modified
android_build/frontend/api.py (+28/-0)
android_build/settings.py (+2/-0)
android_build/urls.py (+1/-0)
static/buildDetails.js (+14/-32)
To merge this branch: bzr merge lp:~stevanr/linaro-android-frontend/bug-1071153
Reviewer Review Type Date Requested Status
Georgy Redkozubov Approve
Linaro Infrastructure Pending
Review via email: mp+131415@code.launchpad.net

Description of the change

Use snapshots API call instead of checking each file individually and using JS textile.

To post a comment you must log in.
Revision history for this message
Georgy Redkozubov (gesha) wrote :

Good to go

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'android_build/frontend/api.py'
2--- android_build/frontend/api.py 2012-10-19 14:18:11 +0000
3+++ android_build/frontend/api.py 2012-10-25 13:59:23 +0000
4@@ -313,6 +313,34 @@
5 else:
6 return HttpResponse(response.read())
7
8+def get_textile_files_request(request):
9+ """Give Web UI a proxy to fetch remote textile file data from snapshots."""
10+
11+ path = ""
12+ for thing in request.GET.getlist("path"):
13+ path = thing
14+
15+ requested_view = 'get-textile-files'
16+ url = settings.SNAPSHOTS_URL + requested_view + '?path=' + path
17+
18+ try:
19+ response = urllib2.urlopen(url)
20+ except urllib2.HTTPError, e:
21+ message = "Server error: %d" % e.code
22+ resp = HttpResponse(message)
23+ resp.status_code = e.code
24+ return resp
25+ except urllib2.URLError, e:
26+ message = "We failed to reach a server."
27+
28+ if isinstance(e.reason, str):
29+ message += " Reason %s" % e.reason
30+
31+ return HttpResponse(message)
32+ else:
33+ return HttpResponse(response.read())
34+
35+
36 def test_remote_dir_exists(request):
37 """Give Web UI the ability to test where a build is stored.
38
39
40=== modified file 'android_build/settings.py'
41--- android_build/settings.py 2012-10-19 14:00:38 +0000
42+++ android_build/settings.py 2012-10-25 13:59:23 +0000
43@@ -106,3 +106,5 @@
44 }
45
46 USE_OWN_COMBO=False
47+
48+SNAPSHOTS_URL = "https://snapshots.linaro.org/"
49
50=== modified file 'android_build/urls.py'
51--- android_build/urls.py 2012-10-19 14:00:38 +0000
52+++ android_build/urls.py 2012-10-25 13:59:23 +0000
53@@ -28,6 +28,7 @@
54 (r'^api/new$', 'android_build.frontend.api.new'),
55 (r'^api/set-daily$', 'android_build.frontend.api.set_daily'),
56 (r'^api/proxy-remote-file$', 'android_build.frontend.api.proxy_remote_file'),
57+ (r'^api/get-textile-files-request$', 'android_build.frontend.api.get_textile_files_request'),
58 (r'^api/test-dir-exists$', 'android_build.frontend.api.test_remote_dir_exists'),
59
60 (r'^openid/', include('django_openid_auth.urls')),
61
62=== modified file 'static/buildDetails.js'
63--- static/buildDetails.js 2012-10-24 11:59:25 +0000
64+++ static/buildDetails.js 2012-10-25 13:59:23 +0000
65@@ -22,23 +22,6 @@
66 var buildNumber = history.get('build');
67 var fetchLatest = (buildNumber === undefined);
68
69- var howto_paths = [
70- "HOWTO_releasenotes.txt",
71- "HOWTO_install.txt",
72- "HOWTO_getsourceandbuild.txt",
73- "HOWTO_flashfirmware.txt",
74- "HOWTO_rtsm.txt"]
75-
76- // Mapping for howto_paths tab titles
77- var howto_titles = [
78- "Release Notes",
79- "Binary Image Installation",
80- "Building From Source",
81- "Firmware Update",
82- "RTSM"]
83-
84-
85-
86
87 var jobData = 'actions[parameters[name,value]],timestamp,duration,artifacts[displayPath,fileName,relativePath],result,number';
88
89@@ -258,7 +241,8 @@
90 to where new builds should be.
91 */
92 var downloadUrl = 'http://snapshots.linaro.org/android/' + rawBuildName + '/' + results.number.toString() + '/';
93- handleRenderedFiles(downloadUrl);
94+ handleRenderedFiles('android/' + rawBuildName + '/' +
95+ results.number.toString());
96
97
98 Y.one('#all-output a').setAttribute('href', downloadUrl);
99@@ -422,25 +406,23 @@
100
101 refreshFromScratch();
102
103- function handleRenderedFiles(downloadUrl) {
104+ function handleRenderedFiles(pathUrl) {
105
106 var rendered_files = new Object();
107 var howto_index = 0;
108
109- for (var howto_index in howto_paths) {
110- $.ajax({
111- url: '/api/proxy-remote-file?url=' + downloadUrl +
112- howto_paths[howto_index],
113- success: function(data) {
114- if (data != 'Invalid argument') {
115- rendered_files[howto_titles[howto_index]] =
116- convert_textile(data);
117+ $.ajax({
118+ url: '/api/get-textile-files-request?path=' + pathUrl,
119+ success: function(data) {
120+ if (data != 'null') {
121+ data = $.parseJSON(data);
122+ for (var key in data) {
123+ rendered_files[key] = data[key];
124 }
125- howto_index++;
126- },
127- async: false,
128- });
129- }
130+ }
131+ },
132+ async: false,
133+ });
134
135 refresh_tabs(rendered_files);
136 }

Subscribers

People subscribed via source and target branches