def get_version(): "Show the versions of all the installed apps" from frappe.utils.change_log import get_app_branch frappe.init('') for m in sorted(frappe.get_all_apps()): branch_name = get_app_branch(m) module = frappe.get_module(m) app_hooks = frappe.get_module(m + ".hooks") if hasattr(app_hooks, '{0}_version'.format(branch_name)): print("{0} {1}".format(m, getattr(app_hooks, '{0}_version'.format(branch_name)))) elif hasattr(module, "__version__"): print("{0} {1}".format(m, module.__version__))
def get_version(): "Show the versions of all the installed apps" from frappe.utils.change_log import get_app_branch frappe.init('') for m in sorted(frappe.get_all_apps()): branch_name = get_app_branch(m) module = frappe.get_module(m) app_hooks = frappe.get_module(m + ".hooks") if hasattr(app_hooks, '{0}_version'.format(branch_name)): print("{0} {1}".format(m, getattr(app_hooks, '{0}_version'.format(branch_name)))) elif hasattr(module, "__version__"): print("{0} {1}".format(m, module.__version__))
def get_version(output): """Show the versions of all the installed apps.""" from git import Repo from frappe.utils.commands import render_table from frappe.utils.change_log import get_app_branch frappe.init("") data = [] for app in sorted(frappe.get_all_apps()): module = frappe.get_module(app) app_hooks = frappe.get_module(app + ".hooks") repo = Repo(frappe.get_app_path(app, "..")) app_info = frappe._dict() app_info.app = app app_info.branch = get_app_branch(app) app_info.commit = repo.head.object.hexsha[:7] app_info.version = getattr(app_hooks, f"{app_info.branch}_version", None) or module.__version__ data.append(app_info) { "legacy": lambda: [ click.echo(f"{app_info.app} {app_info.version}") for app_info in data ], "plain": lambda: [ click.echo( f"{app_info.app} {app_info.version} {app_info.branch} ({app_info.commit})" ) for app_info in data ], "table": lambda: render_table([["App", "Version", "Branch", "Commit"]] + [[ app_info.app, app_info.version, app_info.branch, app_info.commit ] for app_info in data]), "json": lambda: click.echo(json.dumps(data, indent=4)), }[output]()
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}..{1}/{0}'.format(branch, remote)], cwd=app_path): print('Updates found for {0}'.format(app)) if app == 'frappe': # run bench update import shlex subprocess.check_output(shlex.split('bench update --no-backup'), cwd='..') else: updated = False subprocess.check_output( ['git', 'pull', '--rebase', remote, 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 or restart: subprocess.check_output(['bench', 'restart'], cwd='..') else: print('No Updates')
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')