Ejemplo n.º 1
0
def cli():
	global from_command_line
	from_command_line = True

	check_uid()
	change_dir()
	change_uid()

	if len(sys.argv) > 2 and sys.argv[1] == "frappe":
		return old_frappe_cli()

	elif len(sys.argv) > 1 and sys.argv[1] in get_frappe_commands():
		return frappe_cmd()

	elif len(sys.argv) > 1 and sys.argv[1] in ("--site", "--verbose", "--force", "--profile"):
		return frappe_cmd()

	elif len(sys.argv) > 1 and sys.argv[1]=="--help":
		print click.Context(bench_command).get_help()
		print
		print get_frappe_help()
		return

	elif len(sys.argv) > 1 and sys.argv[1] in get_apps():
		return app_cmd()

	else:
		try:
			# NOTE: this is the main bench command
			bench_command()
		except PatchError:
			sys.exit(1)
Ejemplo n.º 2
0
def cli():
	global from_command_line
	from_command_line = True

	check_uid()
	change_dir()
	change_uid()

	if len(sys.argv) > 2 and sys.argv[1] == "frappe":
		return old_frappe_cli()

	elif len(sys.argv) > 1 and sys.argv[1] in get_frappe_commands():
		return frappe_cmd()

	elif len(sys.argv) > 1 and sys.argv[1] in ("--site", "--verbose", "--force", "--profile"):
		return frappe_cmd()

	elif len(sys.argv) > 1 and sys.argv[1]=="--help":
		print(click.Context(bench_command).get_help())
		print()
		print(get_frappe_help())
		return

	elif len(sys.argv) > 1 and sys.argv[1] in get_apps():
		return app_cmd()

	else:
		try:
			# NOTE: this is the main bench command
			bench_command()
		except PatchError:
			sys.exit(1)
Ejemplo n.º 3
0
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)