incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [3/3] git commit: [#6191] ticket:334 Run paster commands as background tasks
Date Thu, 09 May 2013 17:24:20 GMT
[#6191] ticket:334 Run paster commands as background tasks


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3c5358c7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3c5358c7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3c5358c7

Branch: refs/heads/master
Commit: 3c5358c729b5b91e3c4580188ab9ebaccd64f74f
Parents: 0e9e791
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon May 6 11:27:07 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu May 9 17:23:11 2013 +0000

----------------------------------------------------------------------
 Allura/allura/command/base.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3c5358c7/Allura/allura/command/base.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/base.py b/Allura/allura/command/base.py
index c834d34..1ff7d03 100644
--- a/Allura/allura/command/base.py
+++ b/Allura/allura/command/base.py
@@ -29,9 +29,18 @@ from paste.registry import Registry
 import activitystream
 import ming
 from allura.config.environment import load_environment
+from allura.lib.decorators import task
 
 log = None
 
+@task
+def run_command(command, args):
+    """Run paster command asynchronously"""
+    mod, cls = command.rsplit('.', 1)
+    mod = __import__(mod, fromlist=[str(cls)])
+    command = getattr(mod, cls)
+    return command(command.__name__).run(args.split())
+
 class EmptyClass(object): pass
 
 class Command(command.Command):
@@ -40,6 +49,16 @@ class Command(command.Command):
     usage = '[<ini file>]'
     group_name = 'Allura'
 
+    class __metaclass__(type):
+        @property
+        def __doc__(cls):
+            return cls.parser.format_help()
+
+    @classmethod
+    def post(cls, *args, **kw):
+        cmd = '%s.%s' % (cls.__module__, cls.__name__)
+        return run_command.post(cmd, *args, **kw)
+
     @ming.utils.LazyProperty
     def registry(self):
         return Registry()


Mime
View raw message