diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index d0bfd0005b..0353625045 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -383,6 +383,16 @@ def get_version(): if hasattr(module, "__version__"): print "{0} {1}".format(m, module.__version__) +@click.command('setup-help') +def setup_help(): + "Make a database for help documentation" + frappe.local.flags = frappe._dict() + frappe.local.flags.in_setup_help = True + frappe.local.lang = 'en' + frappe.local.conf = frappe.get_site_config(sites_path='.') + from frappe.utils.help import sync + sync() + commands = [ build, clear_cache, @@ -407,4 +417,5 @@ commands = [ watch, _bulk_rename, add_to_email_queue, + setup_help ] diff --git a/frappe/model/db_schema.py b/frappe/model/db_schema.py index aa4d4cd04a..3f62859487 100644 --- a/frappe/model/db_schema.py +++ b/frappe/model/db_schema.py @@ -487,13 +487,10 @@ class DbManager: if not host: host = self.get_current_host() - try: - if password: - self.db.sql("CREATE USER '%s'@'%s' IDENTIFIED BY '%s';" % (user[:16], host, password)) - else: - self.db.sql("CREATE USER '%s'@'%s';" % (user[:16], host)) - except Exception: - raise + if password: + self.db.sql("CREATE USER '%s'@'%s' IDENTIFIED BY '%s';" % (user[:16], host, password)) + else: + self.db.sql("CREATE USER '%s'@'%s';" % (user[:16], host)) def delete_user(self, target, host=None): if not host: @@ -519,7 +516,8 @@ class DbManager: if not host: host = self.get_current_host() - self.db.sql("GRANT ALL PRIVILEGES ON `%s`.* TO '%s'@'%s';" % (target, user, host)) + self.db.sql("GRANT ALL PRIVILEGES ON `%s`.* TO '%s'@'%s';" % (target, + user, host)) def grant_select_privilges(self, db, table, user, host=None): if not host: diff --git a/frappe/translate.py b/frappe/translate.py index 3bf212a32f..869a2f282e 100644 --- a/frappe/translate.py +++ b/frappe/translate.py @@ -168,11 +168,11 @@ def get_full_dict(lang): :param lang: Language Code, e.g. `hi` """ - if not lang: + if not lang or lang=='en': return {} # found in local, return! - if frappe.local.lang_full_dict is not None: + if getattr(frappe.local, 'lang_full_dict', None) is not None: return frappe.local.lang_full_dict frappe.local.lang_full_dict = load_lang(lang) @@ -193,6 +193,9 @@ def load_lang(lang, apps=None): For derivative languages (es-GT), take translations from the base language (es) and then update translations from the child (es-GT)""" + if lang=='en': + return {} + out = frappe.cache().hget("lang_full_dict", lang) if not out: out = {} diff --git a/frappe/utils/help.py b/frappe/utils/help.py index c0d9595380..c068f86a45 100644 --- a/frappe/utils/help.py +++ b/frappe/utils/help.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +import hashlib from frappe.model.db_schema import DbManager from frappe.installer import get_root_connection @@ -32,10 +33,12 @@ def get_help_content(path): class HelpDatabase(object): def __init__(self): - self.help_db_name = '_frappe_help' + bench_name = os.path.basename(os.path.abspath(frappe.get_app_path('frappe')).split('/apps/')[0]) + self.help_db_name = hashlib.sha224(bench_name).hexdigest()[:15] def make_database(self): dbman = DbManager(get_root_connection()) + dbman.drop_database(self.help_db_name) # make database if not self.help_db_name in dbman.get_database_list(): @@ -61,7 +64,7 @@ class HelpDatabase(object): full_path text, fulltext(title), fulltext(content), - fulltext(path)) + index (path)) COLLATE=utf8mb4_unicode_ci ENGINE=MyISAM CHARACTER SET=utf8mb4''') @@ -95,8 +98,9 @@ class HelpDatabase(object): app_name = frappe.get_attr('{app}.__title__'.format(app=app)) or app doc_contents += '