Merge lp:~rafalcieslak256/ubuntu-accomplishments-daemon/fixnotify into lp:ubuntu-accomplishments-daemon

Proposed by Rafał Cieślak
Status: Merged
Merged at revision: 118
Proposed branch: lp:~rafalcieslak256/ubuntu-accomplishments-daemon/fixnotify
Merge into: lp:ubuntu-accomplishments-daemon
Diff against target: 80 lines (+13/-12)
3 files modified
accomplishments/daemon/api.py (+10/-9)
bin/accomplishments-daemon (+2/-2)
debian/control (+1/-1)
To merge this branch: bzr merge lp:~rafalcieslak256/ubuntu-accomplishments-daemon/fixnotify
Reviewer Review Type Date Requested Status
Rafał Cieślak Needs Information
Jono Bacon Needs Fixing
Review via email: mp+117312@code.launchpad.net

Description of the change

This fixes #1003010 (Daemon hangs when calling pynotify, if run without -n flag).

The problem was that pynotify was unable to process, as it's own event loops were not running. We need some kind of twisted reactor that would take care of them, and a GIreactor looked fine, as it implements integration with all that GObject stuff. Therefore I switched to it (from glib2reactor, did we use it at all? I can find trails of it's usage, so probably this will need some more testing). That of course means switching to gi.repository (and gi.repository.Notify) instead of gobject module. Finally, that means a small change in package deps, since we need GI bindings for pynotify.

To post a comment you must log in.
Revision history for this message
Jono Bacon (jonobacon) wrote :

I just tested this and I don't see any notification bubbles. I ran this with:

   twistd -oy bin/accomplishments-daemon

The bubbles not appearing may be our old friend https://bugs.launchpad.net/ubuntu-accomplishments-daemon/+bug/1031190 so I checked the log and when I run the command above I oddly don't get any logging in .cache/accomplishments/logs.

review: Needs Fixing
Revision history for this message
Rafał Cieślak (rafalcieslak256) wrote :

The log will appear in ~/.cache/accomplishments/logs if and only if this path is provided as an argument to twistd. To save the log there, you will need to use --logfile flag. Also, we have never used -o flag without -n. Can you retry using:
twistd -y bin/accomplishments-daemon --logfile=/home/USER/.cache/accomplishments/logs/daemon.log

Also, if you are affected by that other bug, try accomplish()ing something you have full control of, e.g. the "edit credentials" accomplishment, this one is easy to remove and then imediately test using the viewer.

review: Needs Information

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'accomplishments/daemon/api.py'
2--- accomplishments/daemon/api.py 2012-07-23 16:27:15 +0000
3+++ accomplishments/daemon/api.py 2012-07-30 17:55:22 +0000
4@@ -19,7 +19,7 @@
5 import datetime
6 import getpass
7 import glob
8-import gobject
9+#import gobject
10 import gpgme
11 import json
12 import os
13@@ -40,9 +40,10 @@
14 import xdg.BaseDirectory
15
16 try:
17- import pynotify
18+ from gi.repository import Notify
19+ useNotify = True
20 except ImportError:
21- pynotify = None
22+ useNotify = False
23
24 from ubuntuone.platform.tools import SyncDaemonTool
25 from ubuntuone.platform.credentials import CredentialsManagementTool
26@@ -1678,9 +1679,9 @@
27 return accomID.split("/")[0]
28
29 def _display_accomplished_bubble(self,accomID):
30- if self.show_notifications == True and pynotify and (
31- pynotify.is_initted() or pynotify.init("icon-summary-body")):
32- n = pynotify.Notification(
33+ if self.show_notifications == True and useNotify and (
34+ Notify.is_initted() or Notify.init("icon-summary-body")):
35+ n = Notify.Notification.new(
36 _("You have accomplished something!"),
37 self.get_acc_title(accomID),
38 self.get_acc_icon_path(accomID) )
39@@ -1690,10 +1691,10 @@
40 def _display_unlocked_bubble(self,accomID):
41 unlocked = len(self.list_depending_on(accomID))
42 if unlocked is not 0:
43- if self.show_notifications == True and pynotify and (
44- pynotify.is_initted() or pynotify.init("icon-summary-body")):
45+ if self.show_notifications == True and useNotify and (
46+ Notify.is_initted() or Notify.init("icon-summary-body")):
47 message = (N_("You have unlocked %s new opportunity.","You have unlocked %s new opportunities.",unlocked) % str(unlocked))
48- n = pynotify.Notification(
49+ n = Notify.Notification.new(
50 _("Opportunities Unlocked!"), message,
51 self.get_media_file("unlocked.png"))
52 n.show()
53
54=== modified file 'bin/accomplishments-daemon'
55--- bin/accomplishments-daemon 2012-07-08 12:32:14 +0000
56+++ bin/accomplishments-daemon 2012-07-30 17:55:22 +0000
57@@ -5,8 +5,8 @@
58 import sys
59 import os
60
61-from twisted.internet import glib2reactor
62-glib2reactor.install()
63+from twisted.internet import gireactor
64+gireactor.install()
65
66 import dbus
67 from dbus.mainloop.glib import DBusGMainLoop
68
69=== modified file 'debian/control'
70--- debian/control 2012-07-16 17:13:42 +0000
71+++ debian/control 2012-07-30 17:55:22 +0000
72@@ -30,7 +30,7 @@
73 python-ubuntu-sso-client,
74 ubuntuone-couch,
75 python-twisted-core,
76- python-notify,
77+ gir1.2-notify-0.7,
78 python-gobject-2,
79 ubuntuone-client,
80 python-imaging,

Subscribers

People subscribed via source and target branches