def get_frappe_help(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') try: out = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-help".format(python=python), cwd=sites_path) return "\n\nFramework commands:\n" + out.split('Commands:')[1] except: return ""
def get_frappe_commands(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') if not os.path.exists(sites_path): return [] try: return json.loads(get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path)) except subprocess.CalledProcessError: return []
def get_frappe_commands(bench='.'): python = get_env_cmd('python', bench=bench) sites_path = os.path.join(bench, 'sites') if not os.path.exists(sites_path): return [] try: return json.loads(get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path)) except subprocess.CalledProcessError: return []
def get_frappe_help(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') if not os.path.exists(sites_path): return [] try: out = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-help".format(python=python), cwd=sites_path) return "Framework commands:\n" + out.split('Commands:')[1] except subprocess.CalledProcessError: return ""
def get_frappe_help(bench='.'): python = get_env_cmd('python', bench=bench) sites_path = os.path.join(bench, 'sites') if not os.path.exists(sites_path): return [] try: out = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-help".format(python=python), cwd=sites_path) return "Framework commands:\n" + out.split('Commands:')[1] except subprocess.CalledProcessError: return ""
def get_frappe_commands(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') if not os.path.exists(sites_path): log("Command not being executed in bench directory", level=3) return [] try: output = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path) return json.loads(output) except subprocess.CalledProcessError as e: if hasattr(e, "stderr"): print(e.stderr.decode('utf-8')) return []
def get_frappe_commands(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') if not os.path.exists(sites_path): return [] try: output = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path) # output = output.decode('utf-8') return json.loads(output) except subprocess.CalledProcessError as e: if hasattr(e, "stderr"): print(e.stderr.decode('utf-8')) return []
def get_dataent_commands(bench_path='.'): python = get_env_cmd('python', bench_path=bench_path) sites_path = os.path.join(bench_path, 'sites') if not os.path.exists(sites_path): return [] try: output = get_cmd_output( "{python} -m dataent.utils.bench_helper get-dataent-commands". format(python=python), cwd=sites_path) # output = output.decode('utf-8') return json.loads(output) except subprocess.CalledProcessError as e: if hasattr(e, "stderr"): print(e.stderr.decode('utf-8')) return []
def is_sudoers_set(): """Check if bench sudoers is set""" cmd = ["sudo", "-n", "bench"] with open(os.devnull, "wb") as f: return_code_check = not subprocess.call(cmd, stdout=f) if return_code_check: try: bench_warn = change_uid_msg in get_cmd_output(cmd, _raise=False) except subprocess.CalledProcessError: bench_warn = False finally: return_code_check = return_code_check and bench_warn return return_code_check
def is_centos7(): return os.path.exists('/etc/redhat-release') and get_cmd_output("cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d' ' -f3 | cut -d. -f1").strip() == '7'
def get_current_branch(app, bench_path='.'): repo_dir = get_repo_dir(app, bench_path=bench_path) return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir)
def is_centos7(): return os.path.exists('/etc/redhat-release') and get_cmd_output( "cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d' ' -f3 | cut -d. -f1" ).strip() == '7'