jkorstad commited on
Commit
c1ff415
·
verified ·
1 Parent(s): 4421948

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -195,6 +195,31 @@ def run_unirig_command(python_script_path: str, script_args: List[str], step_nam
195
  process_env["LD_LIBRARY_PATH"] = f"{blender_lib_path}{os.pathsep}{existing_ld_path}" if existing_ld_path else blender_lib_path
196
  print(f"Subprocess LD_LIBRARY_PATH: {process_env['LD_LIBRARY_PATH']}")
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
 
199
  try:
200
  # Execute Blender with the Python script.
@@ -234,7 +259,6 @@ def run_unirig_command(python_script_path: str, script_args: List[str], step_nam
234
  else:
235
  raise gr.Error(f"Error in UniRig '{step_name}'. Check logs. Last error lines:\n{last_lines}")
236
 
237
-
238
  except FileNotFoundError:
239
  # This error means blender executable or the python script wasn't found
240
  print(f"ERROR: Could not find Blender executable '{blender_executable_to_use}' or script '{python_script_path}' for {step_name}.")
 
195
  process_env["LD_LIBRARY_PATH"] = f"{blender_lib_path}{os.pathsep}{existing_ld_path}" if existing_ld_path else blender_lib_path
196
  print(f"Subprocess LD_LIBRARY_PATH: {process_env['LD_LIBRARY_PATH']}")
197
 
198
+ # Test import of 'src' module
199
+ test_cmd = [
200
+ blender_executable_to_use,
201
+ "--background",
202
+ "--python", "-c", "import src; print('src module imported successfully')"
203
+ ]
204
+ test_result = subprocess.run(
205
+ test_cmd,
206
+ cwd=UNIRIG_REPO_DIR,
207
+ capture_output=True,
208
+ text=True,
209
+ env=process_env
210
+ )
211
+ if test_result.returncode != 0:
212
+ print(f"Test import of 'src' failed with return code {test_result.returncode}")
213
+ print(f"Test STDOUT: {test_result.stdout}")
214
+ print(f"Test STDERR: {test_result.stderr}")
215
+ raise gr.Error("Failed to import 'src' module in Blender environment. Check PYTHONPATH and module structure.")
216
+ elif "src module imported successfully" not in test_result.stdout:
217
+ print(f"Test import of 'src' did not produce expected output.")
218
+ print(f"Test STDOUT: {test_result.stdout}")
219
+ print(f"Test STDERR: {test_result.stderr}")
220
+ raise gr.Error("Unexpected output from 'src' import test. Check script behavior.")
221
+ else:
222
+ print("Test import of 'src' succeeded.")
223
 
224
  try:
225
  # Execute Blender with the Python script.
 
259
  else:
260
  raise gr.Error(f"Error in UniRig '{step_name}'. Check logs. Last error lines:\n{last_lines}")
261
 
 
262
  except FileNotFoundError:
263
  # This error means blender executable or the python script wasn't found
264
  print(f"ERROR: Could not find Blender executable '{blender_executable_to_use}' or script '{python_script_path}' for {step_name}.")