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/09/19 18:22:13 UTC

[41/41] git commit: [#5822] add generic task for installing an app

[#5822] add generic task for installing an app


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

Branch: refs/heads/db/5822
Commit: 585935abd9034b8734f61ec293df69dfce7cdcfd
Parents: b6ab594
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Tue Sep 17 17:58:30 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Sep 19 16:21:15 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/admin_tasks.py | 37 +++++++++++++++++++++++++++++++++
 Allura/allura/tests/test_tasks.py  |  8 ++++++-
 Allura/docs/administration.rst     | 11 +++++++++-
 Allura/docs/api/tasks.rst          | 30 ++++++++++++++++++++++++++
 4 files changed, 84 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/585935ab/Allura/allura/tasks/admin_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/admin_tasks.py b/Allura/allura/tasks/admin_tasks.py
new file mode 100644
index 0000000..e8b67c0
--- /dev/null
+++ b/Allura/allura/tasks/admin_tasks.py
@@ -0,0 +1,37 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import inspect
+
+from pylons import tmpl_context as c
+
+from allura import model as M
+from allura.lib.decorators import task
+
+
+@task
+def install_app(*args, **kwargs):
+    '''
+    Install an application directly onto c.project, bypassing the UI and any app
+    constraints like installable=False
+    '''
+    c.project.install_app(*args, **kwargs)
+
+install_app.__doc__ += '''
+    Arguments: ''' + inspect.formatargspec(*inspect.getargspec(
+        M.Project.install_app
+    )).replace('self, ','')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/585935ab/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index af7898e..dcbde71 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -47,6 +47,7 @@ from allura.tasks import mail_tasks
 from allura.tasks import notification_tasks
 from allura.tasks import repo_tasks
 from allura.tasks import export_tasks
+from allura.tasks import admin_tasks
 from allura.tests import decorators as td
 from allura.lib.decorators import event_handler, task
 
@@ -372,7 +373,7 @@ class TestExportTasks(unittest.TestCase):
         project_json.assert_called_once()
         temp = '/tmp/bulk_export/p/test/test'
         zipfn = '/tmp/bulk_export/p/test/test.zip'
-        zipdir.assert_caled_with(temp, temp + '/test.zip')
+        zipdir.assert_called_with(temp, zipfn)
         shutil.rmtree.assert_called_once_with(temp)
         # check notification
         M.MonQTask.run_ready()
@@ -410,4 +411,9 @@ class TestExportTasks(unittest.TestCase):
         assert_equal(c.project.bulk_export_status(), 'busy')
 
 
+class TestAdminTasks(unittest.TestCase):
+
+    def test_install_app_docstring(self):
+        assert_in('ep_name, mount_point=None', admin_tasks.install_app.__doc__)
+
 Mapper.compile_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/585935ab/Allura/docs/administration.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/administration.rst b/Allura/docs/administration.rst
index b58339f..3874179 100644
--- a/Allura/docs/administration.rst
+++ b/Allura/docs/administration.rst
@@ -49,8 +49,17 @@ Scripts are in the `scripts/` directory and run via `paster script`.  An extra
 
     (env-allura) Allura$ paster script development.ini ../scripts/create-allura-sitemap.py -- -u 100
 
+TODO:   explain important scripts, commands
 
-TODO: explain how to run tasks, explain important scripts, commands and tasks here
+Tasks can be run via the web interface at /nf/admin/task_manager  You must know
+the full task name, e.g. `allura.tasks.admin_tasks.install_app`  You can
+optionally provide a username and project and app which will get set on the
+current context (`c`).  You should specify what args and kwargs will be passed
+as parameters to the task.  They are specified in JSON format on the form.
+
+See the listing of :mod:`some available tasks <allura.tasks.admin_tasks>`.
+
+TODO: explain how to run scripttasks and commandtasks
 
 
 Client Scripts

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/585935ab/Allura/docs/api/tasks.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/api/tasks.rst b/Allura/docs/api/tasks.rst
new file mode 100644
index 0000000..d49b8af
--- /dev/null
+++ b/Allura/docs/api/tasks.rst
@@ -0,0 +1,30 @@
+..     Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+
+.. _tasks_module:
+
+:mod:`allura.tasks`
+--------------------------------
+
+.. automodule:: allura.tasks
+
+  .. automodule:: allura.tasks.admin_tasks
+        :members:
+
+  .. automodule:: allura.tasks.export_tasks
+
+        .. autofunction:: allura.tasks.export_tasks.bulk_export