2017-06-12 03:48:06 +00:00
|
|
|
# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
|
|
|
|
# MIT License. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals, absolute_import, print_function
|
|
|
|
import click
|
|
|
|
import frappe
|
|
|
|
from frappe.commands import pass_context, get_site
|
|
|
|
|
|
|
|
def call_command(cmd, context):
|
|
|
|
return click.Context(cmd, obj=context).forward(cmd)
|
|
|
|
|
|
|
|
@click.command('make-demo')
|
|
|
|
@click.option('--site', help='site name')
|
|
|
|
@click.option('--domain', default='Manufacturing')
|
|
|
|
@click.option('--days', default=100,
|
|
|
|
help='Run the demo for so many days. Default 100')
|
|
|
|
@click.option('--resume', default=False, is_flag=True,
|
|
|
|
help='Continue running the demo for given days')
|
2017-06-16 11:25:32 +00:00
|
|
|
@click.option('--reinstall', default=False, is_flag=True,
|
|
|
|
help='Reinstall site before demo')
|
2017-06-12 03:48:06 +00:00
|
|
|
@pass_context
|
2017-06-16 11:25:32 +00:00
|
|
|
def make_demo(context, site, domain='Manufacturing', days=100,
|
|
|
|
resume=False, reinstall=False):
|
2017-06-12 03:48:06 +00:00
|
|
|
"Reinstall site and setup demo"
|
|
|
|
from frappe.commands.site import _reinstall
|
|
|
|
from frappe.installer import install_app
|
|
|
|
|
|
|
|
site = get_site(context)
|
|
|
|
|
|
|
|
if resume:
|
|
|
|
with frappe.init_site(site):
|
|
|
|
frappe.connect()
|
|
|
|
from erpnext.demo import demo
|
|
|
|
demo.simulate(days=days)
|
|
|
|
else:
|
2017-06-16 11:25:32 +00:00
|
|
|
if reinstall:
|
|
|
|
_reinstall(site, yes=True)
|
2017-06-12 03:48:06 +00:00
|
|
|
with frappe.init_site(site=site):
|
|
|
|
frappe.connect()
|
|
|
|
if not 'erpnext' in frappe.get_installed_apps():
|
|
|
|
install_app('erpnext')
|
|
|
|
|
|
|
|
# import needs site
|
|
|
|
from erpnext.demo import demo
|
|
|
|
demo.make(domain, days)
|
|
|
|
|
|
|
|
commands = [
|
|
|
|
make_demo
|
2021-08-19 08:11:10 +00:00
|
|
|
]
|