Merge lp:~ricardokirkner/click-reviewers-tools/frameworks-from-api into lp:click-reviewers-tools

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Daniel Holbach
Approved revision: 241
Merged at revision: 240
Proposed branch: lp:~ricardokirkner/click-reviewers-tools/frameworks-from-api
Merge into: lp:click-reviewers-tools
Diff against target: 124 lines (+38/-28)
4 files modified
clickreviews/apparmor_policy.py (+2/-1)
clickreviews/frameworks.py (+1/-3)
clickreviews/remote.py (+14/-6)
data/frameworks.json (+21/-18)
To merge this branch: bzr merge lp:~ricardokirkner/click-reviewers-tools/frameworks-from-api
Reviewer Review Type Date Requested Status
Daniel Holbach (community) Approve
Review via email: mp+235029@code.launchpad.net

Commit message

download framework data from myapps api

To post a comment you must log in.
241. By Ricardo Kirkner

updated frameworks.json using myapps api

Revision history for this message
Daniel Holbach (dholbach) wrote :

Thanks a lot - good work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clickreviews/apparmor_policy.py'
2--- clickreviews/apparmor_policy.py 2014-07-18 20:23:21 +0000
3+++ clickreviews/apparmor_policy.py 2014-09-19 17:20:28 +0000
4@@ -27,7 +27,8 @@
5 def get_policy_file(fn):
6 if fn is None:
7 fn = USER_DATA_FILE
8- clickreviews.remote.get_remote_file(fn, AA_POLICY_DATA_URL)
9+ file_url = clickreviews.remote.get_remote_file_url(AA_POLICY_DATA_URL)
10+ clickreviews.remote.get_remote_file(fn, file_url)
11
12
13 class ApparmorPolicy(object):
14
15=== modified file 'clickreviews/frameworks.py'
16--- clickreviews/frameworks.py 2014-07-18 20:23:21 +0000
17+++ clickreviews/frameworks.py 2014-09-19 17:20:28 +0000
18@@ -17,10 +17,8 @@
19 import clickreviews.remote
20
21 USER_DATA_FILE = os.path.join(clickreviews.remote.DATA_DIR, 'frameworks.json')
22-
23-# XXX: This is a hack and will be gone, as soon as myapps has an API for this.
24 FRAMEWORKS_DATA_URL = \
25- "http://bazaar.launchpad.net/~ubuntu-core-dev/+junk/frameworks/view/head:/frameworks.json"
26+ "https://myapps.developer.ubuntu.com/dev/api/click-framework/"
27
28
29 def get_frameworks_file(fn):
30
31=== modified file 'clickreviews/remote.py'
32--- clickreviews/remote.py 2014-07-18 20:23:21 +0000
33+++ clickreviews/remote.py 2014-09-19 17:20:28 +0000
34@@ -52,14 +52,20 @@
35 #
36 # Public
37 #
38-def get_remote_file(fn, url, data_dir=DATA_DIR):
39+def get_remote_data(url):
40 try:
41 f = request.urlopen(url)
42 except (HTTPError, URLError) as error:
43 abort('Data not retrieved because %s.' % error)
44 except timeout:
45 abort('Socket timed out.')
46- html = f.read()
47+ if not f:
48+ abort()
49+ return f.read()
50+
51+
52+def get_remote_file_url(url):
53+ html = get_remote_data(url)
54 # XXX: This is a hack and will be gone, as soon as myapps has an API for this.
55 link = re.findall(b'<a href="(\S+?)">download file</a>', html)
56 if not link:
57@@ -68,15 +74,17 @@
58 parse.urlparse(url).scheme,
59 parse.urlparse(url).netloc,
60 link[0].decode("utf-8"))
61- f = request.urlopen(download_link)
62- if not f:
63- abort()
64+ return download_link
65+
66+
67+def get_remote_file(fn, url, data_dir=DATA_DIR):
68+ data = get_remote_data(url)
69 if os.path.exists(fn):
70 os.remove(fn)
71 if not os.path.exists(os.path.dirname(fn)):
72 os.makedirs(os.path.dirname(fn))
73 with open(fn, 'bw') as local_file:
74- local_file.write(f.read())
75+ local_file.write(data)
76
77
78 def read_cr_file(fn, url, local_copy_fn=None):
79
80=== modified file 'data/frameworks.json'
81--- data/frameworks.json 2014-07-30 16:33:54 +0000
82+++ data/frameworks.json 2014-09-19 17:20:28 +0000
83@@ -1,20 +1,23 @@
84 {
85- "ubuntu-sdk-13.10": "deprecated",
86- "ubuntu-sdk-14.04-dev1": "deprecated",
87- "ubuntu-sdk-14.04-html-dev1": "deprecated",
88- "ubuntu-sdk-14.04-papi-dev1": "deprecated",
89- "ubuntu-sdk-14.04-qml-dev1": "deprecated",
90- "ubuntu-sdk-14.04": "available",
91- "ubuntu-sdk-14.04-html": "available",
92- "ubuntu-sdk-14.04-papi": "available",
93- "ubuntu-sdk-14.04-qml": "available",
94- "ubuntu-sdk-14.10-dev1": "obsolete",
95- "ubuntu-sdk-14.10-html-dev1": "obsolete",
96- "ubuntu-sdk-14.10-papi-dev1": "obsolete",
97- "ubuntu-sdk-14.10-qml-dev1": "obsolete",
98- "ubuntu-sdk-14.10-dev2": "available",
99- "ubuntu-sdk-14.10-html-dev2": "available",
100- "ubuntu-sdk-14.10-papi-dev2": "available",
101- "ubuntu-sdk-14.10-qml-dev2": "available",
102- "ubuntu-sdk-14.10-qml-dev3": "available"
103+ "ubuntu-sdk-13.10": "deprecated",
104+ "ubuntu-sdk-14.04-html": "available",
105+ "ubuntu-sdk-14.04-qml-dev1": "deprecated",
106+ "ubuntu-sdk-14.10-qml-dev3": "available",
107+ "ubuntu-sdk-14.10-papi-dev3": "available",
108+ "ubuntu-sdk-14.04-html-dev1": "deprecated",
109+ "ubuntu-sdk-14.10-papi-dev1": "obsolete",
110+ "ubuntu-sdk-14.04-papi-dev1": "deprecated",
111+ "ubuntu-sdk-14.10-dev2": "available",
112+ "ubuntu-sdk-14.04": "available",
113+ "ubuntu-sdk-14.10-dev3": "available",
114+ "ubuntu-sdk-14.10-qml-dev1": "obsolete",
115+ "ubuntu-sdk-14.04-dev1": "deprecated",
116+ "ubuntu-sdk-14.10-dev1": "obsolete",
117+ "ubuntu-sdk-14.04-papi": "available",
118+ "ubuntu-sdk-14.04-qml": "available",
119+ "ubuntu-sdk-14.10-papi-dev2": "available",
120+ "ubuntu-sdk-14.10-html-dev3": "available",
121+ "ubuntu-sdk-14.10-html-dev2": "available",
122+ "ubuntu-sdk-14.10-html-dev1": "obsolete",
123+ "ubuntu-sdk-14.10-qml-dev2": "available"
124 }

Subscribers

People subscribed via source and target branches