| 2662 | "\tThe expression may be a complete multi-line script;\n" |
| 2663 | "\tyou are limited only by the platform's maximum argument length."; |
| 2664 | static int arg_handle_python_expr_run(int argc, const char **argv, void *data) |
| 2665 | { |
| 2666 | bContext *C = static_cast<bContext *>(data); |
| 2667 | |
| 2668 | /* Workaround for scripts not getting a `bpy.context.scene`, causes internal errors elsewhere. */ |
| 2669 | if (argc > 1) { |
| 2670 | # ifdef WITH_PYTHON |
| 2671 | bool ok; |
| 2672 | BPY_CTX_SETUP(ok = BPY_run_string_exec(C, nullptr, argv[1])); |
| 2673 | if (!ok && app_state.exit_code_on_error.python) { |
| 2674 | fprintf(stderr, "\nError: script failed, expr: '%s', exiting.\n", argv[1]); |
| 2675 | WM_exit(C, app_state.exit_code_on_error.python); |
| 2676 | } |
| 2677 | # else |
| 2678 | UNUSED_VARS(C); |
| 2679 | fprintf(stderr, "This Blender was built without Python support\n"); |
| 2680 | # endif /* WITH_PYTHON */ |
| 2681 | |
| 2682 | return 1; |
| 2683 | } |
| 2684 | fprintf(stderr, "\nError: you must specify a Python expression after '%s'.\n", argv[0]); |
| 2685 | return 0; |
| 2686 | } |
| 2687 | |
| 2688 | static const char arg_handle_python_console_run_doc[] = |
| 2689 | "\n\t" |
nothing calls this directly
no test coverage detected