Convert Blender-Purge
to a more generic Blender-Crawl
Tool
#42
@ -93,6 +93,7 @@ def find_default_blender():
|
|||||||
default_blender_str = f'/{str(output).split(" /")[1]}'
|
default_blender_str = f'/{str(output).split(" /")[1]}'
|
||||||
default_blender_binary = Path(default_blender_str)
|
default_blender_binary = Path(default_blender_str)
|
||||||
if default_blender_binary.exists():
|
if default_blender_binary.exists():
|
||||||
|
print("Blender Executable location Automatically Detected!")
|
||||||
return default_blender_binary
|
return default_blender_binary
|
||||||
|
|
||||||
def get_blender_path() -> Path:
|
def get_blender_path() -> Path:
|
||||||
@ -200,15 +201,20 @@ def input_filepath(question: str) -> Path:
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def setup_config(find_blender_exec) -> None:
|
def setup_config(skip_finding_exec) -> None:
|
||||||
|
|||||||
|
user_exec = True
|
||||||
|
|
||||||
|
if not skip_finding_exec:
|
||||||
|
if find_default_blender() is not None:
|
||||||
|
user_exec = False
|
||||||
|
blender_path = find_default_blender()
|
||||||
|
|
||||||
|
|
||||||
|
if user_exec:
|
||||||
|
blender_path = input_filepath("# Path to Blender binary: ")
|
||||||
|
|
||||||
config_path = get_config_path()
|
config_path = get_config_path()
|
||||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
default_blender_path = find_default_blender()
|
|
||||||
if (not(find_blender_exec) and default_blender_path):
|
|
||||||
blender_path = default_blender_path
|
|
||||||
else:
|
|
||||||
blender_path = input_filepath("# Path to Blender binary: ")
|
|
||||||
|
|
||||||
obj = {
|
obj = {
|
||||||
"blender_path": blender_path.as_posix(),
|
"blender_path": blender_path.as_posix(),
|
||||||
}
|
}
|
||||||
@ -241,21 +247,21 @@ def run_blender_crawl(args: argparse.Namespace) -> int:
|
|||||||
path = Path(args.path).absolute()
|
path = Path(args.path).absolute()
|
||||||
script = get_default_scipt(args.script)
|
script = get_default_scipt(args.script)
|
||||||
recursive = args.recursive
|
recursive = args.recursive
|
||||||
find_blender_exec = args.exec
|
skip_finding_exec = args.exec
|
||||||
config_path = get_config_path()
|
config_path = get_config_path()
|
||||||
regex = args.regex
|
regex = args.regex
|
||||||
yes = args.yes
|
yes = args.yes
|
||||||
|
|
||||||
# Check config file.
|
# Check config file.
|
||||||
if not config_path.exists() or find_blender_exec:
|
if not config_path.exists() or skip_finding_exec:
|
||||||
print("# Seems like you are starting blender-crawl for the first time!")
|
print("# Seems like you are starting blender-crawl for the first time!")
|
||||||
Sebastian Parborg
commented
While there is a option to skip looking for the blender binary, this is very bad design for a command line tool. Why? Because this makes it very tedious to script this or run it on multiple computers. This means that if someone has set this up to run in a bigger script, the script will halt and never finish or give any errors indicating that it didn't execute. While there is a option to skip looking for the blender binary, this is very bad design for a command line tool.
Why? Because this makes it very tedious to script this or run it on multiple computers.
And most importantly, it will stop execution and ask for user input.
For batch scripts this makes it very unreliable because not only does it not do what you wanted to (crawl for blender files), it also stops execution until it has gotten input.
This means that if someone has set this up to run in a bigger script, the script will halt and never finish or give any errors indicating that it didn't execute.
Nick Alberelli
commented
We handled this problem in these commits We handled this problem in these commits https://projects.blender.org/studio/blender-studio-pipeline/commit/9e9c60fda3035acebb0991bad4c24b9643b29b36 https://projects.blender.org/studio/blender-studio-pipeline/commit/76aad472521d902b831c6e35165c452aa3010355
|
|||||||
print("# Some things needs to be configured")
|
print("# Some things needs to be configured")
|
||||||
setup_config(find_blender_exec)
|
setup_config(skip_finding_exec)
|
||||||
else:
|
else:
|
||||||
if not is_config_valid():
|
if not is_config_valid():
|
||||||
print("# Config file at: %s is not valid", config_path.as_posix())
|
print("# Config file at: %s is not valid", config_path.as_posix())
|
||||||
print("# Please set it up again")
|
print("# Please set it up again")
|
||||||
setup_config(find_blender_exec)
|
setup_config(skip_finding_exec)
|
||||||
|
|
||||||
# Check user input.
|
# Check user input.
|
||||||
if not path:
|
if not path:
|
||||||
|
Loading…
Reference in New Issue
Block a user
I don't think this program should have any config file at all.
Unless the command line tool is very complex (which this one is not), then the user should always have a fresh start each time the command line tool is run.
I'll elaborate further in an other comment.
We handled this together
9e9c60fda3
issue resolved!