blob: f3bf11ad65229e0f402aa809a527d75a80308011 [file] [log] [blame]
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +05301# Copyright (c) 2015, Web Notes Technologies Pvt. Ltd. and Contributors
2# MIT License. See license.txt
3
Chillar Anand915b3432021-09-02 16:44:59 +05304from __future__ import absolute_import, print_function, unicode_literals
5
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +05306import click
7import frappe
Chillar Anand915b3432021-09-02 16:44:59 +05308from frappe.commands import get_site, pass_context
9
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053010
11def call_command(cmd, context):
12 return click.Context(cmd, obj=context).forward(cmd)
13
14@click.command('make-demo')
15@click.option('--site', help='site name')
16@click.option('--domain', default='Manufacturing')
17@click.option('--days', default=100,
18 help='Run the demo for so many days. Default 100')
19@click.option('--resume', default=False, is_flag=True,
20 help='Continue running the demo for given days')
Rushabh Mehta73167ea2017-06-16 16:55:32 +053021@click.option('--reinstall', default=False, is_flag=True,
22 help='Reinstall site before demo')
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053023@pass_context
Rushabh Mehta73167ea2017-06-16 16:55:32 +053024def make_demo(context, site, domain='Manufacturing', days=100,
25 resume=False, reinstall=False):
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053026 "Reinstall site and setup demo"
27 from frappe.commands.site import _reinstall
28 from frappe.installer import install_app
29
30 site = get_site(context)
31
32 if resume:
33 with frappe.init_site(site):
34 frappe.connect()
35 from erpnext.demo import demo
36 demo.simulate(days=days)
37 else:
Rushabh Mehta73167ea2017-06-16 16:55:32 +053038 if reinstall:
39 _reinstall(site, yes=True)
Rushabh Mehta4f8f9c12017-06-12 09:18:06 +053040 with frappe.init_site(site=site):
41 frappe.connect()
42 if not 'erpnext' in frappe.get_installed_apps():
43 install_app('erpnext')
44
45 # import needs site
46 from erpnext.demo import demo
47 demo.make(domain, days)
48
49commands = [
50 make_demo
Ankush Menat4551d7d2021-08-19 13:41:10 +053051]