diff --git a/frappe/app.py b/frappe/app.py index af91d423e7..1abc74fb7e 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -175,7 +175,7 @@ def init_request(request): frappe.local.is_ajax = frappe.get_request_header("X-Requested-With") == "XMLHttpRequest" site = _site or request.headers.get("X-Frappe-Site-Name") or get_site_name(request.host) - frappe.init(site=site, sites_path=_sites_path, force=True) + frappe.init(site, sites_path=_sites_path, force=True) if not (frappe.local.conf and frappe.local.conf.db_name): # site does not exist diff --git a/frappe/commands/scheduler.py b/frappe/commands/scheduler.py index 2c112fbbae..07d725d451 100755 --- a/frappe/commands/scheduler.py +++ b/frappe/commands/scheduler.py @@ -17,7 +17,7 @@ def trigger_scheduler_event(context, event): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() try: frappe.get_doc("Scheduled Job Type", {"method": event}).execute() @@ -41,7 +41,7 @@ def enable_scheduler(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.utils.scheduler.enable_scheduler() frappe.db.commit() @@ -60,7 +60,7 @@ def disable_scheduler(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.utils.scheduler.disable_scheduler() frappe.db.commit() @@ -119,7 +119,7 @@ def set_maintenance_mode(context, state, site=None): site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) update_site_config("maintenance_mode", 1 if (state == "on") else 0) finally: @@ -238,7 +238,7 @@ def ready_for_migration(context, site=None): site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) pending_jobs = any_job_pending(site=site) if pending_jobs: diff --git a/frappe/commands/site.py b/frappe/commands/site.py index d11b83902e..460c1d77ba 100644 --- a/frappe/commands/site.py +++ b/frappe/commands/site.py @@ -88,7 +88,7 @@ def new_site( "Create a new site" from frappe.installer import _new_site - frappe.init(site=site, new_site=True) + frappe.init(site, new_site=True) mariadb_user_host_login_scope = None @@ -182,7 +182,7 @@ def restore( from frappe.utils.synchronization import filelock site = get_site(context) - frappe.init(site=site) + frappe.init(site) with filelock("site_restore", timeout=1): _restore( @@ -374,7 +374,7 @@ def partial_restore(context, sql_file_path, verbose, encryption_key=None): site = get_site(context) verbose = context.verbose or verbose - frappe.init(site=site) + frappe.init(site) frappe.connect() err, out = frappe.utils.execute_in_shell(f"file {sql_file_path}", check_exit_code=True) if err: @@ -446,7 +446,7 @@ def _reinstall( if not yes: click.confirm("This will wipe your database. Are you sure you want to reinstall?", abort=True) try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.clear_cache() installed = frappe.get_installed_apps() @@ -458,7 +458,7 @@ def _reinstall( frappe.db.close() frappe.destroy() - frappe.init(site=site) + frappe.init(site) _new_site( frappe.conf.db_name, @@ -487,7 +487,7 @@ def install_app(context, apps, force=False): raise SiteNotSpecifiedError for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() with filelock("install_app", timeout=1): @@ -528,7 +528,7 @@ def list_apps(context, format): return template.format(app.app_name, app.app_version, app.git_branch) for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() site_title = click.style(f"{site}", fg="green") if len(context.sites) > 1 else "" installed_apps_info = [] @@ -566,7 +566,7 @@ def add_db_index(context, doctype, column): columns = column # correct naming for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() try: frappe.db.add_index(doctype, columns) @@ -599,7 +599,7 @@ def add_system_manager(context, email, first_name, last_name, send_welcome_email import frappe.utils.user for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() try: frappe.utils.user.add_system_manager(email, first_name, last_name, send_welcome_email, password) @@ -626,7 +626,7 @@ def add_user_for_sites( import frappe.utils.user for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() try: add_new_user(email, first_name, last_name, user_type, send_welcome_email, password, add_role) @@ -691,7 +691,7 @@ def run_patch(context, module, force): import frappe.modules.patch_handler for site in context.sites: - frappe.init(site=site) + frappe.init(site) try: frappe.connect() frappe.modules.patch_handler.run_single(module, force=force or context.force) @@ -710,7 +710,7 @@ def reload_doc(context, module, doctype, docname): "Reload schema for a DocType" for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.reload_doc(module, doctype, docname, force=context.force) frappe.db.commit() @@ -727,7 +727,7 @@ def reload_doctype(context, doctype): "Reload schema for a DocType" for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.reload_doctype(doctype, force=context.force) frappe.db.commit() @@ -823,7 +823,7 @@ def backup( for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() rollback_callback = CallbackManager() odb = scheduled_backup( @@ -885,7 +885,7 @@ def remove_from_installed_apps(context, app): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() remove_from_installed_apps(app) finally: @@ -915,7 +915,7 @@ def uninstall(context, app, dry_run, yes, no_backup, force): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() with filelock("uninstall_app"): remove_app(app_name=app, dry_run=dry_run, yes=yes, no_backup=no_backup, force=force) @@ -965,7 +965,7 @@ def _drop_site( from frappe.database import drop_user_and_database from frappe.utils.backups import scheduled_backup - frappe.init(site=site) + frappe.init(site) frappe.connect() try: @@ -1058,7 +1058,7 @@ def set_user_password(site, user, password, logout_all_sessions=False): from frappe.utils.password import update_password try: - frappe.init(site=site) + frappe.init(site) while not password: password = getpass.getpass(f"{user}'s password for {site}: ") @@ -1112,7 +1112,7 @@ def publish_realtime(context, event, message, room, user, doctype, docname, afte for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() publish_realtime( event, @@ -1147,7 +1147,7 @@ def browse(context, site, user=None): click.echo(f"\nSite named {click.style(site, bold=True)} doesn't exist\n", err=True) sys.exit(1) - frappe.init(site=site) + frappe.init(site) frappe.connect() sid = "" @@ -1180,7 +1180,7 @@ def start_recording(context): import frappe.recorder for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.set_user("Administrator") frappe.recorder.start() if not context.sites: @@ -1194,7 +1194,7 @@ def stop_recording(context): import frappe.recorder for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.set_user("Administrator") frappe.recorder.stop() if not context.sites: @@ -1215,7 +1215,7 @@ def start_ngrok(context, bind_tls, use_default_authtoken): from pyngrok import ngrok site = get_site(context) - frappe.init(site=site) + frappe.init(site) ngrok_authtoken = frappe.conf.ngrok_authtoken if not use_default_authtoken: @@ -1257,7 +1257,7 @@ def build_search_index(context): raise SiteNotSpecifiedError print(f"Building search index for {site}") - frappe.init(site=site) + frappe.init(site) frappe.connect() try: build_index_for_all_routes() @@ -1289,7 +1289,7 @@ def clear_log_table(context, doctype, days, no_backup): raise frappe.ValidationError(f"Unsupported logging DocType: {doctype}") for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() if not no_backup: @@ -1333,7 +1333,7 @@ def trim_database(context, dry_run, format, no_backup, yes=False): ALL_DATA = {} for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() TABLES_TO_DROP = [] @@ -1435,7 +1435,7 @@ def trim_tables(context, dry_run, format, no_backup): from frappe.utils.backups import scheduled_backup for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() if not (no_backup or dry_run): @@ -1525,7 +1525,7 @@ def bypass_patch(context, patch_name: str, yes: bool): ) for site in context.sites: - frappe.init(site=site) + frappe.init(site) frappe.connect() try: update_patch_log(patch_name) diff --git a/frappe/commands/translate.py b/frappe/commands/translate.py index fde4a3939e..daa6affdf3 100644 --- a/frappe/commands/translate.py +++ b/frappe/commands/translate.py @@ -13,7 +13,7 @@ def build_message_files(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.translate.rebuild_all_translation_files() finally: @@ -54,7 +54,7 @@ def get_untranslated(context, lang, untranslated_file, app="_ALL_APPS", all=None site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.translate.get_untranslated(lang, untranslated_file, get_all=all, app=app) finally: @@ -73,7 +73,7 @@ def update_translations(context, lang, untranslated_file, translated_file, app=" site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.translate.update_translations(lang, untranslated_file, translated_file, app=app) finally: @@ -90,7 +90,7 @@ def import_translations(context, lang, path): site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.translate.import_translations(lang, path) finally: @@ -107,7 +107,7 @@ def migrate_translations(context, source_app, target_app): site = get_site(context) try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.translate.migrate_translations(source_app, target_app) finally: diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 50aae06990..10117f8d18 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -124,7 +124,7 @@ def clear_cache(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.clear_cache() clear_website_cache() @@ -142,7 +142,7 @@ def clear_website_cache(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() clear_website_cache() finally: @@ -160,7 +160,7 @@ def destroy_all_sessions(context, reason=None): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.sessions.clear_all_sessions(reason) frappe.db.commit() @@ -229,7 +229,7 @@ def reset_perms(context): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() for d in frappe.db.sql_list( """select name from `tabDocType` @@ -254,7 +254,7 @@ def execute(context, method, args=None, kwargs=None, profile=False): for site in context.sites: ret = "" try: - frappe.init(site=site) + frappe.init(site) frappe.connect() if args: @@ -332,7 +332,7 @@ def export_doc(context, doctype, docname): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.modules.export_doc(doctype, docname) finally: @@ -352,7 +352,7 @@ def export_json(context, doctype, path, name=None): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() export_json(doctype, path, name=name) finally: @@ -371,7 +371,7 @@ def export_csv(context, doctype, path): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() export_csv(doctype, path) finally: @@ -389,7 +389,7 @@ def export_fixtures(context, app=None): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() export_fixtures(app=app) finally: @@ -413,7 +413,7 @@ def import_doc(context, path, force=False): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() import_doc(path) finally: @@ -450,7 +450,7 @@ def data_import(context, file_path, doctype, import_type=None, submit_after_impo site = get_site(context) - frappe.init(site=site) + frappe.init(site) frappe.connect() import_file(doctype, file_path, import_type, submit_after_import, console=True) frappe.destroy() @@ -470,7 +470,7 @@ def bulk_rename(context, doctype, path): with open(path) as csvfile: rows = read_csv_content(csvfile.read()) - frappe.init(site=site) + frappe.init(site) frappe.connect() bulk_rename(doctype, rows, via_console=True) @@ -486,7 +486,7 @@ def database(context, extra_args): Enter into the Database console for given site. """ site = get_site(context) - frappe.init(site=site) + frappe.init(site) _enter_console(extra_args=extra_args) @@ -498,7 +498,7 @@ def mariadb(context, extra_args): Enter into mariadb console for a given site. """ site = get_site(context) - frappe.init(site=site) + frappe.init(site) frappe.conf.db_type = "mariadb" _enter_console(extra_args=extra_args) @@ -511,7 +511,7 @@ def postgres(context, extra_args): Enter into postgres console for a given site. """ site = get_site(context) - frappe.init(site=site) + frappe.init(site) frappe.conf.db_type = "postgres" _enter_console(extra_args=extra_args) @@ -555,7 +555,7 @@ def jupyter(context): subprocess.check_output([sys.executable, "-m", "pip", "install", "jupyter"]) site = get_site(context) - frappe.init(site=site) + frappe.init(site) jupyter_notebooks_path = os.path.abspath(frappe.get_site_path("jupyter_notebooks")) sites_path = os.path.abspath(frappe.get_site_path("..")) @@ -572,7 +572,7 @@ Starting Jupyter notebook Run the following in your first cell to connect notebook to frappe ``` import frappe -frappe.init(site='{site}', sites_path='{sites_path}') +frappe.init('{site}', sites_path='{sites_path}') frappe.connect() frappe.local.lang = frappe.db.get_default('lang') frappe.db.connect() @@ -613,7 +613,7 @@ def store_logs(terminal: "InteractiveShellEmbed") -> None: def console(context, autoreload=False): "Start ipython console for a site" site = get_site(context) - frappe.init(site=site) + frappe.init(site) frappe.connect() frappe.local.lang = frappe.db.get_default("lang") @@ -682,7 +682,7 @@ def transform_database(context, table, engine, row_format, failfast): check_table = [] add_line = False skipped = 0 - frappe.init(site=site) + frappe.init(site) if frappe.conf.db_type != "mariadb": click.secho("This command only has support for MariaDB databases at this point", fg="yellow") @@ -1014,7 +1014,7 @@ def request(context, args=None, path=None): for site in context.sites: try: - frappe.init(site=site) + frappe.init(site) frappe.connect() if args: if "?" in args: @@ -1085,7 +1085,7 @@ def set_config(context, key, value, global_=False, parse=False): if not context.sites: raise SiteNotSpecifiedError for site in context.sites: - frappe.init(site=site) + frappe.init(site) update_site_config(key, value, validate=False) frappe.destroy() diff --git a/frappe/installer.py b/frappe/installer.py index 9cec6a471c..662228355e 100644 --- a/frappe/installer.py +++ b/frappe/installer.py @@ -25,7 +25,7 @@ from frappe.utils.synchronization import filelock def _is_scheduler_enabled(site) -> bool: enable_scheduler = False try: - frappe.init(site=site) + frappe.init(site) frappe.connect() enable_scheduler = cint(frappe.db.get_single_value("System Settings", "enable_scheduler")) except Exception: @@ -64,7 +64,7 @@ def _new_site( print(f"Site {site} already exists, use `--force` to proceed anyway") sys.exit(1) - frappe.init(site=site) + frappe.init(site) if not db_name: db_name = f"_{frappe.generate_hash(length=16)}" @@ -753,7 +753,7 @@ def extract_files(site_name, file_path): file_path = get_bench_relative_path(file_path) # Need to do frappe.init to maintain the site locals - frappe.init(site=site_name) + frappe.init(site_name) abs_site_path = os.path.abspath(frappe.get_site_path()) # Copy the files to the parent directory and extract diff --git a/frappe/migrate.py b/frappe/migrate.py index b6ebf00a2b..d5fa8254b8 100644 --- a/frappe/migrate.py +++ b/frappe/migrate.py @@ -192,7 +192,7 @@ class SiteMigration: from frappe.utils.synchronization import filelock if site: - frappe.init(site=site) + frappe.init(site) frappe.connect() if not self.required_services_running(): diff --git a/frappe/parallel_test_runner.py b/frappe/parallel_test_runner.py index 49278028f4..51adf9cdf3 100644 --- a/frappe/parallel_test_runner.py +++ b/frappe/parallel_test_runner.py @@ -30,7 +30,7 @@ class ParallelTestRunner: self.run_tests() def setup_test_site(self): - frappe.init(site=self.site) + frappe.init(self.site) if not frappe.db: frappe.connect() diff --git a/frappe/test_runner.py b/frappe/test_runner.py index 1c40d48232..2aa5418551 100644 --- a/frappe/test_runner.py +++ b/frappe/test_runner.py @@ -57,7 +57,7 @@ def main( ): global unittest_runner - frappe.init(site=site) + frappe.init(site) if not frappe.db: frappe.connect() diff --git a/frappe/tests/test_commands.py b/frappe/tests/test_commands.py index 59f4c7c8fa..ff657a2eae 100644 --- a/frappe/tests/test_commands.py +++ b/frappe/tests/test_commands.py @@ -95,7 +95,7 @@ def maintain_locals(): finally: post_site = getattr(frappe.local, "site", None) if not post_site or post_site != pre_site: - frappe.init(site=pre_site) + frappe.init(pre_site) frappe.local.db = pre_db frappe.local.flags.update(pre_flags) diff --git a/frappe/tests/test_perf.py b/frappe/tests/test_perf.py index 09f4193f26..c91063093c 100644 --- a/frappe/tests/test_perf.py +++ b/frappe/tests/test_perf.py @@ -41,7 +41,7 @@ class TestPerformance(FrappeTestCase): def reset_request_specific_caches(self): # To simulate close to request level of handling frappe.destroy() # releases everything on frappe.local - frappe.init(site=self.TEST_SITE) + frappe.init(self.TEST_SITE) frappe.connect() frappe.clear_cache() diff --git a/frappe/tests/test_translate.py b/frappe/tests/test_translate.py index b586885d62..eec05d226d 100644 --- a/frappe/tests/test_translate.py +++ b/frappe/tests/test_translate.py @@ -156,7 +156,7 @@ class TestTranslate(FrappeTestCase): site = frappe.local.site frappe.destroy() _("this shouldn't break") - frappe.init(site=site) + frappe.init(site) frappe.connect() def test_guest_request_language_resolution_with_request_header(self): diff --git a/frappe/utils/background_jobs.py b/frappe/utils/background_jobs.py index 4e2a7c71b9..89533a9eee 100644 --- a/frappe/utils/background_jobs.py +++ b/frappe/utils/background_jobs.py @@ -204,7 +204,7 @@ def execute_job(site, method, event, job_name, kwargs, user=None, is_async=True, retval = None if is_async: - frappe.init(site=site) + frappe.init(site) frappe.connect() if os.environ.get("CI"): frappe.flags.in_test = True diff --git a/frappe/utils/scheduler.py b/frappe/utils/scheduler.py index fcb514ade6..5d023c8135 100644 --- a/frappe/utils/scheduler.py +++ b/frappe/utils/scheduler.py @@ -101,7 +101,7 @@ def enqueue_events_for_site(site: str) -> None: try: _proctitle(f"scheduling events for {site}") - frappe.init(site=site) + frappe.init(site) frappe.connect() if is_scheduler_inactive(): return