From 04e0af578b5242074e3114929a361f96d2107d97 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 24 Sep 2020 11:56:02 +0530 Subject: [PATCH 1/2] fix: Give better errors about corrupt configs --- frappe/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index e1fe790b45..3091c06dcd 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -10,7 +10,7 @@ from six import iteritems, binary_type, text_type, string_types, PY2 from werkzeug.local import Local, release_local import os, sys, importlib, inspect, json from past.builtins import cmp - +import click from faker import Faker # public @@ -226,12 +226,20 @@ def get_site_config(sites_path=None, site_path=None): if sites_path: common_site_config = os.path.join(sites_path, "common_site_config.json") if os.path.exists(common_site_config): - config.update(get_file_json(common_site_config)) + try: + config.update(get_file_json(common_site_config)) + except Exception as error: + click.secho("Common Site Config may be corrupted", fg="red") + print(error) if site_path: site_config = os.path.join(site_path, "site_config.json") if os.path.exists(site_config): - config.update(get_file_json(site_config)) + try: + config.update(get_file_json(site_config)) + except Exception as error: + click.secho("Site Config for {0} may be corrupted".format(local.site), fg="red") + print(error) elif local.site and not local.flags.new_site: raise IncorrectSitePath("{0} does not exist".format(local.site)) From 0ee7d890bcaf0e0ec2496e8d95ed6a98ca695d1f Mon Sep 17 00:00:00 2001 From: gavin Date: Thu, 24 Sep 2020 13:38:10 +0530 Subject: [PATCH 2/2] fix: Provide file paths instead of "title"s Co-authored-by: Faris Ansari --- frappe/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frappe/__init__.py b/frappe/__init__.py index 3091c06dcd..554f1f9747 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -229,7 +229,7 @@ def get_site_config(sites_path=None, site_path=None): try: config.update(get_file_json(common_site_config)) except Exception as error: - click.secho("Common Site Config may be corrupted", fg="red") + click.secho("common_site_config.json is invalid", fg="red") print(error) if site_path: @@ -238,7 +238,7 @@ def get_site_config(sites_path=None, site_path=None): try: config.update(get_file_json(site_config)) except Exception as error: - click.secho("Site Config for {0} may be corrupted".format(local.site), fg="red") + click.secho("{0}/site_config.json is invalid".format(local.site), fg="red") print(error) elif local.site and not local.flags.new_site: raise IncorrectSitePath("{0} does not exist".format(local.site))