コード例 #1
0
ファイル: install.py プロジェクト: mhbu50/frappe-sebco
def after_install():
    # reset installed apps for re-install
    frappe.db.set_global("installed_apps", '["frappe"]')

    install_basic_docs()

    from frappe.core.doctype.file.file import make_home_folder
    make_home_folder()

    import_country_and_currency()

    from frappe.core.doctype.language.language import sync_languages
    sync_languages()

    # save default print setting
    print_settings = frappe.get_doc("Print Settings")
    print_settings.save()

    # all roles to admin
    frappe.get_doc("User", "Administrator").add_roles(
        *frappe.db.sql_list("""select name from tabRole"""))

    # update admin password
    update_password("Administrator", get_admin_password())

    # setup wizard now in frappe
    frappe.db.set_default('desktop:home_page', 'setup-wizard')

    frappe.db.commit()
コード例 #2
0
def migrate(verbose=True, rebuild_website=False, skip_failing=False):
	'''Migrate all apps to the latest version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks
	'''

	touched_tables_file = frappe.get_site_path('touched_tables.json')
	if os.path.exists(touched_tables_file):
		os.remove(touched_tables_file)

	try:
		frappe.flags.touched_tables = set()
		frappe.flags.in_migrate = True

		clear_global_cache()

		#run before_migrate hooks
		for app in frappe.get_installed_apps():
			for fn in frappe.get_hooks('before_migrate', app_name=app):
				frappe.get_attr(fn)()

		# run patches
		frappe.modules.patch_handler.run_all(skip_failing)
		# sync
		frappe.model.sync.sync_all(verbose=verbose)
		frappe.translate.clear_cache()
		sync_jobs()
		sync_fixtures()
		sync_customizations()
		sync_languages()

		frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

		# syncs statics
		render.clear_cache()

		# add static pages to global search
		global_search.update_global_search_for_all_web_pages()

		#run after_migrate hooks
		for app in frappe.get_installed_apps():
			for fn in frappe.get_hooks('after_migrate', app_name=app):
				frappe.get_attr(fn)()

		frappe.db.commit()

		clear_notifications()

		frappe.publish_realtime("version-update")
		frappe.flags.in_migrate = False
	finally:
		with open(touched_tables_file, 'w') as f:
			json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4)
		frappe.flags.touched_tables.clear()
コード例 #3
0
def after_install():
    # reset installed apps for re-install
    frappe.db.set_global("installed_apps", '["frappe"]')

    install_basic_docs()

    from frappe.core.doctype.file.file import make_home_folder
    make_home_folder()

    import_country_and_currency()

    from frappe.core.doctype.language.language import sync_languages
    sync_languages()

    # save default print setting
    print_settings = frappe.get_doc("Print Settings")
    print_settings.save()

    # all roles to admin
    frappe.get_doc("User", "Administrator").add_roles(
        *frappe.db.sql_list("""select name from tabRole"""))

    # update admin password
    update_password("Administrator", get_admin_password())

    if not frappe.conf.skip_setup_wizard:
        frappe.db.set_default('desktop:home_page', 'setup-wizard')

    # clear test log
    with open(frappe.get_site_path('.test_log'), 'w') as f:
        f.write('')

    add_standard_navbar_items()

    frappe.db.commit()
コード例 #4
0
def migrate(verbose=True, rebuild_website=False):
	'''Migrate all apps to the latest version, will:

	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)'''
	clear_global_cache()

	# run patches
	frappe.modules.patch_handler.run_all()
	# sync
	frappe.model.sync.sync_all(verbose=verbose)
	frappe.translate.clear_cache()
	sync_fixtures()
	sync_customizations()
	sync_desktop_icons()
	sync_languages()

	frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

	# syncs statics
	render.clear_cache()

	frappe.db.commit()

	if not frappe.conf.get('global_help_setup'):
		# sync help if not set as global
		frappe.utils.help.sync()

	clear_notifications()

	frappe.publish_realtime("version-update")
コード例 #5
0
ファイル: install.py プロジェクト: JiShangShiDai/frappe
def after_install():
	# reset installed apps for re-install
	frappe.db.set_global("installed_apps", '["frappe"]')

	install_basic_docs()

	from frappe.core.doctype.file.file import make_home_folder
	make_home_folder()

	import_country_and_currency()

	from frappe.core.doctype.language.language import sync_languages
	sync_languages()

	# save default print setting
	print_settings = frappe.get_doc("Print Settings")
	print_settings.save()

	# all roles to admin
	frappe.get_doc("User", "Administrator").add_roles(*frappe.db.sql_list("""select name from tabRole"""))

	# update admin password
	update_password("Administrator", get_admin_password())

	# setup wizard now in frappe
	frappe.db.set_default('desktop:home_page', 'setup-wizard')

	frappe.db.commit()
コード例 #6
0
ファイル: migrate.py プロジェクト: frappe/frappe
def migrate(verbose=True, rebuild_website=False):
	'''Migrate all apps to the latest version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks
	'''

	touched_tables_file = frappe.get_site_path('touched_tables.json')
	if os.path.exists(touched_tables_file):
		os.remove(touched_tables_file)

	try:
		frappe.flags.touched_tables = set()
		frappe.flags.in_migrate = True
		clear_global_cache()

		#run before_migrate hooks
		for app in frappe.get_installed_apps():
			for fn in frappe.get_hooks('before_migrate', app_name=app):
				frappe.get_attr(fn)()

		# run patches
		frappe.modules.patch_handler.run_all()
		# sync
		frappe.model.sync.sync_all(verbose=verbose)
		frappe.translate.clear_cache()
		sync_fixtures()
		sync_customizations()
		sync_desktop_icons()
		sync_languages()

		frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

		# syncs statics
		render.clear_cache()

		# add static pages to global search
		router.sync_global_search()

		#run after_migrate hooks
		for app in frappe.get_installed_apps():
			for fn in frappe.get_hooks('after_migrate', app_name=app):
				frappe.get_attr(fn)()

		frappe.db.commit()

		clear_notifications()

		frappe.publish_realtime("version-update")
		frappe.flags.in_migrate = False
	finally:
		with open(touched_tables_file, 'w') as f:
			json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4)
		frappe.flags.touched_tables.clear()
コード例 #7
0
ファイル: migrate.py プロジェクト: adnanmunir83/frappe
def migrate(verbose=True, rebuild_website=False):
	'''Migrate all apps to the latest version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks
	'''
	frappe.flags.in_migrate = True
	clear_global_cache()

	#run before_migrate hooks
	for app in frappe.get_installed_apps():
		for fn in frappe.get_hooks('before_migrate', app_name=app):
			frappe.get_attr(fn)()

	# run patches
	frappe.modules.patch_handler.run_all()
	# sync
	frappe.model.sync.sync_all(verbose=verbose)
	frappe.translate.clear_cache()
	sync_fixtures()
	sync_customizations()
	sync_desktop_icons()
	sync_languages()

	frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

	# syncs statics
	render.clear_cache()

	# add static pages to global search
	router.sync_global_search()

	#run after_migrate hooks
	for app in frappe.get_installed_apps():
		for fn in frappe.get_hooks('after_migrate', app_name=app):
			frappe.get_attr(fn)()

	frappe.db.commit()

	if not frappe.conf.get('global_help_setup'):
		# sync help if not set as global
		frappe.utils.help.sync()

	clear_notifications()

	frappe.publish_realtime("version-update")
	frappe.flags.in_migrate = False
コード例 #8
0
ファイル: migrate.py プロジェクト: ESS-LLP/frappe
def migrate(verbose=True, rebuild_website=False):
	'''Migrate all apps to the latest version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks
	'''
	frappe.flags.in_migrate = True
	clear_global_cache()

	#run before_migrate hooks
	for app in frappe.get_installed_apps():
		for fn in frappe.get_hooks('before_migrate', app_name=app):
			frappe.get_attr(fn)()

	# run patches
	frappe.modules.patch_handler.run_all()
	# sync
	frappe.model.sync.sync_all(verbose=verbose)
	frappe.translate.clear_cache()
	sync_fixtures()
	sync_customizations()
	sync_desktop_icons()
	sync_languages()

	frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

	# syncs statics
	render.clear_cache()

	# add static pages to global search
	router.sync_global_search()

	#run after_migrate hooks
	for app in frappe.get_installed_apps():
		for fn in frappe.get_hooks('after_migrate', app_name=app):
			frappe.get_attr(fn)()

	frappe.db.commit()

	clear_notifications()

	frappe.publish_realtime("version-update")
	frappe.flags.in_migrate = False
コード例 #9
0
def execute():
	frappe.reload_doc('core', 'doctype', 'language')

	from frappe.core.doctype.language.language import sync_languages
	sync_languages()

	# move language from old style to new style for old accounts
	# i.e. from "english" to "en"

	lang_dict = get_lang_dict()
	language = frappe.db.get_value('System Settings', None, 'language')
	if language:
		frappe.db.set_value('System Settings', None, 'language', lang_dict.get('language') or 'en')

	for user in frappe.get_all('User', fields=['name', 'language']):
		if user.language:
			frappe.db.set_value('User', user.name, 'language',
				lang_dict.get('language') or 'en', update_modified=False)
コード例 #10
0
ファイル: migrate.py プロジェクト: JiShangShiDai/frappe
def migrate(verbose=True, rebuild_website=False):
	'''Migrate all apps to the latest version, will:

	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)'''
	frappe.flags.in_migrate = True
	clear_global_cache()

	# run patches
	frappe.modules.patch_handler.run_all()
	# sync
	frappe.model.sync.sync_all(verbose=verbose)
	frappe.translate.clear_cache()
	sync_fixtures()
	sync_customizations()
	sync_desktop_icons()
	sync_languages()

	frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

	# syncs statics
	render.clear_cache()

	# add static pages to global search
	router.sync_global_search()

	frappe.db.commit()

	if not frappe.conf.get('global_help_setup'):
		# sync help if not set as global
		frappe.utils.help.sync()

	clear_notifications()

	frappe.publish_realtime("version-update")
	frappe.flags.in_migrate = False
コード例 #11
0
ファイル: migrate.py プロジェクト: adinortey360/testfrappe
def migrate(verbose=True, skip_failing=False, skip_search_index=False):
    '''Migrate all apps to the current version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync dashboards
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks
	'''

    service_status = check_connection(redis_services=["redis_cache"])
    if False in service_status.values():
        for service in service_status:
            if not service_status.get(service, True):
                print("{} service is not running.".format(service))
        print("""Cannot run bench migrate without the services running.
If you are running bench in development mode, make sure that bench is running:

$ bench start

Otherwise, check the server logs and ensure that all the required services are running."""
              )
        sys.exit(1)

    touched_tables_file = frappe.get_site_path('touched_tables.json')
    if os.path.exists(touched_tables_file):
        os.remove(touched_tables_file)

    try:
        frappe.flags.touched_tables = set()
        frappe.flags.in_migrate = True

        clear_global_cache()

        #run before_migrate hooks
        for app in frappe.get_installed_apps():
            for fn in frappe.get_hooks('before_migrate', app_name=app):
                frappe.get_attr(fn)()

        # run patches
        frappe.modules.patch_handler.run_all(skip_failing)

        # sync
        frappe.model.sync.sync_all(verbose=verbose)
        frappe.translate.clear_cache()
        sync_jobs()
        sync_fixtures()
        sync_dashboards()
        sync_customizations()
        sync_languages()

        frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu()

        # syncs statics
        render.clear_cache()

        # updating installed applications data
        frappe.get_single('Installed Applications').update_versions()

        #run after_migrate hooks
        for app in frappe.get_installed_apps():
            for fn in frappe.get_hooks('after_migrate', app_name=app):
                frappe.get_attr(fn)()

        # build web_routes index
        if not skip_search_index:
            # Run this last as it updates the current session
            print('Building search index for {}'.format(frappe.local.site))
            build_index_for_all_routes()

        frappe.db.commit()

        clear_notifications()

        frappe.publish_realtime("version-update")
        frappe.flags.in_migrate = False
    finally:
        with open(touched_tables_file, 'w') as f:
            json.dump(list(frappe.flags.touched_tables),
                      f,
                      sort_keys=True,
                      indent=4)
        frappe.flags.touched_tables.clear()