Exemple #1
0
def drop_site(site,
              root_login='******',
              root_password=None,
              archived_sites_path=None):
    "Remove site from database and filesystem"
    from frappe.installer import get_current_host, make_connection
    from frappe.model.db_schema import DbManager
    from frappe.utils.backups import scheduled_backup

    frappe.init(site=site)
    frappe.connect()
    scheduled_backup(ignore_files=False, force=True)

    db_name = frappe.local.conf.db_name
    frappe.local.db = make_connection(root_login, root_password)
    dbman = DbManager(frappe.local.db)
    dbman.delete_user(db_name, get_current_host())
    dbman.drop_database(db_name)

    if not archived_sites_path:
        archived_sites_path = os.path.join(frappe.get_app_path('frappe'), '..',
                                           '..', '..', 'archived_sites')

    if not os.path.exists(archived_sites_path):
        os.mkdir(archived_sites_path)

    move(archived_sites_path, site)
def drop_site(site, root_login='******', root_password=None):
	from frappe.installer import get_current_host, make_connection
	from frappe.model.db_schema import DbManager
	from frappe.utils.backups import scheduled_backup

	frappe.init(site=site)
	frappe.connect()
	scheduled_backup(ignore_files=False, force=True)

	db_name = frappe.local.conf.db_name
	frappe.local.db = make_connection(root_login, root_password)
	dbman = DbManager(frappe.local.db)
	dbman.delete_user(db_name, get_current_host())
	dbman.drop_database(db_name)

	archived_sites_dir = os.path.join(frappe.get_app_path('frappe'), '..', '..', '..', 'archived_sites')
	if not os.path.exists(archived_sites_dir):
		os.mkdir(archived_sites_dir)
	move(archived_sites_dir, site)