diff --git a/djcelery/__init__.py b/djcelery/__init__.py index 34cdc00c..629132ab 100644 --- a/djcelery/__init__.py +++ b/djcelery/__init__.py @@ -6,7 +6,7 @@ import os import sys -VERSION = (3, 3, 0) +VERSION = (4, 0, 0, 'sc') __version__ = '.'.join(map(str, VERSION[0:3])) + ''.join(VERSION[3:]) __author__ = 'Ask Solem' __contact__ = 'ask@celeryproject.org' diff --git a/djcelery/management/commands/celery.py b/djcelery/management/commands/celery.py index 82cf3038..0b64422e 100644 --- a/djcelery/management/commands/celery.py +++ b/djcelery/management/commands/celery.py @@ -1,5 +1,6 @@ from __future__ import absolute_import, unicode_literals +from celery import VERSION as CELERY_VERSION from celery.bin import celery from djcelery.app import app @@ -11,11 +12,16 @@ class Command(CeleryCommand): """The celery command.""" help = 'celery commands, see celery help' - options = ( - tuple(CeleryCommand.options) + - tuple(base.get_options() or ()) + - tuple(getattr(base, 'preload_options', ())) - ) + if CELERY_VERSION[0] < 4: + options = ( + tuple(CeleryCommand.options) + + tuple(base.get_options() or ()) + + tuple(getattr(base, 'preload_options', ())) + ) + else: + def add_arguments(self, parser): + super().add_arguments(parser) + base.add_arguments(parser) def run_from_argv(self, argv): argv = self.handle_default_options(argv) diff --git a/djcelery/management/commands/celerybeat.py b/djcelery/management/commands/celerybeat.py index 8c9580a4..7525dbee 100644 --- a/djcelery/management/commands/celerybeat.py +++ b/djcelery/management/commands/celerybeat.py @@ -5,6 +5,7 @@ """ from __future__ import absolute_import, unicode_literals +from celery import VERSION as CELERY_VERSION from celery.bin import beat from djcelery.app import app @@ -16,11 +17,19 @@ class Command(CeleryCommand): """Run the celery periodic task scheduler.""" help = 'Old alias to the "celery beat" command.' - options = ( - tuple(CeleryCommand.options) + - tuple(beat.get_options()) + - tuple(getattr(beat, 'preload_options', ())) - ) + if CELERY_VERSION[0] < 4: + options = ( + tuple(CeleryCommand.options) + + tuple(beat.get_options()) + + tuple(getattr(beat, 'preload_options', ())) + ) + else: + def add_arguments(self, parser): + super().add_arguments(parser) + beat.add_arguments(parser) + + # Deprecated args + parser.add_argument("--workdir", help="deprecated") def handle(self, *args, **options): beat.run(*args, **options) diff --git a/djcelery/management/commands/celerycam.py b/djcelery/management/commands/celerycam.py index a22cdd4c..f35f6a05 100644 --- a/djcelery/management/commands/celerycam.py +++ b/djcelery/management/commands/celerycam.py @@ -5,6 +5,7 @@ """ from __future__ import absolute_import, unicode_literals +from celery import VERSION as CELERY_VERSION from celery.bin import events from djcelery.app import app @@ -16,13 +17,22 @@ class Command(CeleryCommand): """Run the celery curses event viewer.""" help = 'Takes snapshots of the clusters state to the database.' - options = ( - tuple(CeleryCommand.options) + - tuple(ev.get_options()) + - tuple(getattr(ev, 'preload_options', ())) - ) + if CELERY_VERSION[0] < 4: + options = ( + tuple(CeleryCommand.options) + + tuple(ev.get_options()) + + tuple(getattr(ev, 'preload_options', ())) + ) + else: + def add_arguments(self, parser): + super().add_arguments(parser) + ev.add_arguments(parser) + + # Deprecated args + parser.add_argument("--workdir", help="deprecated") def handle(self, *args, **options): """Handle the management command.""" - options['camera'] = 'djcelery.snapshot.Camera' + if not options["camera"]: + options['camera'] = 'djcelery.snapshot.Camera' ev.run(*args, **options) diff --git a/djcelery/management/commands/celeryd.py b/djcelery/management/commands/celeryd.py index 8fd1820c..d82d9c2e 100644 --- a/djcelery/management/commands/celeryd.py +++ b/djcelery/management/commands/celeryd.py @@ -5,6 +5,7 @@ """ from __future__ import absolute_import, unicode_literals +from celery import VERSION as CELERY_VERSION from celery.bin import worker from djcelery.app import app @@ -16,11 +17,16 @@ class Command(CeleryCommand): """Run the celery daemon.""" help = 'Old alias to the "celery worker" command.' - options = ( - tuple(CeleryCommand.options) + - tuple(worker.get_options()) + - tuple(getattr(worker, 'preload_options', ())) - ) + if CELERY_VERSION[0] < 4: + options = ( + tuple(CeleryCommand.options) + + tuple(worker.get_options()) + + tuple(getattr(worker, 'preload_options', ())) + ) + else: + def add_arguments(self, parser): + super().add_arguments(parser) + worker.add_arguments(parser) def handle(self, *args, **options): worker.check_args(args) diff --git a/djcelery/management/commands/celeryd_detach.py b/djcelery/management/commands/celeryd_detach.py index 3f2533b9..4d10a76e 100644 --- a/djcelery/management/commands/celeryd_detach.py +++ b/djcelery/management/commands/celeryd_detach.py @@ -8,6 +8,7 @@ import os import sys +from celery import VERSION as CELERY_VERSION from celery.bin import celeryd_detach from djcelery.management.base import CeleryCommand @@ -16,10 +17,17 @@ class Command(CeleryCommand): """Run the celery daemon.""" help = 'Runs a detached Celery worker node.' - options = celeryd_detach.OPTION_LIST + if CELERY_VERSION[0] < 4: + options = celeryd_detach.OPTION_LIST + else: + def add_arguments(self, parser): + celeryd_detach.add_arguments(parser) def run_from_argv(self, argv): class detached(celeryd_detach.detached_celeryd): execv_argv = [os.path.abspath(sys.argv[0]), 'celery', 'worker'] + + if CELERY_VERSION[0] >= 4: + argv.remove("celeryd_detach") detached().execute_from_commandline(argv) diff --git a/setup.py b/setup.py index 33f4c6f3..eb0fbd2d 100755 --- a/setup.py +++ b/setup.py @@ -181,7 +181,7 @@ def extra_args(self): package_data=package_data, zip_safe=False, install_requires=[ - 'celery>=3.1.15,<4.0', + 'celery>=3.1.15', 'django>=1.8', ], cmdclass={'test': RunTests,