Merge lp:~verterok/unity-scope-soundcloud/soundcloud-logging into lp:unity-scope-soundcloud/legacy

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: David Callé
Approved revision: 35
Merged at revision: 34
Proposed branch: lp:~verterok/unity-scope-soundcloud/soundcloud-logging
Merge into: lp:unity-scope-soundcloud/legacy
Diff against target: 97 lines (+19/-16)
2 files modified
src/unity_soundcloud_daemon.py (+18/-15)
tests/test_soundcloud.py (+1/-1)
To merge this branch: bzr merge lp:~verterok/unity-scope-soundcloud/soundcloud-logging
Reviewer Review Type Date Requested Status
David Callé Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+187509@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)
35. 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_soundcloud_daemon.py'
2--- src/unity_soundcloud_daemon.py 2013-04-26 12:48:36 +0000
3+++ src/unity_soundcloud_daemon.py 2013-09-25 19:10:31 +0000
4@@ -2,24 +2,25 @@
5 # -*- coding: utf-8 -*-
6
7 # Copyright (C) 2013 David Callé <davidc@framli.eu>
8-# This program is free software: you can redistribute it and/or modify it
9-# under the terms of the GNU General Public License version 3, as published
10+# This program is free software: you can redistribute it and/or modify it
11+# under the terms of the GNU General Public License version 3, as published
12 # by the Free Software Foundation.
13-#
14-# This program is distributed in the hope that it will be useful, but
15-# WITHOUT ANY WARRANTY; without even the implied warranties of
16-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17+#
18+# This program is distributed in the hope that it will be useful, but
19+# WITHOUT ANY WARRANTY; without even the implied warranties of
20+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
21 # PURPOSE. See the GNU General Public License for more details.
22-#
23-# You should have received a copy of the GNU General Public License along
24+#
25+# You should have received a copy of the GNU General Public License along
26 # with this program. If not, see <http://www.gnu.org/licenses/>.
27
28-from gi.repository import Unity, UnityExtras
29+from gi.repository import Unity
30 from gi.repository import Gio, GLib
31 import urllib.parse
32 import urllib.request
33 import json
34 import gettext
35+import logging
36
37 APP_NAME = 'unity-scope-soundcloud'
38 LOCAL_PATH = '/usr/share/locale/'
39@@ -71,6 +72,8 @@
40 'field':Unity.SchemaFieldType.OPTIONAL}
41 EXTRA_METADATA = [m1, m2, m3, m4, m5, m6, m7]
42
43+logger = logging.getLogger("unity.scope.soundcloud")
44+
45 def search(search, filters):
46 '''
47 Any search method returning results as a list of tuples.
48@@ -90,13 +93,13 @@
49 return results
50 search = urllib.parse.quote(search)
51 uri = "%stracks.json?consumer_key=%s&q=%s&order=hotness&limit=30" % (SEARCH_URI, API_KEY, search)
52- print(uri)
53+ logger.debug("Request: %s", uri)
54 data = []
55 try:
56 response = urllib.request.urlopen(uri).read()
57 data = json.loads(response.decode('utf8'))
58- except Exception as error:
59- print(error)
60+ except Exception:
61+ logger.exception("Error while fetching: %r", uri)
62 checks = ['permalink_url', 'artwork_url',
63 'title', 'description', 'stream_url',
64 'genre', 'label_name', 'license',
65@@ -161,8 +164,8 @@
66 if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '':
67 i['dnd_uri'] = i['uri']
68 result_set.add_result(**i)
69- except Exception as error:
70- print (error)
71+ except Exception:
72+ logger.exception("Error while building result set.")
73
74 class Preview (Unity.ResultPreviewer):
75
76@@ -222,7 +225,7 @@
77 '''
78 fs = Unity.FilterSet.new ()
79 # if FILTERS:
80-#
81+#
82 return fs
83
84 def do_get_group_name (self):
85
86=== modified file 'tests/test_soundcloud.py'
87--- tests/test_soundcloud.py 2013-02-13 14:31:12 +0000
88+++ tests/test_soundcloud.py 2013-09-25 19:10:31 +0000
89@@ -24,7 +24,7 @@
90 def perform_query(self, query, filter_set = Unity.FilterSet.new()):
91 result_set = ResultSet()
92 ctx = Unity.SearchContext.create(query, 0, filter_set,
93- None, result_set, None)
94+ {}, result_set, None)
95 s = self.scope.create_search_for_query(ctx)
96 s.run()
97 return result_set

Subscribers

People subscribed via source and target branches