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
=== modified file 'clickreviews/apparmor_policy.py'
--- clickreviews/apparmor_policy.py 2014-07-18 20:23:21 +0000
+++ clickreviews/apparmor_policy.py 2014-09-19 17:20:28 +0000
@@ -27,7 +27,8 @@
27def get_policy_file(fn):27def get_policy_file(fn):
28 if fn is None:28 if fn is None:
29 fn = USER_DATA_FILE29 fn = USER_DATA_FILE
30 clickreviews.remote.get_remote_file(fn, AA_POLICY_DATA_URL)30 file_url = clickreviews.remote.get_remote_file_url(AA_POLICY_DATA_URL)
31 clickreviews.remote.get_remote_file(fn, file_url)
3132
3233
33class ApparmorPolicy(object):34class ApparmorPolicy(object):
3435
=== modified file 'clickreviews/frameworks.py'
--- clickreviews/frameworks.py 2014-07-18 20:23:21 +0000
+++ clickreviews/frameworks.py 2014-09-19 17:20:28 +0000
@@ -17,10 +17,8 @@
17import clickreviews.remote17import clickreviews.remote
1818
19USER_DATA_FILE = os.path.join(clickreviews.remote.DATA_DIR, 'frameworks.json')19USER_DATA_FILE = os.path.join(clickreviews.remote.DATA_DIR, 'frameworks.json')
20
21# XXX: This is a hack and will be gone, as soon as myapps has an API for this.
22FRAMEWORKS_DATA_URL = \20FRAMEWORKS_DATA_URL = \
23 "http://bazaar.launchpad.net/~ubuntu-core-dev/+junk/frameworks/view/head:/frameworks.json"21 "https://myapps.developer.ubuntu.com/dev/api/click-framework/"
2422
2523
26def get_frameworks_file(fn):24def get_frameworks_file(fn):
2725
=== modified file 'clickreviews/remote.py'
--- clickreviews/remote.py 2014-07-18 20:23:21 +0000
+++ clickreviews/remote.py 2014-09-19 17:20:28 +0000
@@ -52,14 +52,20 @@
52#52#
53# Public53# Public
54#54#
55def get_remote_file(fn, url, data_dir=DATA_DIR):55def get_remote_data(url):
56 try:56 try:
57 f = request.urlopen(url)57 f = request.urlopen(url)
58 except (HTTPError, URLError) as error:58 except (HTTPError, URLError) as error:
59 abort('Data not retrieved because %s.' % error)59 abort('Data not retrieved because %s.' % error)
60 except timeout:60 except timeout:
61 abort('Socket timed out.')61 abort('Socket timed out.')
62 html = f.read()62 if not f:
63 abort()
64 return f.read()
65
66
67def get_remote_file_url(url):
68 html = get_remote_data(url)
63 # XXX: This is a hack and will be gone, as soon as myapps has an API for this.69 # XXX: This is a hack and will be gone, as soon as myapps has an API for this.
64 link = re.findall(b'<a href="(\S+?)">download file</a>', html)70 link = re.findall(b'<a href="(\S+?)">download file</a>', html)
65 if not link:71 if not link:
@@ -68,15 +74,17 @@
68 parse.urlparse(url).scheme,74 parse.urlparse(url).scheme,
69 parse.urlparse(url).netloc,75 parse.urlparse(url).netloc,
70 link[0].decode("utf-8"))76 link[0].decode("utf-8"))
71 f = request.urlopen(download_link)77 return download_link
72 if not f:78
73 abort()79
80def get_remote_file(fn, url, data_dir=DATA_DIR):
81 data = get_remote_data(url)
74 if os.path.exists(fn):82 if os.path.exists(fn):
75 os.remove(fn)83 os.remove(fn)
76 if not os.path.exists(os.path.dirname(fn)):84 if not os.path.exists(os.path.dirname(fn)):
77 os.makedirs(os.path.dirname(fn))85 os.makedirs(os.path.dirname(fn))
78 with open(fn, 'bw') as local_file:86 with open(fn, 'bw') as local_file:
79 local_file.write(f.read())87 local_file.write(data)
8088
8189
82def read_cr_file(fn, url, local_copy_fn=None):90def read_cr_file(fn, url, local_copy_fn=None):
8391
=== modified file 'data/frameworks.json'
--- data/frameworks.json 2014-07-30 16:33:54 +0000
+++ data/frameworks.json 2014-09-19 17:20:28 +0000
@@ -1,20 +1,23 @@
1{1{
2 "ubuntu-sdk-13.10": "deprecated",2 "ubuntu-sdk-13.10": "deprecated",
3 "ubuntu-sdk-14.04-dev1": "deprecated",3 "ubuntu-sdk-14.04-html": "available",
4 "ubuntu-sdk-14.04-html-dev1": "deprecated",4 "ubuntu-sdk-14.04-qml-dev1": "deprecated",
5 "ubuntu-sdk-14.04-papi-dev1": "deprecated",5 "ubuntu-sdk-14.10-qml-dev3": "available",
6 "ubuntu-sdk-14.04-qml-dev1": "deprecated",6 "ubuntu-sdk-14.10-papi-dev3": "available",
7 "ubuntu-sdk-14.04": "available",7 "ubuntu-sdk-14.04-html-dev1": "deprecated",
8 "ubuntu-sdk-14.04-html": "available",8 "ubuntu-sdk-14.10-papi-dev1": "obsolete",
9 "ubuntu-sdk-14.04-papi": "available",9 "ubuntu-sdk-14.04-papi-dev1": "deprecated",
10 "ubuntu-sdk-14.04-qml": "available",10 "ubuntu-sdk-14.10-dev2": "available",
11 "ubuntu-sdk-14.10-dev1": "obsolete",11 "ubuntu-sdk-14.04": "available",
12 "ubuntu-sdk-14.10-html-dev1": "obsolete",12 "ubuntu-sdk-14.10-dev3": "available",
13 "ubuntu-sdk-14.10-papi-dev1": "obsolete",13 "ubuntu-sdk-14.10-qml-dev1": "obsolete",
14 "ubuntu-sdk-14.10-qml-dev1": "obsolete",14 "ubuntu-sdk-14.04-dev1": "deprecated",
15 "ubuntu-sdk-14.10-dev2": "available",15 "ubuntu-sdk-14.10-dev1": "obsolete",
16 "ubuntu-sdk-14.10-html-dev2": "available",16 "ubuntu-sdk-14.04-papi": "available",
17 "ubuntu-sdk-14.10-papi-dev2": "available",17 "ubuntu-sdk-14.04-qml": "available",
18 "ubuntu-sdk-14.10-qml-dev2": "available",18 "ubuntu-sdk-14.10-papi-dev2": "available",
19 "ubuntu-sdk-14.10-qml-dev3": "available"19 "ubuntu-sdk-14.10-html-dev3": "available",
20 "ubuntu-sdk-14.10-html-dev2": "available",
21 "ubuntu-sdk-14.10-html-dev1": "obsolete",
22 "ubuntu-sdk-14.10-qml-dev2": "available"
20}23}

Subscribers

People subscribed via source and target branches