You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/02/11 20:49:19 UTC
git commit: [#5703] Added doc; removed test script
Updated Branches:
refs/heads/tv/5703 0e28be71e -> 683419d58
[#5703] Added doc; removed test script
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/683419d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/683419d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/683419d5
Branch: refs/heads/tv/5703
Commit: 683419d580dad0accc7d045137a7e2ddbb1a0fee
Parents: 0e28be7
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Mon Feb 11 19:48:59 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Mon Feb 11 19:48:59 2013 +0000
----------------------------------------------------------------------
Allura/allura/scripts/scripttask.py | 30 ++++++++++++++++++++++++++++++
Allura/allura/scripts/test.py | 3 ---
2 files changed, 30 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/683419d5/Allura/allura/scripts/scripttask.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/scripttask.py b/Allura/allura/scripts/scripttask.py
index 91a3a2f..4ce2dc2 100644
--- a/Allura/allura/scripts/scripttask.py
+++ b/Allura/allura/scripts/scripttask.py
@@ -1,3 +1,32 @@
+"""
+Provides ScriptTask, a base class for implementing a command-line script that
+can be run as a task.
+
+To use, subclass ScriptTask and implement two methods::
+
+ class MyScript(ScriptTask):
+ @classmethod
+ def parser(cls):
+ '''Define and return an argparse.ArgumentParser instance'''
+ pass
+
+ @classmethod
+ def execute(cls, options):
+ '''Your main code goes here.'''
+ pass
+
+To call as a script::
+
+ if __name__ == '__main__':
+ MyScript.main()
+
+To call as a task::
+
+ # post the task with cmd-line-style args
+ MyScript.post('-p myproject --dry-run')
+
+"""
+
import argparse
import copy_reg
import logging
@@ -11,6 +40,7 @@ from allura.lib.decorators import task
log = logging.getLogger(__name__)
+# make methods picklable
def reduce_method(m):
return (getattr, (m.__self__, m.__func__.__name__))
copy_reg.pickle(types.MethodType, reduce_method)
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/683419d5/Allura/allura/scripts/test.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/test.py b/Allura/allura/scripts/test.py
deleted file mode 100644
index 58f8a16..0000000
--- a/Allura/allura/scripts/test.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from allura.scripts.refreshrepo import RefreshRepo
-
-RefreshRepo.post('--roject test4691b --mount-point git3 --clean --all')