From 3cf41a18f74e7e95fe4892da28e2d27ec7524a35 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 1 Mar 2021 00:47:00 +0530 Subject: [PATCH] fix: add try-except block for importing new_site maintain compatibility across frappe versions. Signed-off-by: Chinmay D. Pai --- build/common/commands/new.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 22b8a82a..b54bfc18 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -2,7 +2,7 @@ import os import frappe import semantic_version -from frappe.installer import _new_site, update_site_config +from frappe.installer import update_site_config from constants import COMMON_SITE_CONFIG_FILE, RDS_DB, RDS_PRIVILEGES from utils import ( run_command, @@ -11,6 +11,16 @@ from utils import ( get_password, ) +# try to import _new_site from frappe, which could possibly +# exist in either commands.py or installer.py, and so we need +# to maintain compatibility across all frappe versions. +try: + # <= version-{11,12} + from frappe.commands.site import _new_site +except ImportError: + # >= version-13 and develop + from frappe.installer import _new_site + def main(): config = get_config()