def bench_command(bench_path='.'): """Bench manager for Frappe""" import bench from bench.utils import setup_logging bench.set_frappe_version(bench_path=bench_path) setup_logging(bench_path=bench_path)
def bench_command(bench_path='.'): """Bench manager for Dataent""" import bench from bench.utils import setup_logging bench.set_dataent_version(bench_path=bench_path) setup_logging(bench_path=bench_path)
def bench_command(bench='.'): "Bench manager for Frappe" from bench.app import get_current_frappe_version from bench.utils import setup_logging # TODO add bench path context global FRAPPE_VERSION FRAPPE_VERSION = get_current_frappe_version() setup_logging(bench=bench)
def cli(): global from_command_line from_command_line = True command = " ".join(sys.argv) change_working_directory() logger = setup_logging() logger.info(command) if len(sys.argv) > 1 and sys.argv[1] not in ("src", ): check_uid() change_uid() change_dir() if is_dist_editable(bench.PROJECT_NAME) and len( sys.argv) > 1 and sys.argv[1] != "src" and not get_config(".").get( "developer_mode"): log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3) if not is_bench_directory() and not cmd_requires_root() and len( sys.argv) > 1 and sys.argv[1] not in ("init", "find", "src"): log("Command not being executed in bench directory", level=3) if len(sys.argv) > 2 and sys.argv[1] == "frappe": return old_frappe_cli() elif len(sys.argv) > 1: if sys.argv[1] in get_frappe_commands() + [ "--site", "--verbose", "--force", "--profile" ]: return frappe_cmd() elif sys.argv[1] == "--help": print(click.Context(bench_command).get_help()) print(get_frappe_help()) return elif sys.argv[1] in get_apps(): return app_cmd() if not (len(sys.argv) > 1 and sys.argv[1] == "src"): atexit.register(check_latest_version) try: bench_command() except BaseException as e: return_code = getattr(e, "code", 0) if return_code: logger.warning("{0} executed with exit code {1}".format( command, return_code)) sys.exit(return_code)