redesigned scheduler

This commit is contained in:
Rushabh Mehta
2012-02-23 11:46:28 +05:30
parent c952bc9f70
commit 1a35574afe
4 changed files with 68 additions and 7 deletions

40
wnf.py
View File

@@ -23,13 +23,18 @@ def replace_code(start, txt1, txt2, extn):
def setup_options():
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-d", "--db",
dest="db_name",
help="Apply the patches on given db")
# build
parser.add_option("-b", "--build", default=False, action="store_true",
help="minify + concat js files")
parser.add_option("-c", "--clear", default=False, action="store_true",
help="increment version")
parser.add_option("--replace", nargs=3, default=False,
metavar = "search replace_by extension",
help="file search-replace")
# git
parser.add_option("--status", default=False, action="store_true",
help="git status")
parser.add_option("--pull", nargs=2, default=False,
@@ -41,28 +46,43 @@ def setup_options():
parser.add_option("-l", "--latest",
action="store_true", dest="run_latest", default=False,
help="Apply the latest patches")
# patch
parser.add_option("-p", "--patch", nargs=1, dest="patch_list", metavar='patch_module',
action="append",
help="Apply patch")
parser.add_option("-f", "--force",
action="store_true", dest="force", default=False,
help="Force Apply all patches specified using option -p or --patch")
parser.add_option("-d", "--db",
dest="db_name",
help="Apply the patches on given db")
parser.add_option('--reload_doc', nargs=3, metavar = "module doctype docname",
help="reload doc")
parser.add_option('--export_doc', nargs=2, metavar = "doctype docname",
help="export doc")
# install
parser.add_option('--install', nargs=3, metavar = "rootpassword dbname source",
help="install fresh db")
parser.add_option('--sync_with_gateway', nargs=1, metavar = "1/0", \
help="Set or Unset Sync with Gateway")
# diff
parser.add_option('--diff_ref_file', nargs=0, \
help="Get missing database records and mismatch properties, with file as reference")
parser.add_option('--diff_ref_db', nargs=0, \
help="Get missing .txt files and mismatch properties, with database as reference")
# scheduler
parser.add_option('--run_scheduler', default=False, action="store_true",
help="Trigger scheduler")
parser.add_option('--run_scheduler_event', nargs=1, metavar="[all|daily|weekly|monthly]",
help="Run scheduler event")
# misc
parser.add_option("--replace", nargs=3, default=False,
metavar = "search replace_by extension",
help="file search-replace")
return parser.parse_args()
def run():
@@ -165,6 +185,14 @@ def run():
import webnotes.modules.diff
webnotes.modules.diff.diff_ref_db()
elif options.run_scheduler:
import webnotes.utils.scheduler
print webnotes.utils.scheduler.execute()
elif options.run_scheduler_event is not None:
import webnotes.utils.scheduler
print webnotes.utils.scheduler.trigger('execute_' + options.run_scheduler_event)
# print messages
if webnotes.message_log:
print '\n'.join(webnotes.message_log)