Ver código fonte

celery command can now take extensions using setuptools entrypoint 'celery.commands'

Ask Solem 12 anos atrás
pai
commit
cc92502497
1 arquivos alterados com 14 adições e 1 exclusões
  1. 14 1
      celery/bin/celery.py

+ 14 - 1
celery/bin/celery.py

@@ -41,7 +41,6 @@ command_classes = (
     ('Utils', ['purge', 'list', 'migrate', 'call', 'result', 'report'], None),
     ('Utils', ['purge', 'list', 'migrate', 'call', 'result', 'report'], None),
 )
 )
 
 
-
 class Error(Exception):
 class Error(Exception):
 
 
     def __init__(self, reason, status=EX_FAILURE):
     def __init__(self, reason, status=EX_FAILURE):
@@ -59,6 +58,20 @@ def command(fun, name=None, sortpri=0):
     return fun
     return fun
 
 
 
 
+def get_extension_commands(namespace='celery.commands'):
+    try:
+        from pkg_resources import iter_entry_points
+    except ImportError:
+        return
+
+    for ep in iter_entry_points(namespace):
+        for attr in ep.attrs:
+            command(symbol_by_name(':'.join([ep.module_name, attr])),
+                    name=ep.name)
+get_extension_commands()
+
+
+
 class Command(BaseCommand):
 class Command(BaseCommand):
     help = ''
     help = ''
     args = ''
     args = ''