Merge lp:~dholbach/ubuntu-accomplishments-daemon/paths-fix into lp:~jonobacon/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon

Proposed by Daniel Holbach
Status: Superseded
Proposed branch: lp:~dholbach/ubuntu-accomplishments-daemon/paths-fix
Merge into: lp:~jonobacon/ubuntu-accomplishments-daemon/ubuntu-accomplishments-daemon
Diff against target: 155 lines (+35/-20)
6 files modified
accomplishments/daemon/api.py (+4/-7)
accomplishments/util/paths.py (+11/-0)
bin/accomplishments-daemon (+9/-6)
debian/copyright (+1/-0)
po/accomplishments-daemon.pot (+5/-5)
setup.py (+5/-2)
To merge this branch: bzr merge lp:~dholbach/ubuntu-accomplishments-daemon/paths-fix
Reviewer Review Type Date Requested Status
Jono Bacon Needs Information
Review via email: mp+101342@code.launchpad.net

This proposal supersedes a proposal from 2012-04-10.

This proposal has been superseded by a proposal from 2012-04-11.

Description of the change

This should install the GPG key in the right place and tests where we are
running from (from branch or from system libs) when starting the daemon.

Also checks for .png files in the right place.

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

Hi Daniel,

Firstly, thanks so much for helping. I really appreciate it!

I noticed a few things when reviewing the merge. When I package the daemon and install it run:

   accomplishments-daemon

it seems to start it with 'twistd -noy'. I saw you added this at the beginning of the source file.

Unfortunately we will need to be able to start the daemon using other twistd command line options (e.g -noy is good for debugging so it runs in the foreground, but when it runs as a daemon we will want to run it with 'twistd -y'.

When I started the daemon (running 'accomplishments-daemon') it ran well but I noticed one bug. When the first few accomplishments are achieved, the first trophy appears correctly in the GUI but any other trophies don't. There is also the following output in the daemon's terminal:

2012-04-10 21:04:09-0700 [-] Looking for accomplishments files in /home/jono/accomplishments/accomplishments/ubuntu-community/en
2012-04-10 21:04:09-0700 [-] Looking for accomplishments files in /home/jono/accomplishments/accomplishments/ubuntu-italian/it
2012-04-10 21:04:09-0700 [-] ['/home/jono/accomplishments/accomplishments/ubuntu-community/en/*.accomplishment', '/home/jono/accomplishments/accomplishments/ubuntu-italian/it/*.accomplishment']
2012-04-10 21:04:09-0700 [-] Unhandled error in Deferred:
2012-04-10 21:04:09-0700 [-] Unhandled Error
 Traceback (most recent call last):
   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 362, in callback
     self._startRunCallbacks(result)
   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 458, in _startRunCallbacks
     self._runCallbacks()
   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 545, in _runCallbacks
     current.result = callback(current.result, *args, **kw)
   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1095, in gotResult
     _inlineCallbacks(r, g, deferred)
 --- <exception caught here> ---
   File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
     result = g.send(result)
   File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 106, in wait_until_a_sig_file_arrives
     self.parent.show_unlocked_accomplishments()
   File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 378, in show_unlocked_accomplishments
     self.get_media_file("unlocked.png"))
   File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 346, in get_media_file
     media_filename = get_data_file('media', '%s' % (media_file_name,))
   File "/usr/lib/python2.7/dist-packages/accomplishments/util/__init__.py", line 80, in get_data_file
     return os.path.join(get_data_path(), *path_segments)
   File "/usr/lib/python2.7/dist-packages/accomplishments/util/__init__.py", line 69, in get_data_path
     raise exceptions.PathNotFound(msg)
 accomplishments.exceptions.PathNotFound: Could not find the project data directory.

This obviously points to an issue with the packaging. This is definitely an issue with the packaging as when I run from the source directory as opposed to the packaged daemon the bug isn't triggered.

...

Read more...

review: Needs Information
119. By Daniel Holbach

merge from trunk

120. By Daniel Holbach

run daemon with -y instead of -noy

121. By Daniel Holbach

look for media files in media_dir - which depends on where we run the daemon from

Revision history for this message
Daniel Holbach (dholbach) wrote :
Download full text (4.2 KiB)

On 11.04.2012 06:23, Jono Bacon wrote:
> Unfortunately we will need to be able to start the daemon using other twistd command line options (e.g -noy is good for debugging so it runs in the foreground, but when it runs as a daemon we will want to run it with 'twistd -y'.

Ok. I fixed this in r120 of my branch.

> When I started the daemon (running 'accomplishments-daemon') it ran well but I noticed one bug. When the first few accomplishments are achieved, the first trophy appears correctly in the GUI but any other trophies don't. There is also the following output in the daemon's terminal:
>
> 2012-04-10 21:04:09-0700 [-] Looking for accomplishments files in /home/jono/accomplishments/accomplishments/ubuntu-community/en
> 2012-04-10 21:04:09-0700 [-] Looking for accomplishments files in /home/jono/accomplishments/accomplishments/ubuntu-italian/it
> 2012-04-10 21:04:09-0700 [-] ['/home/jono/accomplishments/accomplishments/ubuntu-community/en/*.accomplishment', '/home/jono/accomplishments/accomplishments/ubuntu-italian/it/*.accomplishment']
> 2012-04-10 21:04:09-0700 [-] Unhandled error in Deferred:
> 2012-04-10 21:04:09-0700 [-] Unhandled Error
> Traceback (most recent call last):
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 362, in callback
> self._startRunCallbacks(result)
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 458, in _startRunCallbacks
> self._runCallbacks()
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 545, in _runCallbacks
> current.result = callback(current.result, *args, **kw)
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1095, in gotResult
> _inlineCallbacks(r, g, deferred)
> --- <exception caught here> ---
> File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1039, in _inlineCallbacks
> result = g.send(result)
> File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 106, in wait_until_a_sig_file_arrives
> self.parent.show_unlocked_accomplishments()
> File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 378, in show_unlocked_accomplishments
> self.get_media_file("unlocked.png"))
> File "/usr/lib/python2.7/dist-packages/accomplishments/daemon/api.py", line 346, in get_media_file
> media_filename = get_data_file('media', '%s' % (media_file_name,))
> File "/usr/lib/python2.7/dist-packages/accomplishments/util/__init__.py", line 80, in get_data_file
> return os.path.join(get_data_path(), *path_segments)
> File "/usr/lib/python2.7/dist-packages/accomplishments/util/__init__.py", line 69, in get_data_path
> raise exceptions.PathNotFound(msg)
> accomplishments.exceptions.PathNotFound: Could not find the project data directory.
>
> This obviously points to an issue with the packaging. This is definitely an issue with the packaging as when I run from the source directory as opposed to the packaged daemon the bug isn't triggered.

It's not an issue with the packaging, but in the code. I fixed this in
r121 of my branch.

This piece of code:

 get_data_file('media', '%s' % (media_fi...

Read more...

Unmerged revisions

121. By Daniel Holbach

look for media files in media_dir - which depends on where we run the daemon from

120. By Daniel Holbach

run daemon with -y instead of -noy

119. By Daniel Holbach

merge from trunk

118. By Daniel Holbach

check for .png files in the right place depending on where we run the daemon from

117. By Daniel Holbach

update potfile

116. By Daniel Holbach

install gpg key into /usr/share/ and test if we are running from branch or not

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-04-09 20:15:10 +0000
3+++ accomplishments/daemon/api.py 2012-04-11 07:48:18 +0000
4@@ -44,7 +44,7 @@
5 from accomplishments import exceptions
6 from accomplishments.daemon import dbusapi
7 from accomplishments.util import get_data_file, SubprocessReturnCodeProtocol
8-
9+from accomplishments.util.paths import media_dir
10
11 MATRIX_USERNAME = "openiduser155707"
12 LOCAL_USERNAME = getpass.getuser()
13@@ -343,7 +343,7 @@
14
15
16 def get_media_file(self, media_file_name):
17- media_filename = get_data_file('media', '%s' % (media_file_name,))
18+ media_filename = get_data_file(media_dir, '%s' % (media_file_name,))
19 if not os.path.exists(media_filename):
20 media_filename = None
21
22@@ -543,9 +543,7 @@
23 os.remove(o)
24
25 # now generate our trophy images
26- lock_image_path = os.path.join(
27- os.path.dirname(accomplishments.__path__[0]),
28- "data/media/lock.png")
29+ lock_image_path = os.path.join(media_dir, "lock.png")
30 self.generate_trophy_images(
31 app_trophyimagespath, cache_trophyimagespath, lock_image_path)
32
33@@ -729,8 +727,7 @@
34 pynotify.is_initted() or pynotify.init("icon-summary-body")):
35 # XXX: need to fix loading the right icon
36 trophy_icon_path = "file://%s" % os.path.realpath(
37- os.path.join(
38- os.path.split(__file__)[0], "unlocked.png"))
39+ os.path.join(media_dir, "unlocked.png"))
40 n = pynotify.Notification(_("You have accomplished something!"),
41 data["title"], trophy_icon_path)
42 n.show()
43
44=== added file 'accomplishments/util/paths.py'
45--- accomplishments/util/paths.py 1970-01-01 00:00:00 +0000
46+++ accomplishments/util/paths.py 2012-04-11 07:48:18 +0000
47@@ -0,0 +1,11 @@
48+import os
49+
50+def uses_system_lib():
51+ return os.path.dirname(__file__).startswith("/usr")
52+
53+runs_in_branch = not uses_system_lib()
54+systemdata_dir = "data/daemon/"
55+media_dir = "data/media/"
56+if not runs_in_branch:
57+ systemdata_dir = "/usr/share/accomplishments-daemon/"
58+ media_dir = "/usr/share/accomplishments-daemon/media/"
59
60=== modified file 'bin/accomplishments-daemon'
61--- bin/accomplishments-daemon 2012-04-08 22:11:10 +0000
62+++ bin/accomplishments-daemon 2012-04-11 07:48:18 +0000
63@@ -1,8 +1,9 @@
64-#!/usr/bin/twistd
65+#!/usr/bin/twistd -y
66 """
67 Run the Accomplishments daemon!
68 """
69 import sys
70+import os
71
72 from twisted.internet import glib2reactor
73 glib2reactor.install()
74@@ -11,10 +12,12 @@
75 from dbus.mainloop.glib import DBusGMainLoop
76
77 from accomplishments.daemon import app
78-
79-
80-# PYTHONPATH mangling
81-sys.path.insert(0, ".")
82+from accomplishments.util import paths
83+
84+
85+if paths.runs_in_branch:
86+ # PYTHONPATH mangling
87+ sys.path.insert(0, ".")
88
89 dbus_loop = DBusGMainLoop(set_as_default=True)
90 application = app.applicationFactory(
91@@ -25,4 +28,4 @@
92 object_path="/",
93 # Let's execute the timer service every 15 minutes
94 update_interval=15 * 60,
95- gpg_key="./data/daemon/validation-key.pub")
96+ gpg_key=os.path.join(paths.systemdata_dir, "validation-key.pub"))
97
98=== modified file 'debian/copyright'
99--- debian/copyright 2012-04-09 04:52:29 +0000
100+++ debian/copyright 2012-04-11 07:48:18 +0000
101@@ -5,6 +5,7 @@
102
103 Files: *
104 Copyright: (C) 2012 Jono Bacon <jono@ubuntu.com>
105+Copyright: (C) 2012 Rosetta Contributors and Canonical Ltd 2012
106 License: GPL-3
107 The full text of the GPL is distributed in
108 /usr/share/common-licenses/GPL-3 on Debian systems.
109
110=== modified file 'po/accomplishments-daemon.pot'
111--- po/accomplishments-daemon.pot 2012-04-09 06:08:40 +0000
112+++ po/accomplishments-daemon.pot 2012-04-11 07:48:18 +0000
113@@ -8,7 +8,7 @@
114 msgstr ""
115 "Project-Id-Version: PACKAGE VERSION\n"
116 "Report-Msgid-Bugs-To: \n"
117-"POT-Creation-Date: 2012-04-08 23:07-0700\n"
118+"POT-Creation-Date: 2012-04-10 10:21+0200\n"
119 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
120 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
121 "Language-Team: LANGUAGE <LL@li.org>\n"
122@@ -17,6 +17,10 @@
123 "Content-Type: text/plain; charset=CHARSET\n"
124 "Content-Transfer-Encoding: 8bit\n"
125
126+#: ../accomplishments/daemon/api.py:102 ../accomplishments/daemon/api.py:731
127+msgid "You have accomplished something!"
128+msgstr ""
129+
130 #: ../accomplishments/util/__init__.py:88
131 msgid "Show debug messages (-vv debugs accomplishments_daemon_lib also)"
132 msgstr ""
133@@ -24,7 +28,3 @@
134 #: ../accomplishments/util/__init__.py:91
135 msgid "Clear your trophies collection"
136 msgstr ""
137-
138-#: ../accomplishments/daemon/api.py:100 ../accomplishments/daemon/api.py:732
139-msgid "You have accomplished something!"
140-msgstr ""
141
142=== modified file 'setup.py'
143--- setup.py 2012-04-09 04:52:29 +0000
144+++ setup.py 2012-04-11 07:48:18 +0000
145@@ -15,5 +15,8 @@
146 description='Daemon for Ubuntu Accomplishments.',
147 long_description='Daemon for Ubuntu Accomplishments.',
148 url='https://launchpad.net/ubuntu-accomplishments-daemon',
149- cmdclass={'install': dist.InstallAndUpdateDataDirectory}
150- )
151+ cmdclass={'install': dist.InstallAndUpdateDataDirectory},
152+ data_files=[
153+ ('share/accomplishments-daemon', ['data/daemon/validation-key.pub'])
154+ ],
155+)

Subscribers

People subscribed via source and target branches

to all changes: