예제 #1
0
def get_versions():
    """Get versions of all installed apps.

	Example:

		{
			"frappe": {
				"title": "Frappe Framework",
				"version": "5.0.0"
			}
		}"""
    versions = {}
    for app in frappe.get_installed_apps(sort=True):
        app_hooks = frappe.get_hooks(app_name=app)
        versions[app] = {
            "title": app_hooks.get("app_title")[0],
            "description": app_hooks.get("app_description")[0],
            "branch": get_app_branch(app)
        }

        if versions[app]['branch'] != 'master':
            branch_version = app_hooks.get('{0}_version'.format(
                versions[app]['branch']))
            if branch_version:
                versions[app][
                    'branch_version'] = branch_version[0] + ' ({0})'.format(
                        get_app_last_commit_ref(app))

        try:
            versions[app]["version"] = frappe.get_attr(app + ".__version__")
        except AttributeError:
            versions[app]["version"] = '0.0.1'

    return versions
예제 #2
0
def get_versions():
	"""Get versions of all installed apps.

	Example:

		{
			"frappe": {
				"title": "Frappe Framework",
				"version": "5.0.0"
			}
		}"""
	versions = {}
	for app in frappe.get_installed_apps(sort=True):
		app_hooks = frappe.get_hooks(app_name=app)
		versions[app] = {
			"title": app_hooks.get("app_title")[0],
			"description": app_hooks.get("app_description")[0],
			"branch": get_app_branch(app)
		}

		if versions[app]['branch'] != 'master':
			branch_version = app_hooks.get('{0}_version'.format(versions[app]['branch']))
			if branch_version:
				versions[app]['branch_version'] = branch_version[0] + ' ({0})'.format(get_app_last_commit_ref(app))

		try:
			versions[app]["version"] = frappe.get_attr(app + ".__version__")
		except AttributeError:
			versions[app]["version"] = '0.0.1'

	return versions
예제 #3
0
def get_version():
    from frappe.utils.gitutils import get_app_branch
    branch_name = get_app_branch("erpnext")
    if "12" in branch_name:
        return 12
    elif "13" in branch_name:
        return 13
    else:
        return 13
예제 #4
0
def auto_deploy(context, app, migrate=False, restart=False, remote='upstream'):
    '''Pull and migrate sites that have new version'''
    from frappe.utils.gitutils import get_app_branch
    from frappe.utils import get_sites

    branch = get_app_branch(app)
    app_path = frappe.get_app_path(app)

    # fetch
    subprocess.check_output(['git', 'fetch', remote, branch], cwd=app_path)

    # get diff
    if subprocess.check_output(
        ['git', 'diff', '{0}..upstream/{0}'.format(branch)], cwd=app_path):
        print('Updates found for {0}'.format(app))
        if app == 'frappe':
            # run bench update
            subprocess.check_output(['bench', 'update', '--no-backup'],
                                    cwd='..')
        else:
            updated = False
            subprocess.check_output(
                ['git', 'pull', '--rebase', 'upstream', branch], cwd=app_path)
            # find all sites with that app
            for site in get_sites():
                frappe.init(site)
                if app in frappe.get_installed_apps():
                    print('Updating {0}'.format(site))
                    updated = True
                    subprocess.check_output(
                        ['bench', '--site', site, 'clear-cache'], cwd='..')
                    if migrate:
                        subprocess.check_output(
                            ['bench', '--site', site, 'migrate'], cwd='..')
                frappe.destroy()

            if updated and restart:
                subprocess.check_output(['bench', 'restart'], cwd='..')
    else:
        print('No Updates')