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

View File

@ -0,0 +1,20 @@
import webnotes
def execute():
from webnotes.modules import reload_doc
reload_doc('accounts', 'page', 'accounts_home')
reload_doc('selling', 'page', 'selling_home')
reload_doc('buying', 'page', 'buying_home')
reload_doc('stock', 'page', 'stock_home')
reload_doc('hr', 'page', 'hr_home')
reload_doc('support', 'page', 'support_home')
reload_doc('production', 'page', 'production_home')
reload_doc('projects', 'page', 'projects_home')
reload_doc('website', 'page', 'website_home')
webnotes.conn.commit()
webnotes.conn.sql("""create table __SchedulerLog (
`timestamp` timestamp,
method varchar(200),
error text
) engine=MyISAM""")

View File

@ -783,7 +783,7 @@ def send():
send_date = dt_dict['server_dt'].date()
send_time = dt_dict['server_dt'].time()
if (now_date == send_date) and (send_time <= now_time):
if (now_date == send_date):
#webnotes.msgprint('sending ' + ed_obj.doc.name)
ed_obj.send()
#else:

View File

@ -0,0 +1,13 @@
"""will be called by scheduler"""
import webnotes
def execute_all():
"""get support email"""
from support.doctype.support_ticket import get_support_mails
get_support_mails()
def execute_daily():
"""email digest"""
from setup.doctype.email_digest.email_digest import send
send()

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)