------------------------------------------------------------------------------
| 697 | |
| 698 | //------------------------------------------------------------------------------ |
| 699 | int vtkPythonInterpreter::PyMain(int argc, char** argv) |
| 700 | { |
| 701 | vtksys::SystemTools::EnableMSVCDebugHook(); |
| 702 | |
| 703 | int count_v = 0; |
| 704 | for (int cc = 0; cc < argc; ++cc) |
| 705 | { |
| 706 | if (argv[cc] && strcmp(argv[cc], "-v") == 0) |
| 707 | { |
| 708 | ++count_v; |
| 709 | } |
| 710 | if (argv[cc] && strcmp(argv[cc], "-vv") == 0) |
| 711 | { |
| 712 | count_v += 2; |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | if (count_v > 0) |
| 717 | { |
| 718 | // change the vtkPythonInterpreter's log verbosity. We only touch it |
| 719 | // if the command line arguments explicitly requested a certain verbosity. |
| 720 | vtkPythonInterpreter::SetLogVerbosity(vtkLogger::VERBOSITY_INFO); |
| 721 | vtkLogger::SetStderrVerbosity(vtkLogger::ConvertToVerbosity(count_v - 1)); |
| 722 | } |
| 723 | |
| 724 | vtkLogger::Init(argc, argv, nullptr); // since `-v` and `-vv` are parsed as Python verbosity flags |
| 725 | // and not log verbosity flags. |
| 726 | |
| 727 | // Need two copies of args, because the first array may be modified elsewhere. |
| 728 | using OwnedCString = std::unique_ptr<char, decltype(&std::free)>; |
| 729 | std::vector<char*> argvForPython; |
| 730 | std::vector<OwnedCString> argvCleanup; |
| 731 | for (int i = 0; i < argc; i++) |
| 732 | { |
| 733 | if (!argv[i]) |
| 734 | { |
| 735 | continue; |
| 736 | } |
| 737 | if (strcmp(argv[i], "--enable-bt") == 0) |
| 738 | { |
| 739 | vtksys::SystemInformation::SetStackTraceOnError(1); |
| 740 | continue; |
| 741 | } |
| 742 | if (strcmp(argv[i], "-V") == 0) |
| 743 | { |
| 744 | // print out VTK version and let argument pass to Py_RunMain(). At which |
| 745 | // point, Python will print its version and exit. |
| 746 | std::cout << vtkVersion::GetVTKSourceVersion() << std::endl; |
| 747 | } |
| 748 | |
| 749 | OwnedCString argCopy(strdup(argv[i]), &std::free); |
| 750 | if (argCopy == nullptr) |
| 751 | { |
| 752 | vtk::print(stderr, |
| 753 | "Fatal vtkpython error: " |
| 754 | "unable to copy the command line argument #{:d}\n", |
| 755 | i + 1); |
| 756 | return 1; |
nothing calls this directly
no test coverage detected