|
31 | 31 | # get latest version from there |
32 | 32 | if not config.BLENDER_PATH and config.BLENDERS_PATH: |
33 | 33 | logger.error("BLENDER_PATH not set, checking BLENDERS_PATH, result may be tainted.") |
34 | | - latest_version = utils.get_latest_blender_path(config.BLENDERS_PATH) |
| 34 | + latest_version = utils.get_latest_blender_binary_path(config.BLENDERS_PATH) |
35 | 35 | if latest_version: |
36 | 36 | config.BLENDER_PATH = latest_version |
37 | 37 |
|
38 | 38 | if not config.BLENDER_PATH: |
39 | 39 | logger.error("At least one of BLENDER_PATH & BLENDERS_PATH must be set.") |
40 | 40 | sys.exit(1) |
41 | 41 |
|
| 42 | +# Constants |
| 43 | +AVAILABLE_TARGET_FORMATS = ["gltf", "gltf_godot"] |
| 44 | +DEFAULT_TARGET_FORMAT: str = "gltf_godot" |
42 | 45 |
|
| 46 | +# argparse for target format |
43 | 47 | args = argparse.ArgumentParser() |
44 | | -args.add_argument("--target_format", type=str, default="gltf_godot", help="Target export format") |
| 48 | +args.add_argument( |
| 49 | + "--target_format", |
| 50 | + type=str, |
| 51 | + choices=AVAILABLE_TARGET_FORMATS, |
| 52 | + default=DEFAULT_TARGET_FORMAT, |
| 53 | + help="Target export format", |
| 54 | +) |
45 | 55 |
|
46 | 56 |
|
47 | | -# Constants |
| 57 | +# Determine target format from args, env var, or default |
48 | 58 | TARGET_FORMAT = args.parse_args().target_format |
49 | 59 | if TARGET_FORMAT: |
50 | 60 | logger.info("Using target format from args: %s", TARGET_FORMAT) |
51 | 61 | if not TARGET_FORMAT: |
52 | 62 | # use env var or default |
53 | 63 | TARGET_FORMAT = os.getenv("TARGET_FORMAT", None) |
54 | | - if not TARGET_FORMAT: |
55 | | - logger.info("No target format specified, defaulting to 'gltf_godot'") |
56 | 64 |
|
57 | 65 | if not TARGET_FORMAT: |
58 | | - logger.error("No target format specified, defaulting to 'gltf_godot'") |
59 | | - TARGET_FORMAT = "gltf_godot" |
| 66 | + logger.error("No target format specified, defaulting to %s", DEFAULT_TARGET_FORMAT) |
| 67 | + TARGET_FORMAT = DEFAULT_TARGET_FORMAT |
60 | 68 |
|
61 | 69 | # target mode can be only one of these 2 now |
62 | | -if TARGET_FORMAT not in ["gltf", "gltf_godot"]: |
| 70 | +if TARGET_FORMAT not in AVAILABLE_TARGET_FORMATS: |
63 | 71 | logger.error("Invalid target format specified: %s", TARGET_FORMAT) |
64 | 72 | sys.exit(1) |
65 | 73 |
|
@@ -87,7 +95,7 @@ def generate_gltf(asset_data: dict[str, Any], api_key: str, binary_path: str, ta |
87 | 95 | asset_data: Asset metadata returned from the search API. |
88 | 96 | api_key: API key used for authenticated operations. |
89 | 97 | binary_path: Absolute path to the Blender binary used for background operations. |
90 | | - target_format: The target export format, e.g., 'gltf_godot'. |
| 98 | + target_format: The target export format, e.g., '{DEFAULT_TARGET_FORMAT=gltf_godot}'. |
91 | 99 |
|
92 | 100 | Returns: |
93 | 101 | True when the GLTF was generated and uploaded successfully; False otherwise. |
@@ -144,9 +152,10 @@ def generate_gltf(asset_data: dict[str, Any], api_key: str, binary_path: str, ta |
144 | 152 |
|
145 | 153 | if SKIP_UPDATE: |
146 | 154 | logger.info("SKIP_UPDATE is set, not patching the asset.") |
147 | | - opened = utils.open_folder(os.path.dirname(files[0]["path"])) |
| 155 | + logger.debug("Generated files: %s", files) |
| 156 | + opened = utils.open_folder(os.path.dirname(files[0]["file_path"])) |
148 | 157 | if not opened: |
149 | | - logger.error("Failed to open folder %s", os.path.dirname(files[0]["path"])) |
| 158 | + logger.error("Failed to open folder %s", os.path.dirname(files[0]["file_path"])) |
150 | 159 | utils.cleanup_temp(temp_folder) |
151 | 160 |
|
152 | 161 | return False |
|
0 commit comments