Merge lp:~jml/launchpad/lp-poppy into lp:launchpad

Proposed by Jonathan Lange
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jml/launchpad/lp-poppy
Merge into: lp:launchpad
Diff against target: 377 lines (+83/-107)
10 files modified
daemons/poppy-upload.py (+1/-48)
lib/lp/archiveuploader/uploadprocessor.py (+4/-4)
lib/lp/poppy/daemon.py (+55/-0)
lib/lp/poppy/hooks.py (+6/-4)
lib/lp/poppy/server.py (+4/-41)
lib/lp/poppy/tests/filesystem.txt (+1/-1)
lib/lp/poppy/tests/test_poppy.py (+2/-1)
lib/lp/soyuz/doc/soyuz-upload.txt.disabled (+1/-2)
lib/lp/soyuz/interfaces/queue.py (+4/-3)
lib/lp/soyuz/model/queue.py (+5/-3)
To merge this branch: bzr merge lp:~jml/launchpad/lp-poppy
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+21551@code.launchpad.net

Commit message

Move poppy code to lp.poppy.

Description of the change

This branch moves all the poppy code into one place: lp.poppy. In particular, it moves lp.archiveuploader.poppyinterface to lp.poppy.hooks, and most of the actual code in daemons/poppy-upload.py to lp.poppy.daemon.

It also deletes a bunch of unused code and removes as many mentions of "lucille" as make sense to remove.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) wrote :

Thank you for making Poppy nicer :)

Remove the comments:

+ # host = "127.0.0.1"
+ # host = "82.211.81.167" # Drescher's public IP

as discussed and it's good to land.

Cheers!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'daemons/poppy-upload.py'
2--- daemons/poppy-upload.py 2009-10-17 14:06:03 +0000
3+++ daemons/poppy-upload.py 2010-03-17 12:28:38 +0000
4@@ -4,54 +4,7 @@
5 # GNU Affero General Public License version 3 (see the file LICENSE).
6
7 import sys
8-import logging
9-import optparse
10-
11-from canonical.poppy.server import run_server
12-from lp.archiveuploader.poppyinterface import PoppyInterface
13-from canonical.launchpad.scripts import logger, logger_options
14-
15-
16-def main():
17-
18- parser = optparse.OptionParser()
19- logger_options(parser)
20-
21- parser.add_option("--cmd", action="store", metavar="CMD",
22- help="Run CMD after each upload completion")
23-
24- parser.add_option("--allow-user", action="store", metavar="USER",
25- default='ubuntu',
26- help="Username allowed to log in.")
27-
28- parser.add_option("--permissions", action="store", metavar="PERMS",
29- default='g+rwxs',
30- help="Permissions to chmod the targetfsroot with "
31- "before letting go of the directory.")
32-
33- options, args = parser.parse_args()
34-
35- log = logger(options, "poppy-upload")
36-
37- if len(args) != 2:
38- print "usage: poppy-upload.py rootuploaddirectory port"
39- return 1
40-
41- root, port = args
42- # host = "127.0.0.1"
43- # host = "82.211.81.167" # Drescher's public IP
44- host = "0.0.0.0"
45- ident = "lucille upload server"
46- numthreads = 4
47-
48- iface = PoppyInterface(root, log, allow_user=options.allow_user,
49- cmd=options.cmd,
50- perms=options.permissions)
51-
52- run_server(host, int(port), ident, numthreads,
53- iface.new_client_hook, iface.client_done_hook,
54- iface.auth_verify_hook)
55- return 0
56+from lp.poppy.daemon import main
57
58 if __name__ == '__main__':
59 sys.exit(main())
60
61=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
62--- lib/lp/archiveuploader/uploadprocessor.py 2010-02-05 10:54:07 +0000
63+++ lib/lp/archiveuploader/uploadprocessor.py 2010-03-17 12:28:38 +0000
64@@ -218,9 +218,9 @@
65 :return: a list of upload directories found in the queue
66 alphabetically sorted.
67 """
68- # Protecting listdir by a lock ensures that we only get
69- # completely finished directories listed. See
70- # PoppyInterface for the other locking place.
71+ # Protecting listdir by a lock ensures that we only get completely
72+ # finished directories listed. See lp.poppy.hooks for the other
73+ # locking place.
74 lockfile_path = os.path.join(fsroot, ".lock")
75 fsroot_lock = GlobalLock(lockfile_path)
76 mode = stat.S_IMODE(os.stat(lockfile_path).st_mode)
77@@ -239,7 +239,7 @@
78 fsroot_lock.acquire(blocking=True)
79 dir_names = os.listdir(fsroot)
80 finally:
81- # Skip lockfile deletion, see similar code in poppyinterface.py.
82+ # Skip lockfile deletion, see similar code in lp.poppy.hooks.
83 fsroot_lock.release(skip_delete=True)
84
85 sorted_dir_names = sorted(
86
87=== renamed directory 'lib/canonical/poppy' => 'lib/lp/poppy'
88=== added file 'lib/lp/poppy/daemon.py'
89--- lib/lp/poppy/daemon.py 1970-01-01 00:00:00 +0000
90+++ lib/lp/poppy/daemon.py 2010-03-17 12:28:38 +0000
91@@ -0,0 +1,55 @@
92+# Copyright 2010 Canonical Ltd. This software is licensed under the
93+# GNU Affero General Public License version 3 (see the file LICENSE).
94+
95+"""The Poppy daemon."""
96+
97+__metaclass__ = type
98+__all__ = [
99+ 'main',
100+ ]
101+
102+import optparse
103+
104+from canonical.launchpad.scripts import logger, logger_options
105+from lp.poppy.hooks import Hooks
106+from lp.poppy.server import run_server
107+
108+
109+def main():
110+ parser = optparse.OptionParser()
111+ logger_options(parser)
112+
113+ parser.add_option("--cmd", action="store", metavar="CMD",
114+ help="Run CMD after each upload completion")
115+
116+ parser.add_option("--allow-user", action="store", metavar="USER",
117+ default='ubuntu',
118+ help="Username allowed to log in.")
119+
120+ parser.add_option("--permissions", action="store", metavar="PERMS",
121+ default='g+rwxs',
122+ help="Permissions to chmod the targetfsroot with "
123+ "before letting go of the directory.")
124+
125+ options, args = parser.parse_args()
126+
127+ log = logger(options, "poppy-upload")
128+
129+ if len(args) != 2:
130+ print "usage: poppy-upload.py rootuploaddirectory port"
131+ return 1
132+
133+ root, port = args
134+ host = "0.0.0.0"
135+ ident = "lucille upload server"
136+ numthreads = 4
137+
138+ hooks = Hooks(root, log, allow_user=options.allow_user, cmd=options.cmd,
139+ perms=options.permissions)
140+
141+ run_server(host, int(port), ident, numthreads,
142+ hooks.new_client_hook, hooks.client_done_hook,
143+ hooks.auth_verify_hook)
144+ return 0
145+
146+
147
148=== renamed file 'lib/lp/archiveuploader/poppyinterface.py' => 'lib/lp/poppy/hooks.py'
149--- lib/lp/archiveuploader/poppyinterface.py 2009-11-13 15:29:46 +0000
150+++ lib/lp/poppy/hooks.py 2010-03-17 12:28:38 +0000
151@@ -1,7 +1,7 @@
152-# Copyright 2009 Canonical Ltd. This software is licensed under the
153+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
154 # GNU Affero General Public License version 3 (see the file LICENSE).
155
156-# Lucille's primary interface to the upload mechanism
157+__metaclass__ = type
158
159 import logging
160 import shutil
161@@ -11,17 +11,19 @@
162
163 from contrib.glock import GlobalLock
164
165+
166 class PoppyInterfaceFailure(Exception):
167 pass
168
169-class PoppyInterface:
170+
171+class Hooks:
172
173 clients = {}
174
175 def __init__(self, targetpath, logger, allow_user, cmd=None,
176 targetstart=0, perms=None):
177 self.targetpath = targetpath
178- self.logger = logging.getLogger("%s.PoppyInterface" % logger.name)
179+ self.logger = logging.getLogger("%s.Hooks" % logger.name)
180 self.cmd = cmd
181 self.allow_user = allow_user
182 self.targetcount = targetstart
183
184=== modified file 'lib/lp/poppy/server.py'
185--- lib/canonical/poppy/server.py 2009-08-31 18:03:05 +0000
186+++ lib/lp/poppy/server.py 2010-03-17 12:28:38 +0000
187@@ -4,8 +4,6 @@
188 __metaclass__ = type
189
190 import asyncore
191-import logging
192-import sys
193 import tempfile
194 from time import time
195
196@@ -14,7 +12,7 @@
197 from zope.server.taskthreads import ThreadedTaskDispatcher
198 from zope.server.serverbase import ServerBase
199
200-from canonical.poppy.filesystem import UploadFileSystem
201+from lp.poppy.filesystem import UploadFileSystem
202
203
204 class Channel(FTPServerChannel):
205@@ -39,7 +37,7 @@
206 return self.uploadfilesystem
207
208 def received(self, data):
209- # XXX Steve Alexander 2005-01-18
210+ # XXX Steve Alexander 2005-01-18
211 # This is a work-around for a bug in Zope 3's ServerChannelBase
212 # that it doesn't update self.last_activity.
213 # This method can be removed once Zope3 is fixed, and we're using
214@@ -112,6 +110,7 @@
215 # This is the point at which some data for an upload has been
216 # received by the server from a client.
217
218+
219 class Server(ServerBase):
220
221 channel_class = Channel
222@@ -145,7 +144,7 @@
223
224
225 def run_server(host, port, ident, numthreads,
226- new_client_hook, client_done_hook, auth_verify_hook = None):
227+ new_client_hook, client_done_hook, auth_verify_hook=None):
228 task_dispatcher = ThreadedTaskDispatcher()
229 task_dispatcher.setThreadCount(numthreads)
230 server = Server(host, port,
231@@ -157,39 +156,3 @@
232 except KeyboardInterrupt:
233 # Exit without spewing an exception.
234 pass
235-
236-
237-def main():
238- args = sys.argv[1:]
239- if len(args) != 1:
240- print "usage: server.py port"
241- return 1
242- port = int(args[0])
243- host = "127.0.0.1"
244- ident = "lucille upload server"
245- numthreads = 4
246-
247- logger = logging.getLogger('Server')
248- hdlr = logging.FileHandler('+lucilleupload.log')
249- formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
250- hdlr.setFormatter(formatter)
251- logger.addHandler(hdlr)
252- logger.setLevel(logging.WARNING)
253-
254- def new_client_hook(fsroot, host, port):
255- print "new client:", fsroot, host, port
256-
257- def client_done_hook(fsroot, host, port):
258- print "client done:", fsroot, host, port
259-
260- def auth_verify_hook(fsroot, user, passw):
261- print "Auth Verification hook:", fsroot, user, passw
262- return True
263-
264- run_server(host, int(port), ident, numthreads,
265- new_client_hook, client_done_hook,
266- auth_verify_hook)
267- return 0
268-
269-if __name__ == '__main__':
270- sys.exit(main())
271
272=== modified file 'lib/lp/poppy/tests/filesystem.txt'
273--- lib/canonical/poppy/tests/filesystem.txt 2009-10-15 12:44:02 +0000
274+++ lib/lp/poppy/tests/filesystem.txt 2010-03-17 12:28:38 +0000
275@@ -2,7 +2,7 @@
276 This is an implementation of IFileSystem which the FTP Server in Zope3
277 uses to know what to do when people make FTP commands.
278
279- >>> from canonical.poppy.filesystem import UploadFileSystem
280+ >>> from lp.poppy.filesystem import UploadFileSystem
281
282 The UploadFileSystem class implements the interface IFileSystem.
283
284
285=== modified file 'lib/lp/poppy/tests/test_poppy.py'
286--- lib/canonical/poppy/tests/test_poppy.py 2009-06-25 05:30:52 +0000
287+++ lib/lp/poppy/tests/test_poppy.py 2010-03-17 12:28:38 +0000
288@@ -13,8 +13,9 @@
289 import unittest
290 import StringIO
291
292-from canonical.poppy.tests import PoppyTestSetup
293 from canonical.testing import LaunchpadZopelessLayer
294+from lp.poppy.tests import PoppyTestSetup
295+
296
297 class TestPoppy(unittest.TestCase):
298 """Test if poppy.py daemon works properly."""
299
300=== modified file 'lib/lp/soyuz/doc/soyuz-upload.txt.disabled'
301--- lib/lp/soyuz/doc/soyuz-upload.txt.disabled 2010-02-15 12:59:55 +0000
302+++ lib/lp/soyuz/doc/soyuz-upload.txt.disabled 2010-03-17 12:28:38 +0000
303@@ -41,8 +41,7 @@
304 call the upload processing tool. We'll do that ourselves in our test,
305 so that we can control what's going on.
306
307- >>> from canonical.poppy.tests import (
308- ... PoppyTestSetup, SoyuzUploadError)
309+ >>> from lp.poppy.tests import PoppyTestSetup, SoyuzUploadError
310 >>> poppy = PoppyTestSetup(incoming_dir)
311 >>> poppy.startPoppy()
312
313
314=== modified file 'lib/lp/soyuz/interfaces/queue.py'
315--- lib/lp/soyuz/interfaces/queue.py 2010-03-08 12:00:29 +0000
316+++ lib/lp/soyuz/interfaces/queue.py 2010-03-17 12:28:38 +0000
317@@ -139,7 +139,8 @@
318
319
320 class IPackageUpload(Interface):
321- """A Queue item for Lucille"""
322+ """A Queue item for the archive uploader."""
323+
324 export_as_webservice_entry()
325
326 id = Int(
327@@ -395,7 +396,7 @@
328
329
330 class IPackageUploadBuild(Interface):
331- """A Queue item's related builds (for Lucille)"""
332+ """A Queue item's related builds."""
333
334 id = Int(
335 title=_("ID"), required=True, readonly=True,
336@@ -431,7 +432,7 @@
337 """
338
339 class IPackageUploadSource(Interface):
340- """A Queue item's related sourcepackagereleases (for Lucille)"""
341+ """A Queue item's related sourcepackagereleases."""
342
343 id = Int(
344 title=_("ID"), required=True, readonly=True,
345
346=== modified file 'lib/lp/soyuz/model/queue.py'
347--- lib/lp/soyuz/model/queue.py 2010-03-15 10:22:34 +0000
348+++ lib/lp/soyuz/model/queue.py 2010-03-17 12:28:38 +0000
349@@ -132,7 +132,8 @@
350
351
352 class PackageUpload(SQLBase):
353- """A Queue item for Lucille."""
354+ """A Queue item for the archive uploader."""
355+
356 implements(IPackageUpload)
357
358 _defaultOrder = ['id']
359@@ -1349,7 +1350,7 @@
360
361
362 class PackageUploadBuild(SQLBase):
363- """A Queue item's related builds (for Lucille)."""
364+ """A Queue item's related builds."""
365 implements(IPackageUploadBuild)
366
367 _defaultOrder = ['id']
368@@ -1449,7 +1450,8 @@
369
370
371 class PackageUploadSource(SQLBase):
372- """A Queue item's related sourcepackagereleases (for Lucille)."""
373+ """A Queue item's related sourcepackagereleases."""
374+
375 implements(IPackageUploadSource)
376
377 _defaultOrder = ['id']