Merge lp:~verterok/unity-scope-songkick/songkick-logging into lp:unity-scope-songkick

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: David Callé
Approved revision: 15
Merged at revision: 14
Proposed branch: lp:~verterok/unity-scope-songkick/songkick-logging
Merge into: lp:unity-scope-songkick
Diff against target: 66 lines (+9/-11)
2 files modified
src/unity_songkick_daemon.py (+8/-10)
tests/test_songkick.py (+1/-1)
To merge this branch: bzr merge lp:~verterok/unity-scope-songkick/songkick-logging
Reviewer Review Type Date Requested Status
David Callé Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+187384@code.launchpad.net

Commit message

Add basic logging (replace print with logging)

Description of the change

Add basic logging (replace print with logging)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
15. By Guillermo Gonzalez

fix test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Callé (davidc3) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity_songkick_daemon.py'
2--- src/unity_songkick_daemon.py 2013-08-16 10:43:51 +0000
3+++ src/unity_songkick_daemon.py 2013-09-25 02:59:45 +0000
4@@ -20,6 +20,7 @@
5 import urllib.request
6 import json
7 import datetime
8+import logging
9
10 APP_NAME = 'unity-scope-songkick'
11 LOCAL_PATH = '/usr/share/locale/'
12@@ -55,6 +56,7 @@
13
14 EXTRA_METADATA = []
15
16+logger = logging.getLogger("unity.scope.songkick")
17
18 def search(search, filters):
19 '''
20@@ -68,12 +70,13 @@
21 uri = '%s?artist_name=%s&apikey=%s' % (SEARCH_URI, search, API_KEY)
22
23 try:
24+ logger.debug("Request: %s", uri)
25 response = urllib.request.urlopen(uri).read()
26- print(uri)
27 response = response.decode('utf8')
28 json_response = json.loads(response)
29 result = json_response['resultsPage']['results']['event']
30- except:
31+ except Exception:
32+ logger.exception("Error while fetching: %r", uri)
33 result = {}
34 if result:
35 for item in result:
36@@ -194,14 +197,9 @@
37 if m['id'] == e:
38 i['metadata'][e] = i[e]
39 i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS)
40- result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']),
41- i['category'], i['result_type'],
42- str(i['mimetype']), str(i['title']),
43- str(i['comment']), str(i['dnd_uri']),
44- i['metadata'])
45- result_set.add_result(result)
46- except Exception as error:
47- print(error)
48+ result_set.add_result(**i)
49+ except Exception:
50+ logger.exception("Error while building result set.")
51
52
53 class Scope(Unity.AbstractScope):
54
55=== modified file 'tests/test_songkick.py'
56--- tests/test_songkick.py 2013-02-14 20:14:58 +0000
57+++ tests/test_songkick.py 2013-09-25 02:59:45 +0000
58@@ -24,7 +24,7 @@
59 def perform_query(self, query, filter_set = Unity.FilterSet.new()):
60 result_set = ResultSet()
61 ctx = Unity.SearchContext.create(query, 0, filter_set,
62- None, result_set, None)
63+ {}, result_set, None)
64 s = self.scope.create_search_for_query(ctx)
65 s.run()
66 return result_set

Subscribers

People subscribed via source and target branches