annotate rhodecode/lib/celerypylons/commands.py @ 1237:f7bb54f8c20f

fixed archive names, added setup command to contributing docs.
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 09 Apr 2011 20:15:18 +0200
parents af6ca51fb80f
children 13d6da57b0cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
785
277427ac29a9 complete rewrite of paster commands,
Marcin Kuzminski <marcin@python-works.com>
parents: 776
diff changeset
1 from rhodecode.lib.utils import BasePasterCommand, Command
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
2 from celery.app import app_or_default
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
3 from celery.bin import camqadm, celerybeat, celeryd, celeryev
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 __all__ = ['CeleryDaemonCommand', 'CeleryBeatCommand',
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 'CAMQPAdminCommand', 'CeleryEventCommand']
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
9 class CeleryCommand(BasePasterCommand):
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
10 """Abstract class implements run methods needed for celery
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
11
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
12 Starts the celery worker that uses a paste.deploy configuration
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
13 file.
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
14 """
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
15
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
16 def update_parser(self):
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
17 """
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
18 Abstract method. Allows for the class's parser to be updated
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
19 before the superclass's `run` method is called. Necessary to
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
20 allow options/arguments to be passed through to the underlying
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
21 celery command.
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
22 """
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
23
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
24 cmd = self.celery_command(app_or_default())
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
25 for x in cmd.get_options():
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
26 self.parser.add_option(x)
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
27
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
28 def command(self):
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
29 cmd = self.celery_command(app_or_default())
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
30 return cmd.run(**vars(self.options))
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
31
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
32 class CeleryDaemonCommand(CeleryCommand):
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 """Start the celery worker
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 Starts the celery worker that uses a paste.deploy configuration
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 file.
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 """
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 usage = 'CONFIG_FILE [celeryd options...]'
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 summary = __doc__.splitlines()[0]
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 description = "".join(__doc__.splitlines()[2:])
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 parser = Command.standard_parser(quiet=True)
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
43 celery_command = celeryd.WorkerCommand
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
46 class CeleryBeatCommand(CeleryCommand):
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 """Start the celery beat server
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 Starts the celery beat server using a paste.deploy configuration
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 file.
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 """
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 usage = 'CONFIG_FILE [celerybeat options...]'
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 summary = __doc__.splitlines()[0]
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 description = "".join(__doc__.splitlines()[2:])
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 parser = Command.standard_parser(quiet=True)
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
57 celery_command = celerybeat.BeatCommand
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
60 class CAMQPAdminCommand(CeleryCommand):
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 """CAMQP Admin
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 CAMQP celery admin tool.
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 """
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 usage = 'CONFIG_FILE [camqadm options...]'
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 summary = __doc__.splitlines()[0]
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 description = "".join(__doc__.splitlines()[2:])
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 parser = Command.standard_parser(quiet=True)
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
70 celery_command = camqadm.AMQPAdminCommand
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
72 class CeleryEventCommand(CeleryCommand):
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
73 """Celery event command.
776
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 Capture celery events.
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 """
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 usage = 'CONFIG_FILE [celeryev options...]'
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 summary = __doc__.splitlines()[0]
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 description = "".join(__doc__.splitlines()[2:])
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80
f6c613fba757 Celery is configured by the .ini files and run from paster now
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 parser = Command.standard_parser(quiet=True)
1057
af6ca51fb80f rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents: 785
diff changeset
82 celery_command = celeryev.EvCommand