You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/05/09 19:24:18 UTC
[1/3] git commit: [#6191] ticket:334 Fix args splitting
Updated Branches:
refs/heads/master 0e9e79125 -> 5d046129c
[#6191] ticket:334 Fix args splitting
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5d046129
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5d046129
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5d046129
Branch: refs/heads/master
Commit: 5d046129c5efc6f2d44a165e29badcd27f1464f4
Parents: aa36dbf
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 6 13:27:59 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 9 17:23:11 2013 +0000
----------------------------------------------------------------------
Allura/allura/command/base.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5d046129/Allura/allura/command/base.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/base.py b/Allura/allura/command/base.py
index 1ff7d03..d433643 100644
--- a/Allura/allura/command/base.py
+++ b/Allura/allura/command/base.py
@@ -18,6 +18,7 @@
import os
import sys
import logging
+import shlex
from multiprocessing import Process
from pkg_resources import iter_entry_points
@@ -39,7 +40,7 @@ def run_command(command, args):
mod, cls = command.rsplit('.', 1)
mod = __import__(mod, fromlist=[str(cls)])
command = getattr(mod, cls)
- return command(command.__name__).run(args.split())
+ return command(command.__name__).run(shlex.split(args or ''))
class EmptyClass(object): pass
[2/3] git commit: [#6191] ticket:334 Tests
Posted by br...@apache.org.
[#6191] ticket:334 Tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/aa36dbf9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/aa36dbf9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/aa36dbf9
Branch: refs/heads/master
Commit: aa36dbf9840debb77b03bbe50966009d34283f6a
Parents: 3c5358c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 6 13:27:32 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu May 9 17:23:11 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/test_commands.py | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/aa36dbf9/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index e4a11b9..06524c3 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-from nose.tools import assert_raises
+from nose.tools import assert_raises, assert_in
from datadiff.tools import assert_equal
from ming.orm import ThreadLocalORMSession
-from mock import Mock, call
+from mock import Mock, call, patch
from alluratest.controller import setup_basic_test, setup_global_objects
-from allura.command import script, set_neighborhood_features, \
+from allura.command import base, script, set_neighborhood_features, \
create_neighborhood, show_models, taskd_cleanup
from allura import model as M
from forgeblog import model as BM
@@ -316,3 +316,25 @@ def test_status_log_retries():
cmd._check_task(123, Mock())
expected_calls = [call(123, False if i == 0 else True) for i in range(3)]
assert cmd._taskd_status.mock_calls == expected_calls
+
+
+class TestBackgroundCommand(object):
+
+ cmd = 'allura.command.show_models.ReindexCommand'
+ task_name = 'allura.command.base.run_command'
+
+ def test_command_post(self):
+ show_models.ReindexCommand.post('-p "project 3"')
+ tasks = M.MonQTask.query.find({'task_name': self.task_name}).all()
+ assert_equal(len(tasks), 1)
+ task = tasks[0]
+ assert_equal(task.args, [self.cmd, '-p "project 3"'])
+
+ def test_command_doc(self):
+ assert_in('Usage:', show_models.ReindexCommand.__doc__)
+
+ @patch('allura.command.show_models.ReindexCommand')
+ def test_run_command(self, command):
+ command.__name__ = 'ReindexCommand'
+ base.run_command(self.cmd, 'dev.ini -p "project 3"')
+ command(command.__name__).run.assert_called_with(['dev.ini', '-p', 'project 3'])
[3/3] git commit: [#6191] ticket:334 Run paster commands as
background tasks
Posted by br...@apache.org.
[#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 <je...@gmail.com>
Authored: Mon May 6 11:27:07 2013 +0000
Committer: Dave Brondsema <db...@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()