コード例 #1
0
def update(pull=False,
           patch=False,
           build=False,
           bench=False,
           auto=False,
           restart_supervisor=False,
           requirements=False,
           no_backup=False,
           upgrade=False,
           force=False):
    "Update bench"

    if not (pull or patch or build or bench or requirements):
        pull, patch, build, bench, requirements = True, True, True, True, True

    if auto:
        sys.exit(1)

    patches.run(bench_path='.')
    conf = get_config(".")

    if bench and conf.get('update_bench_on_update'):
        update_bench()
        restart_update({
            'pull': pull,
            'patch': patch,
            'build': build,
            'requirements': requirements,
            'no-backup': no_backup,
            'restart-supervisor': restart_supervisor,
            'upgrade': upgrade
        })

    if conf.get('release_bench'):
        print 'Release bench, cannot update'
        sys.exit(1)

    version_upgrade = is_version_upgrade()

    if version_upgrade[0] and not upgrade:
        print
        print
        print "This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(
            *version_upgrade[1:])
        print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
        print
        print "You can stay on the latest stable release by running `bench switch-to-master` or pin your bench to {0} by running `bench switch-to-v{0}`".format(
            version_upgrade[1])
        sys.exit(1)

    _update(pull,
            patch,
            build,
            bench,
            auto,
            restart_supervisor,
            requirements,
            no_backup,
            upgrade,
            force=force)
コード例 #2
0
def update(pull=False,
           patch=False,
           build=False,
           bench=False,
           auto=False,
           restart_supervisor=False,
           requirements=False,
           no_backup=False,
           force=False,
           reset=False):
    "Update bench"

    if not (pull or patch or build or bench or requirements):
        pull, patch, build, bench, requirements = True, True, True, True, True

    if auto:
        sys.exit(1)

    patches.run(bench_path='.')
    conf = get_config(".")

    if bench and conf.get('update_bench_on_update'):
        update_bench()
        restart_update({
            'pull': pull,
            'patch': patch,
            'build': build,
            'requirements': requirements,
            'no-backup': no_backup,
            'restart-supervisor': restart_supervisor,
            'reset': reset
        })

    if conf.get('release_bench'):
        print('Release bench, cannot update')
        sys.exit(1)

    version_upgrade = is_version_upgrade()

    if version_upgrade[0]:
        print()
        print()
        print(
            "This update will cause a major version change in Frappe/ERPNext from {0} to {1}."
            .format(*version_upgrade[1:]))
        print(
            "This would take significant time to migrate and might break custom apps."
        )
        click.confirm('Do you want to continue?', abort=True)

    _update(pull,
            patch,
            build,
            bench,
            auto,
            restart_supervisor,
            requirements,
            no_backup,
            force=force,
            reset=reset)
コード例 #3
0
ファイル: update.py プロジェクト: Dattatech/Test-Bench
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, requirements=False, no_backup=False, upgrade=False, force=False):
	"Update bench"

	if not (pull or patch or build or bench or requirements):
		pull, patch, build, bench, requirements = True, True, True, True, True

	patches.run(bench_path='.')

	conf = get_config(".")

	version_upgrade = is_version_upgrade()

	if version_upgrade[0] and not upgrade:
		print
		print
		print "This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(*version_upgrade[1:])
		print "This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm."
		print
		print "You can stay on the latest stable release by running `bench switch-to-master` or pin your bench to {0} by running `bench switch-to-v{0}`".format(version_upgrade[1])
		sys.exit(1)

	if conf.get('release_bench'):
		print 'Release bench, cannot update'
		sys.exit(1)

	if auto:
		sys.exit(1)

	if bench and conf.get('update_bench_on_update'):
		update_bench()
		restart_update({
				'pull': pull,
				'patch': patch,
				'build': build,
				'requirements': requirements,
				'no-backup': no_backup,
				'restart-supervisor': restart_supervisor,
				'upgrade': upgrade
		})

	_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
コード例 #4
0
ファイル: update.py プロジェクト: Nayar/bench
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, restart_systemd=False, requirements=False, no_backup=False, force=False, reset=False):
	"Update bench"

	if not (pull or patch or build or bench or requirements):
		pull, patch, build, bench, requirements = True, True, True, True, True

	if auto:
		sys.exit(1)

	patches.run(bench_path='.')
	conf = get_config(".")

	if bench and conf.get('update_bench_on_update'):
		update_bench()
		restart_update({
				'pull': pull,
				'patch': patch,
				'build': build,
				'requirements': requirements,
				'no-backup': no_backup,
				'restart-supervisor': restart_supervisor,
				'reset': reset
		})

	if conf.get('release_bench'):
		print('Release bench, cannot update')
		sys.exit(1)

	version_upgrade = is_version_upgrade()

	if version_upgrade[0]:
		print()
		print()
		print("This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(*version_upgrade[1:]))
		print("This would take significant time to migrate and might break custom apps.")
		click.confirm('Do you want to continue?', abort=True)

	_update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
コード例 #5
0
ファイル: utils.py プロジェクト: ccfiel/bench
def update(pull=False,
           patch=False,
           build=False,
           bench=False,
           restart_supervisor=False,
           restart_systemd=False,
           requirements=False,
           backup=True,
           force=False,
           reset=False):
    """command: bench update"""

    if not is_bench_directory():
        """Update only bench CLI if bench update called from outside a bench"""
        update_bench(bench_repo=True, requirements=True)
        sys.exit(0)

    from bench import patches
    from bench.app import is_version_upgrade, pull_all_apps, validate_branch
    from bench.config.common_site_config import get_config, update_config

    bench_path = os.path.abspath(".")
    patches.run(bench_path=bench_path)
    conf = get_config(bench_path)

    if conf.get('release_bench'):
        print('Release bench detected, cannot update!')
        sys.exit(1)

    if not (pull or patch or build or bench or requirements):
        pull, patch, build, bench, requirements = True, True, True, True, True

    if bench and conf.get('update_bench_on_update'):
        update_bench(bench_repo=True, requirements=False)
        restart_update({
            'pull': pull,
            'patch': patch,
            'build': build,
            'requirements': requirements,
            'no-backup': backup,
            'restart-supervisor': restart_supervisor,
            'reset': reset
        })

    validate_branch()
    version_upgrade = is_version_upgrade()

    if version_upgrade[0]:
        if force:
            print(
                "Force flag has been used for a major version change in Frappe and it's apps. \nThis will take significant time to migrate and might break custom apps."
            )
        else:
            print(
                "This update will cause a major version change in Frappe/ERPNext from {0} to {1}. \nThis would take significant time to migrate and might break custom apps."
                .format(*version_upgrade[1:]))
            click.confirm('Do you want to continue?', abort=True)

    if version_upgrade[0] or (not version_upgrade[0] and force):
        validate_upgrade(version_upgrade[1],
                         version_upgrade[2],
                         bench_path=bench_path)

    before_update(bench_path=bench_path, requirements=requirements)

    conf.update({"maintenance_mode": 1, "pause_scheduler": 1})
    update_config(conf, bench_path=bench_path)

    if backup:
        print('Backing up sites...')
        backup_all_sites(bench_path=bench_path)

    if pull:
        pull_all_apps(bench_path=bench_path, reset=reset)

    if requirements:
        update_requirements(bench_path=bench_path)
        update_node_packages(bench_path=bench_path)

    if patch:
        print('Patching sites...')
        patch_sites(bench_path=bench_path)

    if build:
        build_assets(bench_path=bench_path)

    if version_upgrade[0] or (not version_upgrade[0] and force):
        post_upgrade(version_upgrade[1],
                     version_upgrade[2],
                     bench_path=bench_path)

    if restart_supervisor or conf.get('restart_supervisor_on_update'):
        restart_supervisor_processes(bench_path=bench_path)

    if restart_systemd or conf.get('restart_systemd_on_update'):
        restart_systemd_processes(bench_path=bench_path)

    conf.update({"maintenance_mode": 0, "pause_scheduler": 0})
    update_config(conf, bench_path=bench_path)

    print(
        "_" * 80 +
        "\nBench: Deployment tool for Frappe and Frappe Applications (https://frappe.io/bench).\nOpen source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the community"
    )
コード例 #6
0
def update(pull=False,
           apps=None,
           patch=False,
           build=False,
           requirements=False,
           backup=True,
           force=False,
           reset=False,
           restart_supervisor=False,
           restart_systemd=False):
    """command: bench update"""
    from bench import patches
    from bench.app import is_version_upgrade, pull_apps, validate_branch
    from bench.config.common_site_config import get_config, update_config

    bench_path = os.path.abspath(".")
    patches.run(bench_path=bench_path)
    conf = get_config(bench_path)

    if apps and not pull:
        apps = []

    clear_command_cache(bench_path='.')

    if conf.get('release_bench'):
        print('Release bench detected, cannot update!')
        sys.exit(1)

    if not (pull or patch or build or requirements):
        pull, patch, build, requirements = True, True, True, True

    validate_branch()
    version_upgrade = is_version_upgrade()

    if version_upgrade[0]:
        if force:
            print(
                "Force flag has been used for a major version change in Frappe and it's apps. \nThis will take significant time to migrate and might break custom apps."
            )
        else:
            print(
                "This update will cause a major version change in Frappe/ERPNext from {0} to {1}. \nThis would take significant time to migrate and might break custom apps."
                .format(*version_upgrade[1:]))
            click.confirm('Do you want to continue?', abort=True)

    if version_upgrade[0] or (not version_upgrade[0] and force):
        validate_upgrade(version_upgrade[1],
                         version_upgrade[2],
                         bench_path=bench_path)

    conf.update({"maintenance_mode": 1, "pause_scheduler": 1})
    update_config(conf, bench_path=bench_path)

    if backup:
        print('Backing up sites...')
        backup_all_sites(bench_path=bench_path)

    if apps:
        apps = [app.strip() for app in re.split(",| ", apps) if app]

    if pull:
        pull_apps(apps=apps, bench_path=bench_path, reset=reset)

    if requirements:
        update_requirements(bench_path=bench_path)
        update_node_packages(bench_path=bench_path)

    if patch:
        print('Patching sites...')
        patch_sites(bench_path=bench_path)

    if build:
        build_assets(bench_path=bench_path)

    if version_upgrade[0] or (not version_upgrade[0] and force):
        post_upgrade(version_upgrade[1],
                     version_upgrade[2],
                     bench_path=bench_path)

    if restart_supervisor or conf.get('restart_supervisor_on_update'):
        restart_supervisor_processes(bench_path=bench_path)

    if restart_systemd or conf.get('restart_systemd_on_update'):
        restart_systemd_processes(bench_path=bench_path)

    conf.update({"maintenance_mode": 0, "pause_scheduler": 0})
    update_config(conf, bench_path=bench_path)

    print(
        "_" * 80 +
        "\nBench: Deployment tool for Frappe and Frappe Applications (https://frappe.io/bench).\nOpen source depends on your contributions, so do give back by submitting bug reports, patches and fixes and be a part of the community :)"
    )